about summary refs log tree commit diff homepage
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/POSIX/CMakeLists.txt5
-rw-r--r--runtime/POSIX/fd.c15
2 files changed, 15 insertions, 5 deletions
diff --git a/runtime/POSIX/CMakeLists.txt b/runtime/POSIX/CMakeLists.txt
index 02d06736..d8208d9b 100644
--- a/runtime/POSIX/CMakeLists.txt
+++ b/runtime/POSIX/CMakeLists.txt
@@ -20,6 +20,11 @@ set(SRC_FILES
         stubs.c
         )
 
+try_compile (FSTATAT_PATH_ACCEPTS_NULL
+        ${CMAKE_BINARY_DIR}
+        ${PROJECT_SOURCE_DIR}/cmake/fstatat.c
+        )
+
 # Build it
 include("${CMAKE_SOURCE_DIR}/cmake/compile_bitcode_library.cmake")
 prefix_with_path("${SRC_FILES}" "${CMAKE_CURRENT_SOURCE_DIR}/" prefixed_files)
diff --git a/runtime/POSIX/fd.c b/runtime/POSIX/fd.c
index 35d0d315..0aba0ade 100644
--- a/runtime/POSIX/fd.c
+++ b/runtime/POSIX/fd.c
@@ -568,16 +568,21 @@ int fstatat(int fd, const char *path, struct stat *buf, int flags) {
     return 0;
   } 
 
+#ifdef FSTATAT_PATH_ACCEPTS_NULL
+  #define PATHPARAM (path ? __concretize_string(path) : NULL)
+#else
+  assert(path);
+  #define PATHPARAM (__concretize_string(path))
+#endif
+
 #if (defined __NR_newfstatat) && (__NR_newfstatat != 0)
-  return syscall(__NR_newfstatat, (long)fd,
-                 (path ? __concretize_string(path) : NULL), buf, (long)flags);
+  return syscall(__NR_newfstatat, (long)fd, PATHPARAM, buf, (long)flags);
 #else
-  return syscall(__NR_fstatat64, (long)fd,
-                 (path ? __concretize_string(path) : NULL), buf, (long)flags);
+  return syscall(__NR_fstatat64, (long)fd, PATHPARAM, buf, (long)flags);
 #endif
+#undef PATHPARAM
 }
 
-
 int __fd_lstat(const char *path, struct stat64 *buf) {
   exe_disk_file_t *dfile = __get_sym_file(path);
   if (dfile) {