]> git.proxmox.com Git - wasi-libc.git/commitdiff
Remove __wasilibc_unmodified_upstream markers from libc-bottom-half.
authorDan Gohman <dev@sunfishcode.online>
Fri, 5 Feb 2021 00:36:38 +0000 (16:36 -0800)
committerDan Gohman <dev@sunfishcode.online>
Fri, 5 Feb 2021 05:22:15 +0000 (21:22 -0800)
We've already started removing this; this just removes all remaining
ones under the libc-bottom-half directory.

These markers were originally intended to help track upstream changes,
however in practice they created a lot of clutter and weren't that
helpful. And now, upstream cloudlibc is no longer active.

47 files changed:
libc-bottom-half/cloudlibc/src/common/errno.h
libc-bottom-half/cloudlibc/src/include/stdlib.h
libc-bottom-half/cloudlibc/src/libc/dirent/fdopendir.c
libc-bottom-half/cloudlibc/src/libc/dirent/opendirat.c
libc-bottom-half/cloudlibc/src/libc/dirent/readdir.c
libc-bottom-half/cloudlibc/src/libc/dirent/scandirat.c
libc-bottom-half/cloudlibc/src/libc/fcntl/fcntl.c
libc-bottom-half/cloudlibc/src/libc/fcntl/openat.c
libc-bottom-half/cloudlibc/src/libc/fcntl/posix_fadvise.c
libc-bottom-half/cloudlibc/src/libc/fcntl/posix_fallocate.c
libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c
libc-bottom-half/cloudlibc/src/libc/stdio/renameat.c
libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c
libc-bottom-half/cloudlibc/src/libc/sys/resource/getrusage.c
libc-bottom-half/cloudlibc/src/libc/sys/select/select.c
libc-bottom-half/cloudlibc/src/libc/sys/socket/getsockopt.c
libc-bottom-half/cloudlibc/src/libc/sys/socket/recv.c
libc-bottom-half/cloudlibc/src/libc/sys/socket/send.c
libc-bottom-half/cloudlibc/src/libc/sys/socket/shutdown.c
libc-bottom-half/cloudlibc/src/libc/sys/stat/fstat.c
libc-bottom-half/cloudlibc/src/libc/sys/stat/fstatat.c
libc-bottom-half/cloudlibc/src/libc/sys/stat/futimens.c
libc-bottom-half/cloudlibc/src/libc/sys/stat/mkdirat.c
libc-bottom-half/cloudlibc/src/libc/sys/stat/stat_impl.h
libc-bottom-half/cloudlibc/src/libc/sys/stat/utimensat.c
libc-bottom-half/cloudlibc/src/libc/sys/time/gettimeofday.c
libc-bottom-half/cloudlibc/src/libc/sys/times/times.c
libc-bottom-half/cloudlibc/src/libc/time/CLOCK_MONOTONIC.c
libc-bottom-half/cloudlibc/src/libc/time/CLOCK_PROCESS_CPUTIME_ID.c
libc-bottom-half/cloudlibc/src/libc/time/CLOCK_REALTIME.c
libc-bottom-half/cloudlibc/src/libc/time/CLOCK_THREAD_CPUTIME_ID.c
libc-bottom-half/cloudlibc/src/libc/time/clock.c
libc-bottom-half/cloudlibc/src/libc/time/clock_gettime.c
libc-bottom-half/cloudlibc/src/libc/time/clock_nanosleep.c
libc-bottom-half/cloudlibc/src/libc/time/nanosleep.c
libc-bottom-half/cloudlibc/src/libc/time/time.c
libc-bottom-half/cloudlibc/src/libc/unistd/faccessat.c
libc-bottom-half/cloudlibc/src/libc/unistd/ftruncate.c
libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c
libc-bottom-half/cloudlibc/src/libc/unistd/lseek.c
libc-bottom-half/cloudlibc/src/libc/unistd/pread.c
libc-bottom-half/cloudlibc/src/libc/unistd/pwrite.c
libc-bottom-half/cloudlibc/src/libc/unistd/readlinkat.c
libc-bottom-half/cloudlibc/src/libc/unistd/sleep.c
libc-bottom-half/cloudlibc/src/libc/unistd/symlinkat.c
libc-bottom-half/cloudlibc/src/libc/unistd/unlinkat.c
libc-bottom-half/cloudlibc/src/libc/unistd/usleep.c

index ebc1734a52cc2a7180ad98090c04dad2008678d4..7d178fbc5696741e56a75f195526867abafd1301 100644 (file)
@@ -7,78 +7,16 @@
 
 #include <wasi/api.h>
 
-#ifdef __wasilibc_unmodified_upstream
-// Translates ENOTCAPABLE to ENOTDIR if not a directory.
-static inline __wasi_errno_t errno_fixup_directory(__wasi_fd_t fd,
-                                                     __wasi_errno_t error) {
-  if (error == __WASI_ENOTCAPABLE) {
-    __wasi_fdstat_t fds;
-    if (__wasi_fd_stat_get(fd, &fds) == 0 &&
-        fds.fs_filetype != __WASI_FILETYPE_DIRECTORY)
-      return __WASI_ENOTDIR;
-  }
-  return error;
-}
-#else
 // WASI syscalls should just return ENOTDIR if that's what the problem is.
 static inline __wasi_errno_t errno_fixup_directory(__wasi_fd_t fd,
                                                      __wasi_errno_t error) {
   return error;
 }
-#endif
-
-#ifdef __wasilibc_unmodified_upstream // posix_spawn etc.
-// Translates ENOTCAPABLE to EBADF if a regular file or EACCES otherwise.
-static inline __wasi_errno_t errno_fixup_executable(__wasi_fd_t fd,
-                                                      __wasi_errno_t error) {
-  if (error == __WASI_ENOTCAPABLE) {
-    __wasi_fdstat_t fds;
-    if (__wasi_fd_stat_get(fd, &fds) == 0)
-      return fds.fs_filetype == __WASI_FILETYPE_REGULAR_FILE
-                 ? __WASI_EBADF
-                 : __WASI_EACCES;
-  }
-  return error;
-}
-#endif
 
-#ifdef __wasilibc_unmodified_upstream // process file descriptors
-// Translates ENOTCAPABLE to EINVAL if not a process.
-static inline __wasi_errno_t errno_fixup_process(__wasi_fd_t fd,
-                                                   __wasi_errno_t error) {
-  if (error == __WASI_ENOTCAPABLE) {
-    __wasi_fdstat_t fds;
-    if (__wasi_fd_stat_get(fd, &fds) == 0 &&
-        fds.fs_filetype != __WASI_FILETYPE_PROCESS)
-      return __WASI_EINVAL;
-  }
-  return error;
-}
-#endif
-
-#ifdef __wasilibc_unmodified_upstream
-// Translates ENOTCAPABLE to ENOTSOCK if not a socket.
-static inline __wasi_errno_t errno_fixup_socket(__wasi_fd_t fd,
-                                                  __wasi_errno_t error) {
-  if (error == __WASI_ENOTCAPABLE) {
-    __wasi_fdstat_t fds;
-    if (__wasi_fd_stat_get(fd, &fds) == 0 &&
-#ifdef __wasilibc_unmodified_upstream // don't hard-code magic numbers
-        (fds.fs_filetype & 0xf0) != 0x80)
-#else
-        (fds.fs_filetype != __WASI_FILETYPE_SOCKET_STREAM &&
-         fds.fs_filetype != __WASI_FILETYPE_SOCKET_DGRAM))
-#endif
-      return __WASI_ENOTSOCK;
-  }
-  return error;
-}
-#else
 // WASI syscalls should just return ENOTSOCK if that's what the problem is.
 static inline __wasi_errno_t errno_fixup_socket(__wasi_fd_t fd,
                                                   __wasi_errno_t error) {
   return error;
 }
-#endif
 
 #endif
index e30b8de0fefda2482fd69e2d8da50bd8e44d964c..ff48afbb49a1e8de24377175b63155504cc4be1f 100644 (file)
 #include <_/limits.h>
 #include <_/types.h>
 
-#ifdef __wasilibc_unmodified_upstream
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-
-#define RAND_MAX _INT_MAX
-
-#define NULL _NULL
-
-typedef struct {
-  int quot;
-  int rem;
-} div_t;
-
-typedef struct {
-  long quot;
-  long rem;
-} ldiv_t;
-
-typedef struct {
-  long long quot;
-  long long rem;
-} lldiv_t;
-
-#ifndef _SIZE_T_DECLARED
-typedef __size_t size_t;
-#define _SIZE_T_DECLARED
-#endif
-#ifndef _WCHAR_T_DECLARED
-typedef __wchar_t wchar_t;
-#define _WCHAR_T_DECLARED
-#endif
-
-#ifdef __wasilibc_unmodified_upstream
-// Process wide locale always uses ASCII.
-#define MB_CUR_MAX ((size_t)1)
-#endif
-
-// Keep existing code happy that assumes that MB_CUR_MAX_L is a macro.
-#define MB_CUR_MAX_L MB_CUR_MAX_L
-
-#define alloca(size) __builtin_alloca(size)
-#endif
-
 __BEGIN_DECLS
 _Noreturn void _Exit(int);
