diff --git a/libs/nacl/native_client/src/shared/imc/posix/nacl_imc_posix.cc b/libs/nacl/native_client/src/shared/imc/posix/nacl_imc_posix.cc index b8a50977d1..6380325033 100644 --- a/libs/nacl/native_client/src/shared/imc/posix/nacl_imc_posix.cc +++ b/libs/nacl/native_client/src/shared/imc/posix/nacl_imc_posix.cc @@ -80,9 +80,8 @@ static int AshmemCreateRegion(size_t size) { int NaClWouldBlock(void) { return errno == EAGAIN; } - int NaClGetLastErrorString(char* buffer, size_t length) { -#if NACL_LINUX && !NACL_ANDROID +#if NACL_LINUX && defined(__GLIBC__) char* message; /* * Note some Linux distributions provide only GNU version of strerror_r(). diff --git a/src/common/FileSystem.cpp b/src/common/FileSystem.cpp index 03cd3ef266..1016dadee2 100644 --- a/src/common/FileSystem.cpp +++ b/src/common/FileSystem.cpp @@ -192,14 +192,12 @@ inline int my_open(Str::StringRef path, openMode_t mode) int fd = _open_osfhandle(reinterpret_cast(h), modes[mode_] | O_BINARY | O_NOINHERIT); if (fd == -1) CloseHandle(h); -#elif defined(__FreeBSD__) || defined(__APPLE__) - // O_CLOEXEC is supported in macOS from 10.7 onwards - int fd = open(path.c_str(), modes[mode_] | O_CLOEXEC, 0666); -#elif defined(__linux__) +#elif defined(__linux__) && defined(__GLIBC__) int fd = open64(path.c_str(), modes[mode_] | O_CLOEXEC | O_LARGEFILE, 0666); -#elif defined(__native_client__) - // This doesn't actually work, but it's not used anyways - int fd = open(path.c_str(), modes[mode_], 0666); +#else + // This doesn't actually work in Native Client, but it's not used anyways. + // O_CLOEXEC is supported in macOS from 10.7 onwards. + int fd = open(path.c_str(), modes[mode_] | O_CLOEXEC, 0666); #endif #ifndef _WIN32 @@ -238,47 +236,47 @@ inline offset_t my_ftell(FILE* fd) { #ifdef _WIN32 return _ftelli64(fd); -#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__native_client__) - return ftello(fd); -#elif defined(__linux__) +#elif defined(__linux__) && defined(__GLIBC__) return ftello64(fd); +#else + return ftello(fd); #endif } inline int my_fseek(FILE* fd, offset_t off, int whence) { #ifdef _WIN32 return _fseeki64(fd, off, whence); -#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__native_client__) - return fseeko(fd, off, whence); -#elif defined(__linux__) +#elif defined(__linux__) && defined(__GLIBC__) return fseeko64(fd, off, whence); +#else + return fseeko(fd, off, whence); #endif } #ifdef _WIN32 typedef struct _stati64 my_stat_t; -#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__native_client__) -using my_stat_t = struct stat; -#elif defined(__linux__) +#elif defined(__linux__) && defined(__GLIBC__) using my_stat_t = struct stat64; +#else +using my_stat_t = struct stat; #endif inline int my_fstat(int fd, my_stat_t* st) { #ifdef _WIN32 return _fstati64(fd, st); -#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__native_client__) - return fstat(fd, st); -#elif defined(__linux__) +#elif defined(__linux__) && defined(__GLIBC__) return fstat64(fd, st); +#else + return fstat(fd, st); #endif } inline int my_stat(Str::StringRef path, my_stat_t* st) { #ifdef _WIN32 return _wstati64(Str::UTF8To16(path).c_str(), st); -#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__native_client__) - return stat(path.c_str(), st); -#elif defined(__linux__) +#elif defined(__linux__) && defined(__GLIBC__) return stat64(path.c_str(), st); +#else + return stat(path.c_str(), st); #endif } inline intptr_t my_pread(int fd, void* buf, size_t count, offset_t offset) @@ -294,10 +292,10 @@ inline intptr_t my_pread(int fd, void* buf, size_t count, offset_t offset) return -1; } return bytesRead; -#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__native_client__) - return pread(fd, buf, count, offset); -#elif defined(__linux__) +#elif defined(__linux__) && defined(__GLIBC__) return pread64(fd, buf, count, offset); +#else + return pread(fd, buf, count, offset); #endif }