Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
48 changes: 23 additions & 25 deletions src/common/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,12 @@ inline int my_open(Str::StringRef path, openMode_t mode)
int fd = _open_osfhandle(reinterpret_cast<intptr_t>(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
Expand Down Expand Up @@ -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)
Expand All @@ -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
}

Expand Down