-#ifdef __wasilibc_unmodified_upstream
-size_t MB_CUR_MAX_L(__locale_t);
-long a64l(const char *);
-#endif
 _Noreturn void abort(void);
-#ifdef __wasilibc_unmodified_upstream
-int abs(int) __pure2;
-int at_quick_exit(void (*)(void));
-int atexit(void (*)(void));
-void *aligned_alloc(size_t, size_t);
-__uint32_t arc4random(void);
-void arc4random_buf(void *, size_t);
-__uint32_t arc4random_uniform(__uint32_t);
-double atof(const char *);
-int atoi(const char *);
-long atol(const char *);
-long long atoll(const char *);
-void *bsearch(const void *, const void *, size_t, size_t,
-              int (*)(const void *, const void *));
-#endif
 void *calloc(size_t, size_t);
-#ifdef __wasilibc_unmodified_upstream
-div_t div(int, int) __pure2;
-double drand48(void);
-double erand48(__uint16_t *);
-#endif
 _Noreturn void exit(int);
 void free(void *);
-#ifdef __wasilibc_unmodified_upstream
-char *getenv(const char *);
-int getsubopt(char **, char *const *, char **);
-long jrand48(__uint16_t *);
-int l64a_r(long, char *, int);
-long labs(long) __pure2;
-ldiv_t ldiv(long, long) __pure2;
-long long llabs(long long) __pure2;
-lldiv_t lldiv(long long, long long) __pure2;
-long lrand48(void);
-#endif
 void *malloc(size_t);
-#ifdef __wasilibc_unmodified_upstream
-int mblen(const char *, size_t);
-int mblen_l(const char *, size_t, __locale_t);
-size_t mbstowcs(wchar_t *__restrict, const char *__restrict, size_t);
-size_t mbstowcs_l(wchar_t *__restrict, const char *__restrict, size_t,
-                  __locale_t);
-int mbtowc(wchar_t *__restrict, const char *__restrict, size_t);
-int mbtowc_l(wchar_t *__restrict, const char *__restrict, size_t, __locale_t);
-long mrand48(void);
-long nrand48(__uint16_t *);
-int posix_memalign(void **, size_t, size_t);
-#endif
 void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
-#ifdef __wasilibc_unmodified_upstream
-void qsort_r(void *, size_t, size_t,
-             int (*)(const void *, const void *, void *), void *);
-_Noreturn void quick_exit(int);
-int rand(void);
-long random(void);
-#endif
 void *realloc(void *, size_t);
-#ifdef __wasilibc_unmodified_upstream
-void *reallocarray(void *, size_t, size_t);
-double strtod(const char *__restrict, char **__restrict);
-double strtod_l(const char *__restrict, char **__restrict, __locale_t);
-float strtof(const char *__restrict, char **__restrict);
-float strtof_l(const char *__restrict, char **__restrict, __locale_t);
-long strtol(const char *__restrict, char **__restrict, int);
-long strtol_l(const char *__restrict, char **__restrict, int, __locale_t);
-long double strtold(const char *__restrict, char **__restrict);
-long double strtold_l(const char *__restrict, char **__restrict, __locale_t);
-long long strtoll(const char *__restrict, char **__restrict, int);
-long long strtoll_l(const char *__restrict, char **__restrict, int, __locale_t);
-unsigned long strtoul(const char *__restrict, char **__restrict, int);
-unsigned long strtoul_l(const char *__restrict, char **__restrict, int,
-                        __locale_t);
-unsigned long long strtoull(const char *__restrict, char **__restrict, int);
-unsigned long long strtoull_l(const char *__restrict, char **__restrict, int,
-                              __locale_t);
-size_t wcstombs(char *__restrict, const wchar_t *__restrict, size_t);
-size_t wcstombs_l(char *__restrict, const wchar_t *__restrict, size_t,
-                  __locale_t);
-int wctomb(char *, wchar_t);
-int wctomb_l(char *, wchar_t, __locale_t);
-#endif
 __END_DECLS
 
 #if _CLOUDLIBC_INLINE_FUNCTIONS
-#ifdef __wasilibc_unmodified_upstream
-static __inline double __atof(const char *__str) {
-  return strtod(__str, NULL);
-}
-#define atof(str) __atof(str)
-
-static __inline int __atoi(const char *__str) {
-  return (int)strtol(__str, NULL, 10);
-}
-#define atoi(str) __atoi(str)
-
-static __inline long __atol(const char *__str) {
-  return strtol(__str, NULL, 10);
-}
-#define atol(str) __atol(str)
-
-static __inline long long __atoll(const char *__str) {
-  return strtoll(__str, NULL, 10);
-}
-#define atoll(str) __atoll(str)
-
-static __inline int __abs(int __i) {
-  return __i < 0 ? -__i : __i;
-}
-#define abs(i) __abs(i)
-
-static __inline long __labs(long __i) {
-  return __i < 0 ? -__i : __i;
-}
-#define labs(i) __labs(i)
-
-static __inline long long __llabs(long long __i) {
-  return __i < 0 ? -__i : __i;
-}
-#define llabs(i) __llabs(i)
-
-static __inline div_t __div(int __numer, int __denom) {
-  div_t __res = {__numer / __denom, __numer % __denom};
-  return __res;
-}
-#define div(numer, denom) __div(numer, denom)
-
-static __inline ldiv_t __ldiv(long __numer, long __denom) {
-  ldiv_t __res = {__numer / __denom, __numer % __denom};
-  return __res;
-}
-#define ldiv(numer, denom) __ldiv(numer, denom)
-
-static __inline lldiv_t __lldiv(long long __numer, long long __denom) {
-  lldiv_t __res = {__numer / __denom, __numer % __denom};
-  return __res;
-}
-#define lldiv(numer, denom) __lldiv(numer, denom)
-
-static __inline void *__bsearch(const void *__key, const void *__base,
-                                size_t __nel, size_t __width,
-                                int (*__compar)(const void *, const void *)) {
-  const char *__basep, *__obj;
-  size_t __mid, __skip;
-  int __cmp;
-
-  __basep = (const char *)__base;
-  while (__nel > 0) {
-    // Pick pivot.
-    __mid = __nel / 2;
-    __obj = __basep + __mid * __width;
-    __cmp = __compar(__key, (const void *)__obj);
-    if (__cmp < 0) {
-      // key < obj. Restrict search to top of the list.
-      __nel = __mid;
-    } else if (__cmp > 0) {
-      // key > obj. Restrict search to bottom of the list.
-      __skip = __mid + 1;
-      __basep += __skip * __width;
-      __nel -= __skip;
-    } else {
-      return (void *)__obj;
-    }
-  }
-  return NULL;
-}
-#define bsearch(key, base, nel, width, compar) \
-  __preserve_const(void, __bsearch, base, key, base, nel, width, compar)
-#endif
 
 // qsort_r() implementation from Bentley and McIlroy's
 // "Engineering a Sort Function".
