]> git.proxmox.com Git - wasi-libc.git/commitdiff
Delete several blocks of unused code. (#294)
authorDan Gohman <dev@sunfishcode.online>
Wed, 20 Jul 2022 22:46:06 +0000 (15:46 -0700)
committerGitHub <noreply@github.com>
Wed, 20 Jul 2022 22:46:06 +0000 (15:46 -0700)
* Delete several blocks of unused code.

Delete several pieces of code from libc-bottom-half/cloudlibc that aren't in
use on wasi-libc.

* Delete more of `_CLOCK_PROCESS_CPUTIME_ID` or `_CLOCK_THREAD_CPUTIME_ID`.

28 files changed:
expected/wasm32-wasi/defined-symbols.txt
expected/wasm32-wasi/predefined-macros.txt
libc-bottom-half/cloudlibc/src/common/errno.h [deleted file]
libc-bottom-half/cloudlibc/src/common/overflow.h [deleted file]
libc-bottom-half/cloudlibc/src/common/time.h
libc-bottom-half/cloudlibc/src/include/_/cdefs.h
libc-bottom-half/cloudlibc/src/include/stdlib.h [deleted file]
libc-bottom-half/cloudlibc/src/libc/dirent/fdopendir.c
libc-bottom-half/cloudlibc/src/libc/fcntl/openat.c
libc-bottom-half/cloudlibc/src/libc/stdio/renameat.c
libc-bottom-half/cloudlibc/src/libc/stdlib/_Exit.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/fstatat.c
libc-bottom-half/cloudlibc/src/libc/sys/stat/mkdirat.c
libc-bottom-half/cloudlibc/src/libc/sys/stat/utimensat.c
libc-bottom-half/cloudlibc/src/libc/time/CLOCK_PROCESS_CPUTIME_ID.c [deleted file]
libc-bottom-half/cloudlibc/src/libc/time/CLOCK_THREAD_CPUTIME_ID.c [deleted file]
libc-bottom-half/cloudlibc/src/libc/time/nanosleep.c
libc-bottom-half/cloudlibc/src/libc/unistd/faccessat.c
libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c
libc-bottom-half/cloudlibc/src/libc/unistd/readlinkat.c
libc-bottom-half/cloudlibc/src/libc/unistd/symlinkat.c
libc-bottom-half/cloudlibc/src/libc/unistd/unlinkat.c
libc-bottom-half/headers/public/__header_time.h
libc-bottom-half/sources/__wasilibc_rmdirat.c
libc-bottom-half/sources/__wasilibc_unlinkat.c

index 40023d96d0771be1a619fac727aea77ec738c65b..a55f9a9043c8596bc026fd3f4c98d57442a1d573 100644 (file)
@@ -1,7 +1,5 @@
 _CLOCK_MONOTONIC
-_CLOCK_PROCESS_CPUTIME_ID
 _CLOCK_REALTIME
-_CLOCK_THREAD_CPUTIME_ID
 _Exit
 _IO_feof_unlocked
 _IO_ferror_unlocked
index 0cfff9b8cd943426411617e50c483d0a939674cd..1f7b341c765750f73162a6b32e8a395a94ba07b4 100644 (file)
@@ -97,9 +97,7 @@
 #define CLNEXT CTRL('v')
 #define CLOCKS_PER_SEC ((clock_t)1000000000)
 #define CLOCK_MONOTONIC (&_CLOCK_MONOTONIC)
-#define CLOCK_PROCESS_CPUTIME_ID (&_CLOCK_PROCESS_CPUTIME_ID)
 #define CLOCK_REALTIME (&_CLOCK_REALTIME)
-#define CLOCK_THREAD_CPUTIME_ID (&_CLOCK_THREAD_CPUTIME_ID)
 #define CMIN 1
 #define CMPLX(x,y) __CMPLX(x, y, double)
 #define CMPLXF(x,y) __CMPLX(x, y, float)
diff --git a/libc-bottom-half/cloudlibc/src/common/errno.h b/libc-bottom-half/cloudlibc/src/common/errno.h
deleted file mode 100644 (file)
index 7d178fb..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
-//
-// SPDX-License-Identifier: BSD-2-Clause
-
-#ifndef COMMON_ERRNO_H
-#define COMMON_ERRNO_H
-
-#include <wasi/api.h>
-
-// 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;
-}
-
-// 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
diff --git a/libc-bottom-half/cloudlibc/src/common/overflow.h b/libc-bottom-half/cloudlibc/src/common/overflow.h
deleted file mode 100644 (file)
index b7b28f2..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
-//
-// SPDX-License-Identifier: BSD-2-Clause
-
-#ifndef COMMON_OVERFLOW_H
-#define COMMON_OVERFLOW_H
-
-// Performs an addition, subtraction or multiplication operation,
-// returning whether the computation caused an overflow. These
-// intrinsics are available as of Clang 3.8 and GCC 5.
-#define add_overflow(x, y, out) __builtin_add_overflow(x, y, out)
-#define sub_overflow(x, y, out) __builtin_sub_overflow(x, y, out)
-#define mul_overflow(x, y, out) __builtin_mul_overflow(x, y, out)
-
-#endif
index 293678d823c237eda5164f8f73399e2b1d157748..08e28526904f83276fe8c0090d70d260d7803b64 100644 (file)
@@ -6,7 +6,6 @@
 #define COMMON_TIME_H
 
 #include <common/limits.h>
