diff --git a/bolt/runtime/common.h b/bolt/runtime/common.h --- a/bolt/runtime/common.h +++ b/bolt/runtime/common.h @@ -106,6 +106,17 @@ #define MAP_FAILED ((void *)-1) +#define SEEK_SET 0 /* Seek from beginning of file. */ +#define SEEK_CUR 1 /* Seek from current position. */ +#define SEEK_END 2 /* Seek from end of file. */ + +#define O_RDONLY 0 +#define O_WRONLY 1 +#define O_RDWR 2 +#define O_CREAT 64 +#define O_TRUNC 512 +#define O_APPEND 1024 + // Functions that are required by freestanding environment. Compiler may // generate calls to these implicitly. extern "C" { diff --git a/bolt/runtime/instr.cpp b/bolt/runtime/instr.cpp --- a/bolt/runtime/instr.cpp +++ b/bolt/runtime/instr.cpp @@ -684,8 +684,7 @@ return TargetPath; unsigned long CurAddr = (unsigned long)__get_pc(); - uint64_t FDdir = __open(DirPath, - /*flags=*/0 /*O_RDONLY*/, + uint64_t FDdir = __open(DirPath, O_RDONLY, /*mode=*/0666); assert(static_cast(FDdir) >= 0, "failed to open /proc/self/map_files"); @@ -720,15 +719,14 @@ char *BinPath = getBinaryPath(); assert(BinPath && BinPath[0] != '\0', "failed to find binary path"); - uint64_t FD = __open(BinPath, - /*flags=*/0 /*O_RDONLY*/, + uint64_t FD = __open(BinPath, O_RDONLY, /*mode=*/0666); assert(static_cast(FD) >= 0, "failed to open binary path"); Result.FileDesc = FD; // mmap our binary to memory - uint64_t Size = __lseek(FD, 0, 2 /*SEEK_END*/); + uint64_t Size = __lseek(FD, 0, SEEK_END); uint8_t *BinContents = reinterpret_cast( __mmap(0, Size, PROT_READ, MAP_PRIVATE, FD, 0)); assert(BinContents != MAP_FAILED, "readDescriptions: Failed to mmap self!"); @@ -1470,8 +1468,7 @@ Ptr = strCopy(Ptr, ".fdata", BufSize - (Ptr - Buf + 1)); } *Ptr++ = '\0'; - uint64_t FD = __open(Buf, - /*flags=*/0x241 /*O_WRONLY|O_TRUNC|O_CREAT*/, + uint64_t FD = __open(Buf, O_WRONLY | O_TRUNC | O_CREAT, /*mode=*/0666); if (static_cast(FD) < 0) { report("Error while trying to open profile file for writing: ");