index 325093fc29c4aa09a40e514bb7645d8bd0df9e4f..59fc027e8d8ad309b5509cd9f9d8a248f0d0f55d 100644 (file)
@@ -25,12 +25,8 @@ DIR *fdopendir(int fd) {
   // Ensure that this is really a directory by already loading the first
   // chunk of data.
   __wasi_errno_t error =
-#ifdef __wasilibc_unmodified_upstream
-      __wasi_file_readdir(fd, dirp->buffer, DIRENT_DEFAULT_BUFFER_SIZE,
-#else
       // TODO: Remove the cast on `dirp->buffer` once the witx is updated with char8 support.
       __wasi_fd_readdir(fd, (uint8_t *)dirp->buffer, DIRENT_DEFAULT_BUFFER_SIZE,
-#endif
                                 __WASI_DIRCOOKIE_START, &dirp->buffer_used);
   if (error != 0) {
     free(dirp->buffer);
index c940d5f3b5a47eb212de44a8aeccea5387cdd137..1465004f2a279e631335eff0ace3a21e6330e620 100644 (file)
 
 DIR *opendirat(int dir, const char *dirname) {
   // Open directory.
-#ifdef __wasilibc_unmodified_upstream // avoid making a varargs call
-  int fd = openat(dir, dirname, O_RDONLY | O_NONBLOCK | O_DIRECTORY);
-#else
   int fd = __wasilibc_openat_nomode(dir, dirname, O_RDONLY | O_NONBLOCK | O_DIRECTORY);
-#endif
   if (fd == -1)
     return NULL;
 
index c4a2013037ad4bf72c052076b45daf800d51fb73..b5650d6cdfa6c9d7e74ed14527a66fe70e69b1e6 100644 (file)
@@ -91,12 +91,8 @@ struct dirent *readdir(DIR *dirp) {
 
     // Load more directory entries and continue.
     __wasi_errno_t error =
-#ifdef __wasilibc_unmodified_upstream
-        __wasi_file_readdir(dirp->fd, dirp->buffer, dirp->buffer_size,
-#else
         // TODO: Remove the cast on `dirp->buffer` once the witx is updated with char8 support.
         __wasi_fd_readdir(dirp->fd, (uint8_t *)dirp->buffer, dirp->buffer_size,
-#endif
                                   dirp->cookie, &dirp->buffer_used);
     if (error != 0) {
       errno = error;
index 83cdeb91e76013e006f0182730d5cad4a1b9bb89..a77a1d31f401b37c739426b2dcbc7a736965507e 100644 (file)
@@ -25,11 +25,7 @@ int scandirat(int dirfd, const char *dir, struct dirent ***namelist,
     sel = sel_true;
 
   // Open the directory.
-#ifdef __wasilibc_unmodified_upstream // avoid making a varargs call
-  int fd = openat(dirfd, dir, O_RDONLY | O_NONBLOCK | O_DIRECTORY);
-#else
   int fd = __wasilibc_openat_nomode(dirfd, dir, O_RDONLY | O_NONBLOCK | O_DIRECTORY);
-#endif
   if (fd == -1)
     return -1;
 
@@ -119,12 +115,8 @@ int scandirat(int dirfd, const char *dir, struct dirent ***namelist,
 
   read_entries:;
     // Load more directory entries and continue.
-#ifdef __wasilibc_unmodified_upstream
-    __wasi_errno_t error = __wasi_file_readdir(fd, buffer, buffer_size,
-#else
     // TODO: Remove the cast on `buffer` once the witx is updated with char8 support.
     __wasi_errno_t error = __wasi_fd_readdir(fd, (uint8_t *)buffer, buffer_size,
-#endif
                                                        cookie, &buffer_used);
     if (error != 0) {
       errno = error;
index d4e5597463626d0ae02fae0f2bcf3b02dc6633db..5d4055dd5fa46294fdadf4fb28169d8a783da704 100644 (file)
@@ -18,11 +18,7 @@ int fcntl(int fildes, int cmd, ...) {
     case F_GETFL: {
       // Obtain the flags and the rights of the descriptor.
       __wasi_fdstat_t fds;
-#ifdef __wasilibc_unmodified_upstream
-      __wasi_errno_t error = __wasi_fd_stat_get(fildes, &fds);
-#else
       __wasi_errno_t error = __wasi_fd_fdstat_get(fildes, &fds);
-#endif
       if (error != 0) {
         errno = error;
         return -1;
@@ -31,26 +27,13 @@ int fcntl(int fildes, int cmd, ...) {
       // Roughly approximate the access mode by converting the rights.
       int oflags = fds.fs_flags;
       if ((fds.fs_rights_base &
-#ifdef __wasilibc_unmodified_upstream
-           (__WASI_RIGHT_FD_READ | __WASI_RIGHT_FILE_READDIR)) != 0) {
-        if ((fds.fs_rights_base & __WASI_RIGHT_FD_WRITE) != 0)
-#else
            (__WASI_RIGHTS_FD_READ | __WASI_RIGHTS_FD_READDIR)) != 0) {
         if ((fds.fs_rights_base & __WASI_RIGHTS_FD_WRITE) != 0)
-#endif
           oflags |= O_RDWR;
         else
           oflags |= O_RDONLY;
-#ifdef __wasilibc_unmodified_upstream
-      } else if ((fds.fs_rights_base & __WASI_RIGHT_FD_WRITE) != 0) {
-#else
       } else if ((fds.fs_rights_base & __WASI_RIGHTS_FD_WRITE) != 0) {
-#endif
         oflags |= O_WRONLY;
-#ifdef __wasilibc_unmodified_upstream
-      } else if ((fds.fs_rights_base & __WASI_RIGHT_PROC_EXEC) != 0) {
-        oflags |= O_EXEC;
-#endif
       } else {
         oflags |= O_SEARCH;
       }
@@ -63,15 +46,9 @@ int fcntl(int fildes, int cmd, ...) {
       int flags = va_arg(ap, int);
       va_end(ap);
 
-#ifdef __wasilibc_unmodified_upstream // fstat
-      __wasi_fdstat_t fds = {.fs_flags = flags & 0xfff};
-      __wasi_errno_t error =
-          __wasi_fd_stat_put(fildes, &fds, __WASI_FDSTAT_FLAGS);
-#else
       __wasi_fdflags_t fs_flags = flags & 0xfff;
       __wasi_errno_t error =
           __wasi_fd_fdstat_set_flags(fildes, fs_flags);
-#endif
       if (error != 0) {
         errno = error;
         return -1;
index 12d62b724cc7855668f62784a431d52312c37551..da54a722c83a0fba1e3a5cc8a3dafca73e13036e 100644 (file)
 #include <fcntl.h>
 #include <string.h>
 
-#ifdef __wasilibc_unmodified_upstream // fstat
-static_assert(O_APPEND == __WASI_FDFLAG_APPEND, "Value mismatch");
-static_assert(O_DSYNC == __WASI_FDFLAG_DSYNC, "Value mismatch");
-static_assert(O_NONBLOCK == __WASI_FDFLAG_NONBLOCK, "Value mismatch");
-static_assert(O_RSYNC == __WASI_FDFLAG_RSYNC, "Value mismatch");
-static_assert(O_SYNC == __WASI_FDFLAG_SYNC, "Value mismatch");
-#else
 static_assert(O_APPEND == __WASI_FDFLAGS_APPEND, "Value mismatch");
 static_assert(O_DSYNC == __WASI_FDFLAGS_DSYNC, "Value mismatch");
 static_assert(O_NONBLOCK == __WASI_FDFLAGS_NONBLOCK, "Value mismatch");
 static_assert(O_RSYNC == __WASI_FDFLAGS_RSYNC, "Value mismatch");
 static_assert(O_SYNC == __WASI_FDFLAGS_SYNC, "Value mismatch");
-#endif
 
-#ifdef __wasilibc_unmodified_upstream // fstat
-static_assert(O_CREAT >> 12 == __WASI_O_CREAT, "Value mismatch");
-static_assert(O_DIRECTORY >> 12 == __WASI_O_DIRECTORY, "Value mismatch");
-static_assert(O_EXCL >> 12 == __WASI_O_EXCL, "Value mismatch");
-static_assert(O_TRUNC >> 12 == __WASI_O_TRUNC, "Value mismatch");
-#else
 static_assert(O_CREAT >> 12 == __WASI_OFLAGS_CREAT, "Value mismatch");
 static_assert(O_DIRECTORY >> 12 == __WASI_OFLAGS_DIRECTORY, "Value mismatch");
 static_assert(O_EXCL >> 12 == __WASI_OFLAGS_EXCL, "Value mismatch");
 static_assert(O_TRUNC >> 12 == __WASI_OFLAGS_TRUNC, "Value mismatch");
-#endif
 
 int openat(int fd, const char *path, int oflag, ...) {
-#ifdef __wasilibc_unmodified_upstream // fstat
-#else
     return __wasilibc_openat_nomode(fd, path, oflag);
 }
 
 int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
-#endif
   // Compute rights corresponding with the access modes provided.
   // Attempt to obtain all rights, except the ones that contradict the
   // access mode provided to openat().
-#ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
-  __wasi_rights_t min = 0;
-#endif
   __wasi_rights_t max =
-#ifdef __wasilibc_unmodified_upstream // fstat
-      ~(__WASI_RIGHT_FD_DATASYNC | __WASI_RIGHT_FD_READ |
-        __WASI_RIGHT_FD_WRITE | __WASI_RIGHT_FILE_ALLOCATE |
-        __WASI_RIGHT_FILE_READDIR | __WASI_RIGHT_FILE_STAT_FPUT_SIZE |
-#else
       ~(__WASI_RIGHTS_FD_DATASYNC | __WASI_RIGHTS_FD_READ |
         __WASI_RIGHTS_FD_WRITE | __WASI_RIGHTS_FD_ALLOCATE |
         __WASI_RIGHTS_FD_READDIR | __WASI_RIGHTS_FD_FILESTAT_SET_SIZE |
-#endif
-#ifdef __wasilibc_unmodified_upstream // RIGHT_MEM_MAP_EXEC
-        __WASI_RIGHT_MEM_MAP_EXEC);
-#else
         0);
-#endif
   switch (oflag & O_ACCMODE) {
     case O_RDONLY:
     case O_RDWR:
     case O_WRONLY:
       if ((oflag & O_RDONLY) != 0) {
-#ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
-        min |= (oflag & O_DIRECTORY) == 0 ? __WASI_RIGHT_FD_READ
-                                          : __WASI_RIGHT_FILE_READDIR;
-#endif
-#ifdef __wasilibc_unmodified_upstream // RIGHT_MEM_MAP_EXEC
-        max |= __WASI_RIGHT_FD_READ | __WASI_RIGHT_FILE_READDIR |
-               __WASI_RIGHT_MEM_MAP_EXEC;
-#else
         max |= __WASI_RIGHTS_FD_READ | __WASI_RIGHTS_FD_READDIR;
-#endif
       }
       if ((oflag & O_WRONLY) != 0) {
-#ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
-        min |= __WASI_RIGHT_FD_WRITE;
-        if ((oflag & O_APPEND) == 0)
-          min |= __WASI_RIGHT_FD_SEEK;
-#endif
-#ifdef __wasilibc_unmodified_upstream // fstat
-        max |= __WASI_RIGHT_FD_DATASYNC | __WASI_RIGHT_FD_WRITE |
-               __WASI_RIGHT_FILE_ALLOCATE |
-               __WASI_RIGHT_FILE_STAT_FPUT_SIZE;
-#else
         max |= __WASI_RIGHTS_FD_DATASYNC | __WASI_RIGHTS_FD_WRITE |
                __WASI_RIGHTS_FD_ALLOCATE |
                __WASI_RIGHTS_FD_FILESTAT_SET_SIZE;
-#endif
       }
       break;
     case O_EXEC:
-#ifdef __wasilibc_unmodified_upstream // RIGHT_PROC_EXEC
-      min |= __WASI_RIGHT_PROC_EXEC;
-#endif
       break;
     case O_SEARCH:
       break;
@@ -110,57 +56,21 @@ int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
       errno = EINVAL;
       return -1;
   }
-#ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
-  assert((min & max) == min &&
-         "Minimal rights should be a subset of the maximum");
-#endif
 
   // Ensure that we can actually obtain the minimal rights needed.
   __wasi_fdstat_t fsb_cur;
-#ifdef __wasilibc_unmodified_upstream
-  __wasi_errno_t error = __wasi_fd_stat_get(fd, &fsb_cur);
-#else
   __wasi_errno_t error = __wasi_fd_fdstat_get(fd, &fsb_cur);
-#endif
   if (error != 0) {
     errno = error;
     return -1;
   }
-#ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
-  if (fsb_cur.fs_filetype != __WASI_FILETYPE_DIRECTORY) {
-    errno = ENOTDIR;
-    return -1;
-  }
-  if ((min & fsb_cur.fs_rights_inheriting) != min) {
-    errno = ENOTCAPABLE;
-    return -1;
-  }
-#endif
 
   // Path lookup properties.
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-  __wasi_lookup_t lookup = {.fd = fd, .flags = 0};
-#else
   __wasi_lookupflags_t lookup_flags = 0;
-#endif
   if ((oflag & O_NOFOLLOW) == 0)
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-    lookup.flags |= __WASI_LOOKUP_SYMLINK_FOLLOW;
-#else
     lookup_flags |= __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW;
-#endif
 
   // Open file with appropriate rights.
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t and __wasi_fdstat_t
-  __wasi_fdstat_t fsb_new = {
-      .fs_flags = oflag & 0xfff,
-      .fs_rights_base = max & fsb_cur.fs_rights_inheriting,
-      .fs_rights_inheriting = fsb_cur.fs_rights_inheriting,
-  };
-  __wasi_fd_t newfd;
-  error = __wasi_file_open(lookup, path, strlen(path),
-                                 (oflag >> 12) & 0xfff, &fsb_new, &newfd);
-#else
   __wasi_fdflags_t fs_flags = oflag & 0xfff;
   __wasi_rights_t fs_rights_base = max & fsb_cur.fs_rights_inheriting;
   __wasi_rights_t fs_rights_inheriting = fsb_cur.fs_rights_inheriting;
@@ -169,13 +79,8 @@ int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
                                  (oflag >> 12) & 0xfff,
                                  fs_rights_base, fs_rights_inheriting, fs_flags,
                                  &newfd);
-#endif
   if (error != 0) {
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-    errno = errno_fixup_directory(lookup.fd, error);
-#else
     errno = errno_fixup_directory(fd, error);
-#endif
     return -1;
   }
   return newfd;
index af8d7e1a6e46080fa253ec2861b1c7dddd079722..d683d399f247297e7eb78ed10185d9987562b759 100644 (file)
@@ -20,9 +20,5 @@ static_assert(POSIX_FADV_WILLNEED == __WASI_ADVICE_WILLNEED,
 int posix_fadvise(int fd, off_t offset, off_t len, int advice) {
   if (offset < 0 || len < 0)
     return EINVAL;
-#ifdef __wasilibc_unmodified_upstream
-  return __wasi_file_advise(fd, offset, len, advice);
-#else
   return __wasi_fd_advise(fd, offset, len, advice);
-#endif
 }
index 44e1842480f353ec256ac61c849b11ae064b3182..4b41c4b65c9a721555e09bb6435a77bbe95cba99 100644 (file)
@@ -9,9 +9,5 @@
 int posix_fallocate(int fd, off_t offset, off_t len) {
   if (offset < 0 || len < 0)
     return EINVAL;
-#ifdef __wasilibc_unmodified_upstream
-  return __wasi_file_allocate(fd, offset, len);
-#else
   return __wasi_fd_allocate(fd, offset, len);
-#endif
 }
index e48e3c7463857d1880d22d4d41757edff7e4001e..6100ea561dc15260d18c89dbb781c920f48b78f1 100644 (file)
@@ -7,11 +7,7 @@
 #include <sched.h>
 
 int sched_yield(void) {
-#ifdef __wasilibc_unmodified_upstream
-  __wasi_errno_t error = __wasi_thread_yield();
-#else
   __wasi_errno_t error = __wasi_sched_yield();
-#endif
   if (error != 0) {
     errno = error;
     return -1;
index f5e4d96c8d013b1c421081aee92ec7a3ed477051..da9b5c510684017949ee6c3405796a4e80748256 100644 (file)
 #include <string.h>
 
 int renameat(int oldfd, const char *old, int newfd, const char *new) {
-#ifdef __wasilibc_unmodified_upstream
-  __wasi_errno_t error = __wasi_file_rename(oldfd, old, strlen(old),
-#else
   __wasi_errno_t error = __wasi_path_rename(oldfd, old, strlen(old),
-#endif
-                                                    newfd, new, strlen(new));
+                                            newfd, new, strlen(new));
   if (error != 0) {
     errno = errno_fixup_directory(oldfd, errno_fixup_directory(newfd, error));
     return -1;
index e464d8871f40156a98aa5e1b464d8871a6d97aee..7d03cc61ad5b817a341f36f492195312a6298e27 100644 (file)
@@ -24,11 +24,7 @@ int ioctl(int fildes, int request, ...) {
       };
       __wasi_event_t events[__arraycount(subscriptions)];
       size_t nevents;
-#ifdef __wasilibc_unmodified_upstream
-      __wasi_errno_t error = __wasi_poll(
-#else
       __wasi_errno_t error = __wasi_poll_oneoff(
-#endif
           subscriptions, events, __arraycount(subscriptions), &nevents);
       if (error != 0) {
         errno = error;
@@ -61,11 +57,7 @@ int ioctl(int fildes, int request, ...) {
     case FIONBIO: {
       // Obtain the current file descriptor flags.
       __wasi_fdstat_t fds;
-#ifdef __wasilibc_unmodified_upstream
-      __wasi_errno_t error = __wasi_fd_stat_get(fildes, &fds);
-#else
       __wasi_errno_t error = __wasi_fd_fdstat_get(fildes, &fds);
-#endif
       if (error != 0) {
         errno = error;
         return -1;
@@ -75,25 +67,13 @@ int ioctl(int fildes, int request, ...) {
       va_list ap;
       va_start(ap, request);
       if (*va_arg(ap, const int *) != 0)
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-        fds.fs_flags |= __WASI_FDFLAG_NONBLOCK;
-#else
         fds.fs_flags |= __WASI_FDFLAGS_NONBLOCK;
-#endif
       else
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-        fds.fs_flags &= ~__WASI_FDFLAG_NONBLOCK;
-#else
         fds.fs_flags &= ~__WASI_FDFLAGS_NONBLOCK;
-#endif
       va_end(ap);
 
       // Update the file descriptor flags.
-#ifdef __wasilibc_unmodified_upstream // fstat
-      error = __wasi_fd_stat_put(fildes, &fds, __WASI_FDSTAT_FLAGS);
-#else
       error = __wasi_fd_fdstat_set_flags(fildes, fds.fs_flags);
-#endif
       if (error != 0) {
         errno = error;
         return -1;
index be1a0788e094b59421946269a9ab269378e5332d..bd059c4b961cb3d8ae683c4fd0ddfcb40f243f11 100644 (file)
@@ -13,11 +13,7 @@ int getrusage(int who, struct rusage *r_usage) {
   switch (who) {
     case RUSAGE_SELF: {
       __wasi_timestamp_t usertime = 0;
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-      (void)__wasi_clock_time_get(__WASI_CLOCK_PROCESS_CPUTIME_ID, 1000,
-#else
       (void)__wasi_clock_time_get(__WASI_CLOCKID_PROCESS_CPUTIME_ID, 1000,
-#endif
                                   &usertime);
       *r_usage = (struct rusage){
           .ru_utime = timestamp_to_timeval(usertime),
index 5d4bc934aab038d977e2894b741b8e5873691afe..ebe5e8c656eb61e8d86c17d4315768646b3636a9 100644 (file)
@@ -17,17 +17,9 @@ int select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds,
     }
     struct timespec ts = {.tv_sec = timeout->tv_sec,
                           .tv_nsec = (long)timeout->tv_usec * 1000};
-#ifdef __wasilibc_unmodified_upstream
-    return pselect(nfds, readfds, writefds, errorfds, &ts);
-#else
     return pselect(nfds, readfds, writefds, errorfds, &ts, NULL);
-#endif
   } else {
     // No timeout specified.
-#ifdef __wasilibc_unmodified_upstream
-    return pselect(nfds, readfds, writefds, errorfds, NULL);
-#else
     return pselect(nfds, readfds, writefds, errorfds, NULL, NULL);
-#endif
   }
 }
index 61af183f4afff266deb942f4a85653a2b9c2e2c4..1fe41c4e30d2c117360c8ee35961fc201d22da46 100644 (file)
@@ -9,11 +9,7 @@
 #include <string.h>
 
 int getsockopt(int socket, int level, int option_name,
-#ifdef __wasilibc_unmodified_upstream
-               void *restrict option_value, size_t *restrict option_len) {
-#else
                void *restrict option_value, socklen_t *restrict option_len) {
-#endif
   // Only support SOL_SOCKET options for now.
   if (level != SOL_SOCKET) {
     errno = ENOPROTOOPT;
@@ -26,11 +22,7 @@ int getsockopt(int socket, int level, int option_name,
       // Return the type of the socket. This information can simply be
       // obtained by looking at the file descriptor type.
       __wasi_fdstat_t fsb;
-#ifdef __wasilibc_unmodified_upstream
-      if (__wasi_fd_stat_get(socket, &fsb) != 0) {
-#else
       if (__wasi_fd_fdstat_get(socket, &fsb) != 0) {
-#endif
         errno = EBADF;
         return -1;
       }
index 57e0370a41104e6e02ac09758b3b022e68e1ac0d..49c09d03768ed74ef7d5cc6751174d809e2aa4d7 100644 (file)
 #include <errno.h>
 #include <stdint.h>
 
-#ifdef __wasilibc_unmodified_upstream
-static_assert(MSG_PEEK == __WASI_SOCK_RECV_PEEK, "Value mismatch");
-static_assert(MSG_WAITALL == __WASI_SOCK_RECV_WAITALL, "Value mismatch");
-#else
 static_assert(MSG_PEEK == __WASI_RIFLAGS_RECV_PEEK, "Value mismatch");
 static_assert(MSG_WAITALL == __WASI_RIFLAGS_RECV_WAITALL, "Value mismatch");
-#endif
 
 ssize_t recv(int socket, void *restrict buffer, size_t length, int flags) {
   // Validate flags.
@@ -28,37 +23,20 @@ ssize_t recv(int socket, void *restrict buffer, size_t length, int flags) {
 
   // Prepare input parameters.
   __wasi_iovec_t iov = {.buf = buffer, .buf_len = length};
-#ifdef __wasilibc_unmodified_upstream // send/recv
-  __wasi_recv_in_t ri = {
-      .ri_data = &iov,
-      .ri_data_len = 1,
-      .ri_flags = flags,
-  };
-#else
   __wasi_iovec_t *ri_data = &iov;
   size_t ri_data_len = 1;
   __wasi_riflags_t ri_flags = flags;
-#endif
 
   // Perform system call.
-#ifdef __wasilibc_unmodified_upstream // send/recv
-  __wasi_recv_out_t ro;
-  __wasi_errno_t error = __wasi_sock_recv(socket, &ri, &ro);
-#else
   size_t ro_datalen;
   __wasi_roflags_t ro_flags;
   __wasi_errno_t error = __wasi_sock_recv(socket,
                                           ri_data, ri_data_len, ri_flags,
                                           &ro_datalen,
                                           &ro_flags);
-#endif
   if (error != 0) {
     errno = errno_fixup_socket(socket, error);
     return -1;
   }
-#ifdef __wasilibc_unmodified_upstream // send/recv
-  return ro.ro_datalen;
-#else
   return ro_datalen;
-#endif
 }
index 626110cc5456a113f73c8bb16df9a06ebb402184..0759abf9b2c80f780fc5303806cb98a7cfcb1b0d 100644 (file)
@@ -19,32 +19,16 @@ ssize_t send(int socket, const void *buffer, size_t length, int flags) {
 
   // Prepare input parameters.
   __wasi_ciovec_t iov = {.buf = buffer, .buf_len = length};
-#ifdef __wasilibc_unmodified_upstream // send/recv
-  __wasi_send_in_t si = {
-      .si_data = &iov,
-      .si_data_len = 1,
-  };
-#else
   __wasi_ciovec_t *si_data = &iov;
   size_t si_data_len = 1;
   __wasi_siflags_t si_flags = 0;
-#endif
 
   // Perform system call.
-#ifdef __wasilibc_unmodified_upstream // send/recv
-  __wasi_send_out_t so;
-  __wasi_errno_t error = __wasi_sock_send(socket, &si, &so);
-#else
   size_t so_datalen;
   __wasi_errno_t error = __wasi_sock_send(socket, si_data, si_data_len, si_flags, &so_datalen);
-#endif
   if (error != 0) {
     errno = errno_fixup_socket(socket, error);
     return -1;
   }
-#ifdef __wasilibc_unmodified_upstream // send/recv
-  return so.so_datalen;
-#else
   return so_datalen;
-#endif
 }
index 560f53c30a33b3d84bd37d8029de3601d3aed8bc..883b551ae832bf9f21ccf9794ce3ebe299cb38ac 100644 (file)
 #include <wasi/api.h>
 #include <errno.h>
 
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-static_assert(SHUT_RD == __WASI_SHUT_RD, "Value mismatch");
-static_assert(SHUT_WR == __WASI_SHUT_WR, "Value mismatch");
-#else
 static_assert(SHUT_RD == __WASI_SDFLAGS_RD, "Value mismatch");
 static_assert(SHUT_WR == __WASI_SDFLAGS_WR, "Value mismatch");
-#endif
 
 int shutdown(int socket, int how) {
   // Validate shutdown flags.
index ff590d13cb07f9beeecb97de8a8427c578910bf2..b8ffdb59c7083baa8609dc0803a551e97e082e91 100644 (file)
 
 int fstat(int fildes, struct stat *buf) {
   __wasi_filestat_t internal_stat;
-#ifdef __wasilibc_unmodified_upstream // fstat
-  __wasi_errno_t error = __wasi_file_stat_fget(fildes, &internal_stat);
-#else
   __wasi_errno_t error = __wasi_fd_filestat_get(fildes, &internal_stat);
-#endif
   if (error != 0) {
     errno = error;
     return -1;
index 375d59de47be22a4b629b7073d26381b1c73c101..6f31ddbec73a7e0a19d04c7db4216cc3062967bc 100644 (file)
 int fstatat(int fd, const char *restrict path, struct stat *restrict buf,
             int flag) {
   // Create lookup properties.
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-  __wasi_lookup_t lookup = {.fd = fd, .flags = 0};
-#else
   __wasi_lookupflags_t lookup_flags = 0;
-#endif
   if ((flag & AT_SYMLINK_NOFOLLOW) == 0)
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-    lookup.flags |= __WASI_LOOKUP_SYMLINK_FOLLOW;
-#else
     lookup_flags |= __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW;
-#endif
 
   // Perform system call.
   __wasi_filestat_t internal_stat;
   __wasi_errno_t error =
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-      __wasi_file_stat_get(lookup, path, strlen(path), &internal_stat);
-#else
       __wasi_path_filestat_get(fd, lookup_flags, path, strlen(path), &internal_stat);
-#endif
   if (error != 0) {
     errno = errno_fixup_directory(fd, error);
     return -1;
index 1ae43ddeb9393e9aee8d0ccc430688ee4c1e2269..13357fcf0a7183f115b9823d3ee312c79cc86e9b 100644 (file)
 
 int futimens(int fd, const struct timespec *times) {
   // Convert timestamps and extract NOW/OMIT flags.
-#ifdef __wasilibc_unmodified_upstream // fstat
-  __wasi_filestat_t fs;
-  __wasi_fsflags_t flags;
-  if (!utimens_get_timestamps(times, &fs, &flags)) {
-#else
   __wasi_timestamp_t st_atim;
   __wasi_timestamp_t st_mtim;
   __wasi_fstflags_t flags;
   if (!utimens_get_timestamps(times, &st_atim, &st_mtim, &flags)) {
-#endif
     errno = EINVAL;
     return -1;
   }
 
   // Perform system call.
-#ifdef __wasilibc_unmodified_upstream // fstat
-  __wasi_errno_t error = __wasi_file_stat_fput(fd, &fs, flags);
-#else
   __wasi_errno_t error = __wasi_fd_filestat_set_times(fd, st_atim, st_mtim, flags);
-#endif
   if (error != 0) {
     errno = error;
     return -1;
index 75f47a4a68299393510759a151e013a2eb74a917..df79f7683b270a5a9333fc4dad09cf7430d2fac0 100644 (file)
 #include <errno.h>
 #include <string.h>
 
-#ifdef __wasilibc_unmodified_upstream
-int mkdirat(int fd, const char *path, ...) {
-#else
 int mkdirat(int fd, const char *path, mode_t mode) {
-#endif
-#ifdef __wasilibc_unmodified_upstream // __wasi_path_create_directory
-  __wasi_errno_t error = __wasi_file_create(
-      fd, path, strlen(path), __WASI_FILETYPE_DIRECTORY);
-#else
   __wasi_errno_t error = __wasi_path_create_directory(
       fd, path, strlen(path));
-#endif
   if (error != 0) {
     errno = errno_fixup_directory(fd, error);
     return -1;
index d1a26fdadd82f8023b4a0e88c6e823cd86f005bf..c649d3b6d956cf1ea78d0a5f9a4777b37aa334bb 100644 (file)
@@ -24,43 +24,17 @@ static_assert(S_ISSOCK(S_IFSOCK), "Value mismatch");
 static inline void to_public_stat(const __wasi_filestat_t *in,
                                   struct stat *out) {
   // Ensure that we don't truncate any values.
-#ifdef __wasilibc_unmodified_upstream
-  static_assert(sizeof(in->st_dev) == sizeof(out->st_dev), "Size mismatch");
-  static_assert(sizeof(in->st_ino) == sizeof(out->st_ino), "Size mismatch");
-  static_assert(sizeof(in->st_filetype) == sizeof(out->__st_filetype),
-                "Size mismatch");
-#else
   static_assert(sizeof(in->dev) == sizeof(out->st_dev), "Size mismatch");
   static_assert(sizeof(in->ino) == sizeof(out->st_ino), "Size mismatch");
   /*
    * The non-standard __st_filetype field appears to only be used for shared
    * memory, which we don't currently support.
    */
-#endif
-#ifdef __wasilibc_unmodified_upstream
-  static_assert(sizeof(in->st_nlink) == sizeof(out->st_nlink), "Size mismatch");
-  static_assert(sizeof(in->st_size) == sizeof(out->st_size), "Size mismatch");
-#else
   /* nlink_t is 64-bit on wasm32, following the x32 ABI. */
   static_assert(sizeof(in->nlink) <= sizeof(out->st_nlink), "Size shortfall");
   static_assert(sizeof(in->size) == sizeof(out->st_size), "Size mismatch");
-#endif
 
   *out = (struct stat){
-#ifdef __wasilibc_unmodified_upstream
-#define COPY_FIELD(field) .field = in->field
-      COPY_FIELD(st_dev),
-      COPY_FIELD(st_ino),
-      .__st_filetype = in->st_filetype,
-      COPY_FIELD(st_nlink),
-      COPY_FIELD(st_size),
-#undef COPY_FIELD
-#define COPY_TIMESPEC(field) .field = timestamp_to_timespec(in->field)
-      COPY_TIMESPEC(st_atim),
-      COPY_TIMESPEC(st_mtim),
-      COPY_TIMESPEC(st_ctim),
-#undef COPY_TIMESPEC
-#else
       .st_dev = in->dev,
       .st_ino = in->ino,
       .st_nlink = in->nlink,
@@ -68,15 +42,10 @@ static inline void to_public_stat(const __wasi_filestat_t *in,
       .st_atim = timestamp_to_timespec(in->atim),
       .st_mtim = timestamp_to_timespec(in->mtim),
       .st_ctim = timestamp_to_timespec(in->ctim),
-#endif
   };
 
   // Convert file type to legacy types encoded in st_mode.
-#ifdef __wasilibc_unmodified_upstream
-  switch (in->st_filetype) {
-#else
   switch (in->filetype) {
-#endif
     case __WASI_FILETYPE_BLOCK_DEVICE:
       out->st_mode |= S_IFBLK;
       break;
@@ -100,64 +69,37 @@ static inline void to_public_stat(const __wasi_filestat_t *in,
 }
 
 static inline bool utimens_get_timestamps(const struct timespec *times,
-#ifdef __wasilibc_unmodified_upstream // fstat
-                                          __wasi_filestat_t *fs,
-                                          __wasi_fsflags_t *flags) {
-#else
                                           __wasi_timestamp_t *st_atim,
                                           __wasi_timestamp_t *st_mtim,
                                           __wasi_fstflags_t *flags) {
-#endif
   if (times == NULL) {
     // Update both timestamps.
-#ifdef __wasilibc_unmodified_upstream // fstat
-    *flags = __WASI_FILESTAT_ATIM_NOW | __WASI_FILESTAT_MTIM_NOW;
-#else
     *flags = __WASI_FSTFLAGS_ATIM_NOW | __WASI_FSTFLAGS_MTIM_NOW;
-#endif
   } else {
     // Set individual timestamps.
     *flags = 0;
     switch (times[0].tv_nsec) {
       case UTIME_NOW:
-#ifdef __wasilibc_unmodified_upstream // fstat
-        *flags |= __WASI_FILESTAT_ATIM_NOW;
-#else
         *flags |= __WASI_FSTFLAGS_ATIM_NOW;
-#endif
         break;
       case UTIME_OMIT:
         break;
       default:
-#ifdef __wasilibc_unmodified_upstream // fstat
-        *flags |= __WASI_FILESTAT_ATIM;
-        if (!timespec_to_timestamp_exact(&times[0], &fs->st_atim))
-#else
         *flags |= __WASI_FSTFLAGS_ATIM;
         if (!timespec_to_timestamp_exact(&times[0], st_atim))
-#endif
           return false;
         break;
     }
 
     switch (times[1].tv_nsec) {
       case UTIME_NOW:
-#ifdef __wasilibc_unmodified_upstream // fstat
-        *flags |= __WASI_FILESTAT_MTIM_NOW;
-#else
         *flags |= __WASI_FSTFLAGS_MTIM_NOW;
-#endif
         break;
       case UTIME_OMIT:
         break;
       default:
-#ifdef __wasilibc_unmodified_upstream // fstat
-        *flags |= __WASI_FILESTAT_MTIM;
-        if (!timespec_to_timestamp_exact(&times[1], &fs->st_mtim))
-#else
         *flags |= __WASI_FSTFLAGS_MTIM;
         if (!timespec_to_timestamp_exact(&times[1], st_mtim))
-#endif
           return false;
         break;
     }
index f27b67d6ef36fa1f2325fd33c8bc421de1bc8605..0a8e61be6a57991fb6d5ef7af5cffab69cfe0a8d 100644 (file)
 int utimensat(int fd, const char *path, const struct timespec times[2],
               int flag) {
   // Convert timestamps and extract NOW/OMIT flags.
-#ifdef __wasilibc_unmodified_upstream // fstat
-  __wasi_filestat_t fs;
-  __wasi_fsflags_t flags;
-  if (!utimens_get_timestamps(times, &fs, &flags)) {
-#else
   __wasi_timestamp_t st_atim;
   __wasi_timestamp_t st_mtim;
   __wasi_fstflags_t flags;
   if (!utimens_get_timestamps(times, &st_atim, &st_mtim, &flags)) {
-#endif
     errno = EINVAL;
     return -1;
   }
 
   // Create lookup properties.
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-  __wasi_lookup_t lookup = {.fd = fd, .flags = 0};
-#else
   __wasi_lookupflags_t lookup_flags = 0;
-#endif
   if ((flag & AT_SYMLINK_NOFOLLOW) == 0)
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-    lookup.flags |= __WASI_LOOKUP_SYMLINK_FOLLOW;
-#else
     lookup_flags |= __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW;
-#endif
 
   // Perform system call.
   __wasi_errno_t error =
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t, fstat
-      __wasi_file_stat_put(lookup, path, strlen(path), &fs, flags);
-#else
       __wasi_path_filestat_set_times(fd, lookup_flags, path, strlen(path), st_atim, st_mtim, flags);
-#endif
   if (error != 0) {
     errno = errno_fixup_directory(fd, error);
     return -1;
index 9d33386fb68499c5590d6e4f69d7057f5fe1e8ff..d58cbb9d217ccedd553b4228f91ca9a56e81146a 100644 (file)
@@ -8,17 +8,9 @@
 
 #include <wasi/api.h>
 
-#ifdef __wasilibc_unmodified_upstream
-int gettimeofday(struct timeval *restrict tp, ...) {
-#else
 int gettimeofday(struct timeval *restrict tp, void *tz) {
-#endif
   __wasi_timestamp_t ts = 0;
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-  (void)__wasi_clock_time_get(__WASI_CLOCK_REALTIME, 1000, &ts);
-#else
   (void)__wasi_clock_time_get(__WASI_CLOCKID_REALTIME, 1000, &ts);
-#endif
   *tp = timestamp_to_timeval(ts);
   return 0;
 }
index 19dc42a9bace4824630e7986872a44410253b78f..fdb1a38f379fbb60726f93a448f25497d567149b 100644 (file)
@@ -15,19 +15,11 @@ static_assert(CLOCKS_PER_SEC == NSEC_PER_SEC,
 clock_t times(struct tms *buffer) {
   // Obtain user time.
   __wasi_timestamp_t usertime = 0;
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-  (void)__wasi_clock_time_get(__WASI_CLOCK_PROCESS_CPUTIME_ID, 0, &usertime);
-#else
   (void)__wasi_clock_time_get(__WASI_CLOCKID_PROCESS_CPUTIME_ID, 0, &usertime);
-#endif
   *buffer = (struct tms){.tms_utime = usertime};
 
   // Obtain real time.
   __wasi_timestamp_t realtime = 0;
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-  (void)__wasi_clock_time_get(__WASI_CLOCK_MONOTONIC, 0, &realtime);
-#else
   (void)__wasi_clock_time_get(__WASI_CLOCKID_MONOTONIC, 0, &realtime);
-#endif
   return realtime;
 }
index bf87ea9f2eece2d2503c4c783503cac4dd73da7d..a4c4a62c685f7997282bab67337846f6324e4ce0 100644 (file)
@@ -8,9 +8,5 @@
 #include <time.h>
 
 const struct __clockid _CLOCK_MONOTONIC = {
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-    .id = __WASI_CLOCK_MONOTONIC,
-#else
     .id = __WASI_CLOCKID_MONOTONIC,
-#endif
 };
index ce872140365d816202aeeeab2f81e558586afa39..901fd7300b1eac285d2e9a1deb033f456b096a8d 100644 (file)
@@ -8,9 +8,5 @@
 #include <time.h>
 
 const struct __clockid _CLOCK_PROCESS_CPUTIME_ID = {
-#ifdef __wasilibc_unmodified_upstream
-    .id = __WASI_CLOCK_PROCESS_CPUTIME_ID,
-#else
     .id = __WASI_CLOCKID_PROCESS_CPUTIME_ID,
-#endif
 };
index 9bbcc6e8aa7678476acda5fdc8d5685b7f0122f1..952375444b9da8e59c37e4fc9c1c62cb13460cde 100644 (file)
@@ -8,9 +8,5 @@
 #include <time.h>
 
 const struct __clockid _CLOCK_REALTIME = {
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-    .id = __WASI_CLOCK_REALTIME,
-#else
     .id = __WASI_CLOCKID_REALTIME,
-#endif
 };
index 4cfd3ee54dc3fc255f6868bfe963c9499edb4200..de58c510bbab5e56cb336f9a1bdbc783fa7beed0 100644 (file)
@@ -8,9 +8,5 @@
 #include <time.h>
 
 const struct __clockid _CLOCK_THREAD_CPUTIME_ID = {
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-    .id = __WASI_CLOCK_THREAD_CPUTIME_ID,
-#else
     .id = __WASI_CLOCKID_THREAD_CPUTIME_ID,
-#endif
 };
index d0748f33c4f91546bbc4073f9cb3746702a07106..cc4b6db0cbc54abc038a766646fb17506cfc55f5 100644 (file)
@@ -13,10 +13,6 @@ static_assert(CLOCKS_PER_SEC == NSEC_PER_SEC,
 
 clock_t clock(void) {
   __wasi_timestamp_t ts = 0;
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-  (void)__wasi_clock_time_get(__WASI_CLOCK_PROCESS_CPUTIME_ID, 0, &ts);
-#else
   (void)__wasi_clock_time_get(__WASI_CLOCKID_PROCESS_CPUTIME_ID, 0, &ts);
-#endif
   return ts;
 }
index 412b61352cbe1111ea8f30d8f162a10150e54f20..dbb36a72da216fb63d4f1465874e5a358b3b299f 100644 (file)
@@ -9,11 +9,7 @@
 #include <errno.h>
 #include <time.h>
 
-#ifdef __wasilibc_unmodified_upstream
-int clock_gettime(clockid_t clock_id, struct timespec *tp) {
-#else
 int __clock_gettime(clockid_t clock_id, struct timespec *tp) {
-#endif
   __wasi_timestamp_t ts;
   __wasi_errno_t error = __wasi_clock_time_get(clock_id->id, 1, &ts);
   if (error != 0) {
@@ -23,7 +19,4 @@ int __clock_gettime(clockid_t clock_id, struct timespec *tp) {
   *tp = timestamp_to_timespec(ts);
   return 0;
 }
-#ifdef __wasilibc_unmodified_upstream
-#else
 extern __typeof(__clock_gettime) clock_gettime __attribute__((weak, alias("__clock_gettime")));
-#endif
index cd8ecfc613f1f115e32cd8c455045a527a189689..52b577a0ea3e1d412745aa466307362909b55d66 100644 (file)
 #include <errno.h>
 #include <time.h>
 
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-static_assert(TIMER_ABSTIME == __WASI_SUBSCRIPTION_CLOCK_ABSTIME,
-#else
 static_assert(TIMER_ABSTIME == __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME,
-#endif
               "Value mismatch");
 
-#ifdef __wasilibc_unmodified_upstream
-int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
-                    ...) {
-#else
 int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
                     struct timespec *rmtp) {
-#endif
   if ((flags & ~TIMER_ABSTIME) != 0)
     return EINVAL;
 
@@ -39,10 +30,6 @@ int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
   // Block until polling event is triggered.
   size_t nevents;
   __wasi_event_t ev;
-#ifdef __wasilibc_unmodified_upstream
-  __wasi_errno_t error = __wasi_poll(&sub, &ev, 1, &nevents);
-#else
   __wasi_errno_t error = __wasi_poll_oneoff(&sub, &ev, 1, &nevents);
-#endif
   return error == 0 && ev.error == 0 ? 0 : ENOTSUP;
 }
index 0cba5ac87bde5e924ce3e8d511b2c2f223a8b2c1..9ffa1be2811c60bdd19391849f4d8a31c79b31a9 100644 (file)
@@ -6,16 +6,8 @@
 #include <threads.h>
 #include <time.h>
 
-#ifdef __wasilibc_unmodified_upstream
-int nanosleep(const struct timespec *rqtp, ...) {
-#else
 int nanosleep(const struct timespec *rqtp, struct timespec *rem) {
-#endif
-#ifdef __wasilibc_unmodified_upstream
-  int error = clock_nanosleep(CLOCK_REALTIME, 0, rqtp);
-#else
   int error = clock_nanosleep(CLOCK_REALTIME, 0, rqtp, rem);
-#endif
   if (error != 0) {
     errno = error;
     return -1;
@@ -23,7 +15,6 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rem) {
   return 0;
 }
 
-#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
+#if defined(_REENTRANT)
 __strong_reference(nanosleep, thrd_sleep);
-#else
 #endif
index 2c0ba9aeb94d7ea34172e7144d4b541c41605e48..52bc0e4842695f88f2d56042e5ae471fb26d9ce9 100644 (file)
@@ -9,11 +9,7 @@
 
 time_t time(time_t *tloc) {
   __wasi_timestamp_t ts = 0;
-#ifdef __wasilibc_unmodified_upstream
-  (void)__wasi_clock_time_get(__WASI_CLOCK_REALTIME, NSEC_PER_SEC, &ts);
-#else
   (void)__wasi_clock_time_get(__WASI_CLOCKID_REALTIME, NSEC_PER_SEC, &ts);
-#endif
   if (tloc != NULL)
     *tloc = ts / NSEC_PER_SEC;
   return ts / NSEC_PER_SEC;
index 2c8ee84f7f3103ab1de9b1b4cec3d7f632fc477f..2ccecb8abecb664ae4a96dd33f695087f8bf60a9 100644 (file)
@@ -19,21 +19,10 @@ int faccessat(int fd, const char *path, int amode, int flag) {
   }
 
   // Check for target file existence and obtain the file type.
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-  __wasi_lookup_t lookup = {
-      .fd = fd,
-      .flags = __WASI_LOOKUP_SYMLINK_FOLLOW,
-  };
-#else
   __wasi_lookupflags_t lookup_flags = __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW;
-#endif
   __wasi_filestat_t file;
   __wasi_errno_t error =
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-      __wasi_file_stat_get(lookup, path, strlen(path), &file);
-#else
       __wasi_path_filestat_get(fd, lookup_flags, path, strlen(path), &file);
-#endif
   if (error != 0) {
     errno = errno_fixup_directory(fd, error);
     return -1;
@@ -43,11 +32,7 @@ int faccessat(int fd, const char *path, int amode, int flag) {
   // directory file descriptor.
   if (amode != 0) {
     __wasi_fdstat_t directory;
-#ifdef __wasilibc_unmodified_upstream
-    error = __wasi_fd_stat_get(fd, &directory);
-#else
     error = __wasi_fd_fdstat_get(fd, &directory);
-#endif
     if (error != 0) {
       errno = error;
       return -1;
@@ -55,25 +40,11 @@ int faccessat(int fd, const char *path, int amode, int flag) {
 
     __wasi_rights_t min = 0;
     if ((amode & R_OK) != 0)
-#ifdef __wasilibc_unmodified_upstream
-      min |= file.st_filetype == __WASI_FILETYPE_DIRECTORY
-                 ? __WASI_RIGHT_FILE_READDIR
-                 : __WASI_RIGHT_FD_READ;
-#else
       min |= file.filetype == __WASI_FILETYPE_DIRECTORY
                  ? __WASI_RIGHTS_FD_READDIR
                  : __WASI_RIGHTS_FD_READ;
-#endif
     if ((amode & W_OK) != 0)
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-      min |= __WASI_RIGHT_FD_WRITE;
-#else
       min |= __WASI_RIGHTS_FD_WRITE;
-#endif
-#ifdef __wasilibc_unmodified_upstream // RIGHT_PROC_EXEC
-    if ((amode & X_OK) != 0 && file.st_filetype != __WASI_FILETYPE_DIRECTORY)
-      min |= __WASI_RIGHT_PROC_EXEC;
-#endif
 
     if ((min & directory.fs_rights_inheriting) != min) {
       errno = EACCES;
index c00ccdd4fe418cbcee91b6dfcd6ab9eeb007087b..7792597e2f51621d67f4e15b60b6963622f89198 100644 (file)
@@ -11,19 +11,9 @@ int ftruncate(int fildes, off_t length) {
     errno = EINVAL;
     return -1;
   }
-#ifdef __wasilibc_unmodified_upstream // fstat
-  __wasi_filestat_t fs = {
-      .st_size = length,
-  };
-#else
   __wasi_filesize_t st_size = length;
-#endif
   __wasi_errno_t error =
-#ifdef __wasilibc_unmodified_upstream // fstat
-      __wasi_file_stat_fput(fildes, &fs, __WASI_FILESTAT_SIZE);
-#else
       __wasi_fd_filestat_set_size(fildes, st_size);
-#endif
   if (error != 0) {
     errno = error;
     return -1;
index f0ec72bd6a5c83bc2248752ee8d55641a7950e32..eaaf274e01a81eb71c68ff3f3c717e2206bf4c75 100644 (file)
 
 int linkat(int fd1, const char *path1, int fd2, const char *path2, int flag) {
   // Create lookup properties.
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-  __wasi_lookup_t lookup1 = {.fd = fd1, .flags = 0};
-#else
   __wasi_lookupflags_t lookup1_flags = 0;
-#endif
   if ((flag & AT_SYMLINK_FOLLOW) != 0)
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-    lookup1.flags |= __WASI_LOOKUP_SYMLINK_FOLLOW;
-#else
     lookup1_flags |= __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW;
-#endif
 
   // Perform system call.
-#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
-  __wasi_errno_t error = __wasi_file_link(lookup1, path1, strlen(path1),
-#else
   __wasi_errno_t error = __wasi_path_link(fd1, lookup1_flags, path1, strlen(path1),
-#endif
-                                                  fd2, path2, strlen(path2));
+                                          fd2, path2, strlen(path2));
   if (error != 0) {
     errno = errno_fixup_directory(fd1, errno_fixup_directory(fd2, error));
     return -1;
index cb5d995b3ce3394901c3c9e995dbc67553019b48..0dfc49e4c9cebc2c2aa76bc70a43c5d18a1dbf58 100644 (file)
@@ -11,11 +11,7 @@ static_assert(SEEK_CUR == __WASI_WHENCE_CUR, "Value mismatch");
 static_assert(SEEK_END == __WASI_WHENCE_END, "Value mismatch");
 static_assert(SEEK_SET == __WASI_WHENCE_SET, "Value mismatch");
 
-#ifdef __wasilibc_unmodified_upstream // Provide an __lseek entry point
-off_t lseek(int fildes, off_t offset, int whence) {
-#else
 off_t __lseek(int fildes, off_t offset, int whence) {
-#endif
   __wasi_filesize_t new_offset;
   __wasi_errno_t error =
       __wasi_fd_seek(fildes, offset, whence, &new_offset);
@@ -26,7 +22,4 @@ off_t __lseek(int fildes, off_t offset, int whence) {
   return new_offset;
 }
 
-#ifdef __wasilibc_unmodified_upstream // Provide an __lseek entry point
-#else
 extern __typeof(__lseek) lseek __attribute__((weak, alias("__lseek")));
-#endif
index 9520867a6d8e35e812e8d13790da0f155a55dd4b..c9944bc4e8ab797fb8f007f5e074fa0be10d5c93 100644 (file)
@@ -17,17 +17,9 @@ ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset) {
       __wasi_fd_pread(fildes, &iov, 1, offset, &bytes_read);
   if (error != 0) {
     __wasi_fdstat_t fds;
-#ifdef __wasilibc_unmodified_upstream
-    if (error == ENOTCAPABLE && __wasi_fd_stat_get(fildes, &fds) == 0) {
-#else
     if (error == ENOTCAPABLE && __wasi_fd_fdstat_get(fildes, &fds) == 0) {
-#endif
       // Determine why we got ENOTCAPABLE.
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-      if ((fds.fs_rights_base & __WASI_RIGHT_FD_READ) == 0)
-#else
       if ((fds.fs_rights_base & __WASI_RIGHTS_FD_READ) == 0)
-#endif
         error = EBADF;
       else
         error = ESPIPE;
index 56672e5b572d1d3823cbf52100d6ac9b9904c2a6..f80bc406b9a0ec311107a76c300a54b279b988c7 100644 (file)
@@ -17,17 +17,9 @@ ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset) {
       __wasi_fd_pwrite(fildes, &iov, 1, offset, &bytes_written);
   if (error != 0) {
     __wasi_fdstat_t fds;
-#ifdef __wasilibc_unmodified_upstream
-    if (error == ENOTCAPABLE && __wasi_fd_stat_get(fildes, &fds) == 0) {
-#else
     if (error == ENOTCAPABLE && __wasi_fd_fdstat_get(fildes, &fds) == 0) {
-#endif
       // Determine why we got ENOTCAPABLE.
-#ifdef __wasilibc_unmodified_upstream // generated constant names
-      if ((fds.fs_rights_base & __WASI_RIGHT_FD_WRITE) == 0)
-#else
       if ((fds.fs_rights_base & __WASI_RIGHTS_FD_WRITE) == 0)
-#endif
         error = EBADF;
       else
         error = ESPIPE;
index 1ebffc6001ae2b1408cf51d34bd423eedb551b00..82a9939f260ae6b71e341b2f7db0c9ed0d6a07b6 100644 (file)
 ssize_t readlinkat(int fd, const char *restrict path, char *restrict buf,
                    size_t bufsize) {
   size_t bufused;
-#ifdef __wasilibc_unmodified_upstream
-  __wasi_errno_t error = __wasi_file_readlink(fd, path, strlen(path),
-                                                      buf, bufsize, &bufused);
-#else
   // TODO: Remove the cast on `buf` once the witx is updated with char8 support.
   __wasi_errno_t error = __wasi_path_readlink(fd, path, strlen(path),
                                                       (uint8_t*)buf, bufsize, &bufused);
-#endif
   if (error != 0) {
     errno = errno_fixup_directory(fd, error);
     return -1;
index f6a1d899d157c9c02bfda86b2fbced63a73204a9..970287b62fb1babece575f166e0a7644ecb8b616 100644 (file)
@@ -7,11 +7,7 @@
 
 unsigned int sleep(unsigned int seconds) {
   struct timespec ts = {.tv_sec = seconds, .tv_nsec = 0};
-#ifdef __wasilibc_unmodified_upstream
-  if (clock_nanosleep(CLOCK_REALTIME, 0, &ts) != 0)
-#else
   if (clock_nanosleep(CLOCK_REALTIME, 0, &ts, NULL) != 0)
-#endif
     return seconds;
   return 0;
 }
index 9ad06b7aa6b8ee88c16fde34cfcd6a52e81cc1be..ec7cc949cb4bcf340bdd7d797ef1b3efbac10d32 100644 (file)
 
 int symlinkat(const char *path1, int fd, const char *path2) {
   __wasi_errno_t error =
-#ifdef __wasilibc_unmodified_upstream
-      __wasi_file_symlink(path1, strlen(path1), fd, path2, strlen(path2));
-#else
       __wasi_path_symlink(path1, strlen(path1), fd, path2, strlen(path2));
-#endif
   if (error != 0) {
     errno = errno_fixup_directory(fd, error);
     return -1;
index d970ad1b4bddafa1a2e3702efd89d48ae3af1601..ea795c2a2dfd358d0bc47017b8687e5b1e30b739 100644 (file)
@@ -5,31 +5,15 @@
 #include <common/errno.h>
 
 #include <wasi/api.h>
-#ifdef __wasilibc_unmodified_upstream // unlink
-#else
 #include <wasi/libc.h>
-#endif
 #include <errno.h>
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
 
 int unlinkat(int fd, const char *path, int flag) {
-#ifdef __wasilibc_unmodified_upstream // unlink
-  __wasi_ulflags_t ulflags = 0;
-  if ((flag & AT_REMOVEDIR) != 0)
-    ulflags |= __WASI_UNLINK_REMOVEDIR;
-  __wasi_errno_t error =
-      __wasi_file_unlink(fd, path, strlen(path), ulflags);
-  if (error != 0) {
-    errno = errno_fixup_directory(fd, error);
-    return -1;
-  }
-  return 0;
-#else
   if ((flag & AT_REMOVEDIR) != 0) {
     return __wasilibc_rmdirat(fd, path);
   }
   return __wasilibc_unlinkat(fd, path);
-#endif
 }
index 51ee5cba5dab30ae635413c0c401426127cc1356..8005f172594ceafdfa1fa49ec82228f5797f2b5a 100644 (file)
@@ -9,11 +9,7 @@
 int usleep(useconds_t useconds) {
   struct timespec ts = {.tv_sec = useconds / 1000000,
                         .tv_nsec = useconds % 1000000 * 1000};
-#ifdef __wasilibc_unmodified_upstream
-  int error = clock_nanosleep(CLOCK_REALTIME, 0, &ts);
-#else
   int error = clock_nanosleep(CLOCK_REALTIME, 0, &ts, NULL);
-#endif
   if (error != 0) {
     errno = error;
     return -1;