-#include <common/overflow.h>
 
 #include <sys/time.h>
 
 
 #define NSEC_PER_SEC 1000000000
 
-// Timezone agnostic conversion routines.
-int __localtime_utc(time_t, struct tm *);
-void __mktime_utc(const struct tm *, struct timespec *);
-
-static inline bool is_leap(time_t year) {
-  year %= 400;
-  if (year < 0)
-    year += 400;
-  return ((year % 4) == 0 && (year % 100) != 0) || year == 100;
-}
-
-// Gets the length of the months in a year.
-static inline const char *get_months(time_t year) {
-  static const char leap[12] = {
-      31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
-  };
-  static const char common[12] = {
-      31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
-  };
-  return is_leap(year) ? leap : common;
-}
-
-// Gets the cumulative length of the months in a year.
-static inline const short *get_months_cumulative(time_t year) {
-  static const short leap[13] = {
-      0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366,
-  };
-  static const short common[13] = {
-      0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365,
-  };
-  return is_leap(year) ? leap : common;
-}
-
-static inline short get_ydays(time_t year) {
-  return is_leap(year) ? 366 : 365;
-}
-
 static inline bool timespec_to_timestamp_exact(
     const struct timespec *timespec, __wasi_timestamp_t *timestamp) {
   // Invalid nanoseconds field.
@@ -64,8 +26,8 @@ static inline bool timespec_to_timestamp_exact(
     return false;
 
   // Make sure our timestamp does not overflow.
-  return !mul_overflow(timespec->tv_sec, NSEC_PER_SEC, timestamp) &&
-         !add_overflow(*timestamp, timespec->tv_nsec, timestamp);
+  return !__builtin_mul_overflow(timespec->tv_sec, NSEC_PER_SEC, timestamp) &&
+         !__builtin_add_overflow(*timestamp, timespec->tv_nsec, timestamp);
 }
 
 static inline bool timespec_to_timestamp_clamp(
@@ -77,8 +39,8 @@ static inline bool timespec_to_timestamp_clamp(
   if (timespec->tv_sec < 0) {
     // Timestamps before the Epoch are not supported.
     *timestamp = 0;
-  } else if (mul_overflow(timespec->tv_sec, NSEC_PER_SEC, timestamp) ||
-             add_overflow(*timestamp, timespec->tv_nsec, timestamp)) {
+  } else if (__builtin_mul_overflow(timespec->tv_sec, NSEC_PER_SEC, timestamp) ||
+             __builtin_add_overflow(*timestamp, timespec->tv_nsec, timestamp)) {
     // Make sure our timestamp does not overflow.
     *timestamp = NUMERIC_MAX(__wasi_timestamp_t);
   }
index 246adec41447886c9b42a0becaa186fd344a6759..d9a6f547b06ca555cb7b93627001a6f479f3f927 100644 (file)
 #ifndef ___CDEFS_H_
 #define ___CDEFS_H_
 
-// Version information.
-#define __cloudlibc__ 1
-#define __cloudlibc_major__ 0
-#define __cloudlibc_minor__ 102
-
-#ifdef __cplusplus
-#define __BEGIN_DECLS extern "C" {
-#define __END_DECLS }
-#else
-#define __BEGIN_DECLS
-#define __END_DECLS
-#endif
-
-// Whether we should provide inline versions of functions. Due to C++'s
-// support for namespaces, it is generally a bad idea to declare
-// function macros.
-#ifdef __cplusplus
-#define _CLOUDLIBC_INLINE_FUNCTIONS 0
-#else
-#define _CLOUDLIBC_INLINE_FUNCTIONS 1
-#endif
-
 // Compiler-independent annotations.
 
-#ifndef __has_builtin
-#define __has_builtin(x) 0
-#endif
-#ifndef __has_extension
-#define __has_extension(x) __has_feature(x)
-#endif
-#ifndef __has_feature
-#define __has_feature(x) 0
-#endif
-
-#define __offsetof(type, member) __builtin_offsetof(type, member)
-#define __containerof(ptr, type, member) \
-  ((type *)((char *)(ptr)-__offsetof(type, member)))
-
-#define __extname(x) __asm__(x)
-#define __malloc_like __attribute__((__malloc__))
-#define __pure2 __attribute__((__const__))
-#define __pure __attribute__((__pure__))
-#define __section(x) __attribute__((__section__(x)))
-#define __unused __attribute__((__unused__))
-#define __used __attribute__((__used__))
-#define __weak_symbol __attribute__((__weak__))
-
-// Format string argument type checking.
-#define __printflike(format, va) \
-  __attribute__((__format__(__printf__, format, va)))
-#define __scanflike(format, va) \
-  __attribute__((__format__(__scanf__, format, va)))
-// TODO(ed): Enable this once supported by LLVM:
-// https://llvm.org/bugs/show_bug.cgi?id=16810
-#define __wprintflike(format, va)
-#define __wscanflike(format, va)
-
 #define __strong_reference(oldsym, newsym) \
   extern __typeof__(oldsym) newsym __attribute__((__alias__(#oldsym)))
 
 // Convenience macros.
 
 #define __arraycount(x) (sizeof(x) / sizeof((x)[0]))
-#define __howmany(x, y) (((x) + (y)-1) / (y))
-#define __rounddown(x, y) (((x) / (y)) * (y))
-#define __roundup(x, y) ((((x) + (y)-1) / (y)) * (y))
-
-// Lock annotations.
-
-#if __has_extension(c_thread_safety_attributes)
-#define __lock_annotate(x) __attribute__((x))
-#else
-#define __lock_annotate(x)
-#endif
-
-#define __lockable __lock_annotate(lockable)
-
-#define __locks_exclusive(...) \
-  __lock_annotate(exclusive_lock_function(__VA_ARGS__))
-#define __locks_shared(...) __lock_annotate(shared_lock_function(__VA_ARGS__))
-
-#define __trylocks_exclusive(...) \
-  __lock_annotate(exclusive_trylock_function(__VA_ARGS__))
-#define __trylocks_shared(...) \
-  __lock_annotate(shared_trylock_function(__VA_ARGS__))
-
-#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__))
-
-#define __asserts_exclusive(...) \
-  __lock_annotate(assert_exclusive_lock(__VA_ARGS__))
-#define __asserts_shared(...) __lock_annotate(assert_shared_lock(__VA_ARGS__))
-
-#define __requires_exclusive(...) \
-  __lock_annotate(exclusive_locks_required(__VA_ARGS__))
-#define __requires_shared(...) \
-  __lock_annotate(shared_locks_required(__VA_ARGS__))
-#define __requires_unlocked(...) __lock_annotate(locks_excluded(__VA_ARGS__))
-
-#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)
-
-#define __guarded_by(x) __lock_annotate(guarded_by(x))
-#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x))
-
-// Const preservation.
-//
-// Functions like strchr() allow you to silently discard a const
-// qualifier from a string. This macro can be used to wrap such
-// functions to propagate the const keyword where possible.
-//
-// This macro has many limitations, such as only being able to detect
-// constness for void, char and wchar_t. For Clang, it also doesn't seem
-// to work on string literals.
-
-#define __preserve_const(type, name, arg, ...) \
-  _Generic(arg,                                                    \
-           const void *: (const type *)name(__VA_ARGS__),          \
-           const char *: (const type *)name(__VA_ARGS__),          \
-           const signed char *: (const type *)name(__VA_ARGS__),   \
-           const unsigned char *: (const type *)name(__VA_ARGS__), \
-           const __wchar_t *: (const type *)name(__VA_ARGS__),     \
-           default: name(__VA_ARGS__))
 
 #endif
diff --git a/libc-bottom-half/cloudlibc/src/include/stdlib.h b/libc-bottom-half/cloudlibc/src/include/stdlib.h
deleted file mode 100644 (file)
index ff48afb..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-// Copyright (c) 2015-2017 Nuxi, https://nuxi.nl/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-// 1. Redistributions of source code must retain the above copyright
-//    notice, this list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright
-//    notice, this list of conditions and the following disclaimer in the
-//    documentation and/or other materials provided with the distribution.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-// SUCH DAMAGE.
-
-// <stdlib.h> - standard library definitions
-//
-// Extensions:
-// - MB_CUR_MAX_L(), mblen_l(), mbstowcs_l(), mbtowc_l(), wcstombs_l()
-//   and wctomb_l():
-//   Regular functions always use the C locale. Available on many other
-//   operating systems.
-// - alloca():
-//   Present on most other operating systems.
-// - arc4random(), arc4random_buf() and arc4random_uniform():
-//   Secure random number generator. Available on many other operating
-//   systems.
-// - l64a_r():
-//   Thread-safe replacement for l64a(). Part of the SVID, 4th edition.
-// - qsort_r():
-//   Available on many other operating systems, although the prototype
-//   is not consistent. This implementation is compatible with glibc.
-//   It is expected that this version will be standardized in the future.
-// - reallocarray():
-//   Allows for reallocation of buffers without integer overflows.
-//
-// Features missing:
-// - initstate(), lcong48(), seed48(), setstate(), srand(), srand48()
-//   and srandom():
-//   Randomizer is seeded securely by default. There is no need to seed
-//   manually.
-// - WEXITSTATUS(), WIFEXITED(), WIFSIGNALED(), WIFSTOPPED(), WNOHANG,
-//   WSTOPSIG(), WTERMSIG(), WUNTRACED:
-//   Only useful if system() would actually work.
-// - l64a():
-//   Not thread-safe. Use l64a_r() instead.
-// - putenv(), setenv() and unsetenv():
-//   Environment variables are not available.
-// - grantpt(), posix_openpt(), ptsname() and unlockpt():
-//   Pseudo-terminals are not available.
-// - mkdtemp(), mkstemp() and realpath():
-//   Requires global filesystem namespace.
-// - setkey():
-//   Password database and encryption schemes not available.
-// - system():
-//   Requires a command shell.
-
-#ifndef _STDLIB_H_
-#define _STDLIB_H_
-
-#include <_/limits.h>
-#include <_/types.h>
-
-__BEGIN_DECLS
-_Noreturn void _Exit(int);
-_Noreturn void abort(void);
-void *calloc(size_t, size_t);
-_Noreturn void exit(int);
-void free(void *);
-void *malloc(size_t);
-void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
-void *realloc(void *, size_t);
-__END_DECLS
-
-#if _CLOUDLIBC_INLINE_FUNCTIONS
-
-// qsort_r() implementation from Bentley and McIlroy's
-// "Engineering a Sort Function".
-//
-// This sorting function is inlined into this header, so that the
-// compiler can create an optimized version that takes the alignment and
-// size of the elements into account. It also reduces the overhead of
-// indirect function calls.
-
-static __inline void __qsort_r(void *, size_t, size_t,
-                               int (*)(const void *, const void *, void *),
-                               void *);
-
-static __inline size_t __qsort_min(size_t __a, size_t __b) {
-  return __a < __b ? __a : __b;
-}
-
-// Swaps the contents of two buffers.
-static __inline void __qsort_swap(char *__a, char *__b, size_t __n) {
-  char __t;
-
-  while (__n-- > 0) {
-    __t = *__a;
-    *__a++ = *__b;
-    *__b++ = __t;
-  }
-}
-
-// Implementation of insertionsort for small lists.
-static __inline void __qsort_insertionsort(
-    char *__a, size_t __nel, size_t __width,
-    int (*__cmp)(const void *, const void *, void *), void *__thunk) {
-  char *__pm, *__pl;
-
-  for (__pm = __a + __width; __pm < __a + __nel * __width; __pm += __width)
-    for (__pl = __pm; __pl > __a && __cmp(__pl - __width, __pl, __thunk) > 0;
-         __pl -= __width)
-      __qsort_swap(__pl, __pl - __width, __width);
-}
-
-// Returns the median of three elements.
-static __inline char *__qsort_med3(char *__a, char *__b, char *__c,
-                                   int (*__cmp)(const void *, const void *,
-                                                void *),
-                                   void *__thunk) {
-  return __cmp(__a, __b, __thunk) < 0
-             ? (__cmp(__b, __c, __thunk) < 0
-                    ? __b
-                    : __cmp(__a, __c, __thunk) < 0 ? __c : __a)
-             : (__cmp(__b, __c, __thunk) > 0
-                    ? __b
-                    : __cmp(__a, __c, __thunk) > 0 ? __c : __a);
-}
-
-// Picks a pivot based on a pseudo-median of three or nine.
-// TODO(ed): Does this still guarantee an O(n log n) running time?
-static __inline char *__qsort_pickpivot(char *__a, size_t __nel, size_t __width,
-                                        int (*__cmp)(const void *, const void *,
-                                                     void *),
-                                        void *__thunk) {
-  char *__pl, *__pm, *__pn;
-  size_t __s;
-
-  __pl = __a;
-  __pm = __a + (__nel / 2) * __width;
-  __pn = __a + (__nel - 1) * __width;
-  if (__nel > 40) {
-    __s = (__nel / 8) * __width;
-    __pl = __qsort_med3(__pl, __pl + __s, __pl + 2 * __s, __cmp, __thunk);
-    __pm = __qsort_med3(__pm - __s, __pm, __pm + __s, __cmp, __thunk);
-    __pn = __qsort_med3(__pn - 2 * __s, __pn - __s, __pn, __cmp, __thunk);
-  }
-  return __qsort_med3(__pl, __pm, __pn, __cmp, __thunk);
-}
-
-// Implementation of quicksort for larger lists.
-static __inline void __qsort_quicksort(char *__a, size_t __nel, size_t __width,
-                                       int (*__cmp)(const void *, const void *,
-                                                    void *),
-                                       void *__thunk) {
-  char *__pa, *__pb, *__pc, *__pd, *__pn;
-  int __r;
-  size_t __s;
-
-  // Select pivot and move it to the head of the list.
-  __qsort_swap(__a, __qsort_pickpivot(__a, __nel, __width, __cmp, __thunk),
-               __width);
-
-  // Perform partitioning.
-  __pa = __pb = __a;
-  __pc = __pd = __a + (__nel - 1) * __width;
-  for (;;) {
-    while (__pb <= __pc && (__r = __cmp(__pb, __a, __thunk)) <= 0) {
-      if (__r == 0) {
-        __qsort_swap(__pa, __pb, __width);
-        __pa += __width;
-      }
-      __pb += __width;
-    }
-    while (__pc >= __pb && (__r = __cmp(__pc, __a, __thunk)) >= 0) {
-      if (__r == 0) {
-        __qsort_swap(__pc, __pd, __width);
-        __pd -= __width;
-      }
-      __pc -= __width;
-    }
-    if (__pb > __pc)
-      break;
-    __qsort_swap(__pb, __pc, __width);
-    __pb += __width;
-    __pc -= __width;
-  }
-
-  // Store pivot between the two partitions.
-  __pn = __a + __nel * __width;
-  __s = __qsort_min((size_t)(__pa - __a), (size_t)(__pb - __pa));
-  __qsort_swap(__a, __pb - __s, __s);
-  __s = __qsort_min((size_t)(__pd - __pc), (size_t)(__pn - __pd) - __width);
-  __qsort_swap(__pb, __pn - __s, __s);
-
-  // Sort the two partitions.
-  __s = (size_t)(__pb - __pa);
-  __qsort_r(__a, __s / __width, __width, __cmp, __thunk);
-  __s = (size_t)(__pd - __pc);
-  __qsort_r(__pn - __s, __s / __width, __width, __cmp, __thunk);
-}
-
-static __inline void __qsort_r(void *__base, size_t __nel, size_t __width,
-                               int (*__cmp)(const void *, const void *, void *),
-                               void *__thunk) {
-  char *__a;
-
-  __a = (char *)__base;
-  if (__nel < 8) {
-    __qsort_insertionsort(__a, __nel, __width, __cmp, __thunk);
-  } else {
-    __qsort_quicksort(__a, __nel, __width, __cmp, __thunk);
-  }
-}
-#define qsort_r(base, nel, width, compar, thunk) \
-  __qsort_r(base, nel, width, compar, thunk)
-
-// qsort(): Call into qsort_r(), providing the callback as the thunk.
-// We assume that the optimizer is smart enough to simplify.
-
-static __inline int __qsort_cmp(const void *__a, const void *__b,
-                                void *__thunk) {
-  return ((int (*)(const void *, const void *))__thunk)(__a, __b);
-}
-
-static __inline void __qsort(void *__base, size_t __nel, size_t __width,
-                             int (*__cmp)(const void *, const void *)) {
-  qsort_r(__base, __nel, __width, __qsort_cmp, (void *)__cmp);
-}
-#define qsort(base, nel, width, compar) __qsort(base, nel, width, compar)
-#endif
-
-#endif
index 59fc027e8d8ad309b5509cd9f9d8a248f0d0f55d..c7fd4565865c6dc521993a834799e36d3c1089aa 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <wasi/api.h>
 #include <dirent.h>
 #include <errno.h>
@@ -31,7 +29,6 @@ DIR *fdopendir(int fd) {
   if (error != 0) {
     free(dirp->buffer);
     free(dirp);
-    errno = errno_fixup_directory(fd, error);
     return NULL;
   }
 
index 46919fe8149120077655762be9624ca9a7905928..51e10b5f80eb0861c34965c430f09649983c2073 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <assert.h>
 #include <wasi/api.h>
 #include <wasi/libc.h>
@@ -75,7 +73,6 @@ int __wasilibc_nocwd_openat_nomode(int fd, const char *path, int oflag) {
                                  fs_rights_base, fs_rights_inheriting, fs_flags,
                                  &newfd);
   if (error != 0) {
-    errno = errno_fixup_directory(fd, error);
     return -1;
   }
   return newfd;
index e43cef22c279d518df9858f1d7dd698ef282cdad..86c6a5cbe3fc5b8298b763813ea63ec331b7055f 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <wasi/api.h>
 #include <errno.h>
 #include <stdio.h>
@@ -12,7 +10,6 @@
 int __wasilibc_nocwd_renameat(int oldfd, const char *old, int newfd, const char *new) {
   __wasi_errno_t error = __wasi_path_rename(oldfd, old, newfd, new);
   if (error != 0) {
-    errno = errno_fixup_directory(oldfd, errno_fixup_directory(newfd, error));
     return -1;
   }
   return 0;
index 10dab2b61e44c3b041af6c8d763ec72ce323153e..5e266f0b985da4ceb7866b2170f2278dc090a1e4 100644 (file)
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: BSD-2-Clause
 
 #include <wasi/api.h>
-#include <stdlib.h>
+#include <_/cdefs.h>
 #include <stdnoreturn.h>
 #include <unistd.h>
 
index 49c09d03768ed74ef7d5cc6751174d809e2aa4d7..cf6199e8c860be49ff9f1b75c7231bacfc82c27c 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <sys/socket.h>
 
 #include <assert.h>
@@ -35,7 +33,6 @@ ssize_t recv(int socket, void *restrict buffer, size_t length, int flags) {
                                           &ro_datalen,
                                           &ro_flags);
   if (error != 0) {
-    errno = errno_fixup_socket(socket, error);
     return -1;
   }
   return ro_datalen;
index 0759abf9b2c80f780fc5303806cb98a7cfcb1b0d..238270190ce0ca7b61a850619bd3b476537f1bb7 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <sys/socket.h>
 
 #include <assert.h>
@@ -27,7 +25,6 @@ ssize_t send(int socket, const void *buffer, size_t length, int flags) {
   size_t so_datalen;
   __wasi_errno_t error = __wasi_sock_send(socket, si_data, si_data_len, si_flags, &so_datalen);
   if (error != 0) {
-    errno = errno_fixup_socket(socket, error);
     return -1;
   }
   return so_datalen;
index 883b551ae832bf9f21ccf9794ce3ebe299cb38ac..85ede06d1b72d206f15e8d4ee01016b090ec2299 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <sys/socket.h>
 
 #include <assert.h>
@@ -22,7 +20,6 @@ int shutdown(int socket, int how) {
 
   __wasi_errno_t error = __wasi_sock_shutdown(socket, how);
   if (error != 0) {
-    errno = errno_fixup_socket(socket, error);
     return -1;
   }
   return error;
index f037d99dbe794f49b4f10c2ec5a9570fb97fce4c..ab48f32a747a3540309b62456f1f2d439a878184 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <sys/stat.h>
 
 #include <wasi/api.h>
@@ -25,7 +23,6 @@ int __wasilibc_nocwd_fstatat(int fd, const char *restrict path, struct stat *res
   __wasi_errno_t error =
       __wasi_path_filestat_get(fd, lookup_flags, path, &internal_stat);
   if (error != 0) {
-    errno = errno_fixup_directory(fd, error);
     return -1;
   }
   to_public_stat(&internal_stat, buf);
index c89ce3db52ed96c9d1aa277a8485956da7dbdfea..302650f2e9f04eb426190154939b51113c487261 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <sys/stat.h>
 
 #include <wasi/api.h>
@@ -13,7 +11,6 @@
 int __wasilibc_nocwd_mkdirat_nomode(int fd, const char *path) {
   __wasi_errno_t error = __wasi_path_create_directory(fd, path);
   if (error != 0) {
-    errno = errno_fixup_directory(fd, error);
     return -1;
   }
   return 0;
index a5727162011eb7e9a66655cba4d8860489b27a47..d274ef5ce2f40a3ceb6f068ef891d771283eed99 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <sys/stat.h>
 
 #include <wasi/api.h>
@@ -20,7 +18,6 @@ int __wasilibc_nocwd_utimensat(int fd, const char *path, const struct timespec t
   __wasi_timestamp_t st_mtim;
   __wasi_fstflags_t flags;
   if (!utimens_get_timestamps(times, &st_atim, &st_mtim, &flags)) {
-    errno = EINVAL;
     return -1;
   }
 
@@ -33,7 +30,6 @@ int __wasilibc_nocwd_utimensat(int fd, const char *path, const struct timespec t
   __wasi_errno_t error =
       __wasi_path_filestat_set_times(fd, lookup_flags, path, st_atim, st_mtim, flags);
   if (error != 0) {
-    errno = errno_fixup_directory(fd, error);
     return -1;
   }
   return 0;
diff --git a/libc-bottom-half/cloudlibc/src/libc/time/CLOCK_PROCESS_CPUTIME_ID.c b/libc-bottom-half/cloudlibc/src/libc/time/CLOCK_PROCESS_CPUTIME_ID.c
deleted file mode 100644 (file)
index 901fd73..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright (c) 2016 Nuxi, https://nuxi.nl/
-//
-// SPDX-License-Identifier: BSD-2-Clause
-
-#include <common/clock.h>
-
-#include <wasi/api.h>
-#include <time.h>
-
-const struct __clockid _CLOCK_PROCESS_CPUTIME_ID = {
-    .id = __WASI_CLOCKID_PROCESS_CPUTIME_ID,
-};
diff --git a/libc-bottom-half/cloudlibc/src/libc/time/CLOCK_THREAD_CPUTIME_ID.c b/libc-bottom-half/cloudlibc/src/libc/time/CLOCK_THREAD_CPUTIME_ID.c
deleted file mode 100644 (file)
index de58c51..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright (c) 2016 Nuxi, https://nuxi.nl/
-//
-// SPDX-License-Identifier: BSD-2-Clause
-
-#include <common/clock.h>
-
-#include <wasi/api.h>
-#include <time.h>
-
-const struct __clockid _CLOCK_THREAD_CPUTIME_ID = {
-    .id = __WASI_CLOCKID_THREAD_CPUTIME_ID,
-};
index 9ffa1be2811c60bdd19391849f4d8a31c79b31a9..66cbbdfacec9830c71feb053372278701ba8be75 100644 (file)
@@ -5,6 +5,7 @@
 #include <errno.h>
 #include <threads.h>
 #include <time.h>
+#include <_/cdefs.h>
 
 int nanosleep(const struct timespec *rqtp, struct timespec *rem) {
   int error = clock_nanosleep(CLOCK_REALTIME, 0, rqtp, rem);
index 077250c6673d746c8628d29c20a4a44163a11ac4..d28805d18f759816b64e7b7fa9a36a53ce8651b3 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <wasi/api.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -24,7 +22,6 @@ int __wasilibc_nocwd_faccessat(int fd, const char *path, int amode, int flag) {
   __wasi_errno_t error =
       __wasi_path_filestat_get(fd, lookup_flags, path, &file);
   if (error != 0) {
-    errno = errno_fixup_directory(fd, error);
     return -1;
   }
 
index 683dd4cf65ecaee4510d8ff06819f91744e47d5f..eef59849157f916388118c4358bada4196e49e55 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <wasi/api.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -19,7 +17,6 @@ int __wasilibc_nocwd_linkat(int fd1, const char *path1, int fd2, const char *pat
   // Perform system call.
   __wasi_errno_t error = __wasi_path_link(fd1, lookup1_flags, path1, fd2, path2);
   if (error != 0) {
-    errno = errno_fixup_directory(fd1, errno_fixup_directory(fd2, error));
     return -1;
   }
   return 0;
index e08afb9b3c35b9872c7e95b92e67dc72b65ef605..4c5be305a6cabdb9559d84aa5d646336c018db9a 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <wasi/api.h>
 #include <errno.h>
 #include <string.h>
@@ -16,7 +14,6 @@ ssize_t __wasilibc_nocwd_readlinkat(int fd, const char *restrict path, char *res
   __wasi_errno_t error = __wasi_path_readlink(fd, path,
                                                       (uint8_t*)buf, bufsize, &bufused);
   if (error != 0) {
-    errno = errno_fixup_directory(fd, error);
     return -1;
   }
   return bufused;
index 1705afc1c548a018781458896b6e543881e827cd..b70fc785bbf611c6d2f7a0a26ba504abb6fb0693 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <wasi/api.h>
 #include <errno.h>
 #include <string.h>
@@ -12,7 +10,6 @@
 int __wasilibc_nocwd_symlinkat(const char *path1, int fd, const char *path2) {
   __wasi_errno_t error = __wasi_path_symlink(path1, fd, path2);
   if (error != 0) {
-    errno = errno_fixup_directory(fd, error);
     return -1;
   }
   return 0;
index ea795c2a2dfd358d0bc47017b8687e5b1e30b739..351bf9264570c0051b8b6a144d16b741f1eae92c 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: BSD-2-Clause
 
-#include <common/errno.h>
-
 #include <wasi/api.h>
 #include <wasi/libc.h>
 #include <errno.h>
index 2d56b1e76fd32452d27219a502dbdeb32a7b273f..2a2ff91d8a94ee1ff1f96d1c8ebf16455dfd1828 100644 (file)
 
 extern const struct __clockid _CLOCK_MONOTONIC;
 #define CLOCK_MONOTONIC (&_CLOCK_MONOTONIC)
-extern const struct __clockid _CLOCK_PROCESS_CPUTIME_ID;
-#define CLOCK_PROCESS_CPUTIME_ID (&_CLOCK_PROCESS_CPUTIME_ID)
 extern const struct __clockid _CLOCK_REALTIME;
 #define CLOCK_REALTIME (&_CLOCK_REALTIME)
-extern const struct __clockid _CLOCK_THREAD_CPUTIME_ID;
-#define CLOCK_THREAD_CPUTIME_ID (&_CLOCK_THREAD_CPUTIME_ID)
 
 /*
  * TIME_UTC is the only standardized time base value.
index 2730c23c52cbfc3110b92c3d45c9277a88ef9819..3f1d27daa3c881d6097662575a6a7dbde7a917c5 100644 (file)
@@ -1,4 +1,3 @@
-#include <common/errno.h>
 #include <wasi/api.h>
 #include <wasi/libc.h>
 #include <errno.h>
@@ -6,7 +5,6 @@
 int __wasilibc_nocwd___wasilibc_rmdirat(int fd, const char *path) {
     __wasi_errno_t error = __wasi_path_remove_directory(fd, path);
     if (error != 0) {
-        errno = errno_fixup_directory(fd, error);
         return -1;
     }
     return 0;
index 21ae69a52bee91c6eb35d3837d50e96698ddfcc1..8b4f6b5ceaf0c92c44fdf3a31193d0ceb12f42c6 100644 (file)
@@ -1,4 +1,3 @@
-#include <common/errno.h>
 #include <wasi/api.h>
 #include <wasi/libc.h>
 #include <errno.h>