CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
78 lines
2.0 KiB
C
78 lines
2.0 KiB
C
//===- file_map.c ---------------------------------------------------------===//
|
|
//
|
|
// Part of Comgr, under the Apache License v2.0 with LLVM Exceptions. See
|
|
// amd/comgr/LICENSE.TXT in this repository for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "amd_comgr.h"
|
|
#include "common.h"
|
|
|
|
int main(int argc, char *argv[]) {
|
|
int Ret;
|
|
amd_comgr_status_t Status;
|
|
|
|
const char *FileName = "comgr_map_test_file.txt";
|
|
|
|
// Remove any stray file that may exist from before.
|
|
remove(FileName);
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
int FD = _open(FileName, _O_CREAT | _O_RDWR);
|
|
#else
|
|
int FD = open(FileName, O_CREAT | O_RDWR, 0755);
|
|
#endif
|
|
if (FD < 0) {
|
|
fail("open failed for %s with errno %d", FileName, errno);
|
|
}
|
|
|
|
const char *Buffer = "abcdefghi";
|
|
size_t Length = strlen(Buffer);
|
|
size_t Bytes = WriteFileCustom(FD, Buffer, Length);
|
|
if (Bytes != Length) {
|
|
fail("Write failed with ret %zu", Bytes);
|
|
}
|
|
|
|
amd_comgr_data_t DataObject;
|
|
Status = amd_comgr_create_data(AMD_COMGR_DATA_KIND_RELOCATABLE, &DataObject);
|
|
checkError(Status, "amd_comgr_create_data");
|
|
|
|
uint64_t Offset = 2;
|
|
Status = amd_comgr_set_data_from_file_slice(DataObject, FD, Offset, Length);
|
|
checkError(Status, "amd_comgr_get_file_slice");
|
|
|
|
char Slice[10];
|
|
size_t SliceLength = Length - 2;
|
|
Status = amd_comgr_get_data(DataObject, &SliceLength, Slice);
|
|
checkError(Status, "amd_comgr_get_data");
|
|
|
|
Status = amd_comgr_release_data(DataObject);
|
|
checkError(Status, "amd_comgr_release_data");
|
|
|
|
if (SliceLength != Length - Offset) {
|
|
fail("File Slice Length incorrect");
|
|
}
|
|
|
|
if (!strncmp(Slice, Buffer, Length - Offset)) {
|
|
fail("File Slice read failed");
|
|
}
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
_close(FD);
|
|
#else
|
|
close(FD);
|
|
#endif
|
|
|
|
if ((Ret = remove(FileName)) != 0) {
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
if ((Ret = remove(FileName)) != 0) {
|
|
fail("remove failed");
|
|
}
|
|
#else
|
|
fail("remove failed");
|
|
#endif
|
|
}
|
|
return 0;
|
|
}
|