mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-12 05:59:10 +00:00
Improve cosmo's conformance to libc-test
This change addresses various open source compatibility issues, so that we pass 313/411 of the tests in https://github.com/jart/libc-test where earlier today we were passing about 30/411 of them, due to header toil. Please note that Glibc only passes 341/411 so 313 today is pretty good! - Make the conformance of libc/isystem/ headers nearly perfect - Import more of the remaining math library routines from Musl - Fix inconsistencies with type signatures of calls like umask - Write tests for getpriority/setpriority which work great now - conform to `struct sockaddr *` on remaining socket functions - Import a bunch of uninteresting stdlib functions e.g. rand48 - Introduce readdir_r, scandir, pthread_kill, sigsetjmp, etc.. Follow the instructions in our `tool/scripts/cosmocc` toolchain to run these tests yourself. You use `make CC=cosmocc` on the test repository
This commit is contained in:
parent
467a332e38
commit
e557058ac8
189 changed files with 5091 additions and 884 deletions
|
@ -1,4 +1,8 @@
|
|||
#ifndef LIBC_ISYSTEM_ARPA_INET_H_
|
||||
#define LIBC_ISYSTEM_ARPA_INET_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
#include "libc/sysv/consts/inet6.h"
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_COMPLEX_H_
|
||||
#define LIBC_ISYSTEM_COMPLEX_H_
|
||||
#include "libc/complex.h"
|
||||
#include "libc/imag.h"
|
||||
#include "libc/math.h"
|
||||
#define I _Complex_I
|
||||
#endif
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
#define LIBC_ISYSTEM_DIRENT_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/dt.h"
|
||||
#endif
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_FCNTL_H_
|
||||
#define LIBC_ISYSTEM_SYS_FCNTL_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/flock.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
#include "libc/sysv/consts/fd.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/posix.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#endif
|
||||
|
|
6
libc/isystem/ftw.h
Normal file
6
libc/isystem/ftw.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_FTW_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_FTW_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "third_party/musl/ftw.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_FTW_H_ */
|
4
libc/isystem/glob.h
Normal file
4
libc/isystem/glob.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_GLOB_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_GLOB_H_
|
||||
#include "third_party/musl/glob.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_GLOB_H_ */
|
|
@ -2,4 +2,6 @@
|
|||
#define LIBC_ISYSTEM_INTTYPES_H_
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/inttypes.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/literal.h"
|
||||
#endif /* LIBC_ISYSTEM_INTTYPES_H_ */
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_LANGINFO_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_LANGINFO_H_
|
||||
#include "libc/str/langinfo.h"
|
||||
#include "libc/str/locale.h"
|
||||
#include "libc/str/nltypes.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_LANGINFO_H_ */
|
||||
|
|
4
libc/isystem/libgen.h
Normal file
4
libc/isystem/libgen.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_LIBGEN_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_LIBGEN_H_
|
||||
#include "libc/fmt/conv.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_LIBGEN_H_ */
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef LIBC_ISYSTEM_LIMITS_H_
|
||||
#define LIBC_ISYSTEM_LIMITS_H_
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/sysv/consts/_posix.h"
|
||||
#include "libc/sysv/consts/iov.h"
|
||||
#include "libc/sysv/consts/limits.h"
|
||||
#include "libc/sysv/consts/xopen.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#endif
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NETINET_IN_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NETINET_IN_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/ip_mreq.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/sock/struct/sockaddr6.h"
|
||||
#include "libc/sysv/consts/inaddr.h"
|
||||
#include "libc/sysv/consts/inet6.h"
|
||||
#include "libc/sysv/consts/ip.h"
|
||||
#include "libc/sysv/consts/ipport.h"
|
||||
#include "libc/sysv/consts/ipproto.h"
|
||||
|
|
6
libc/isystem/netinet/tcp.h
Normal file
6
libc/isystem/netinet/tcp.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NETINET_TCP_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NETINET_TCP_H_
|
||||
#include "libc/sysv/consts/sol.h"
|
||||
#include "libc/sysv/consts/tcp.h"
|
||||
#include "libc/sysv/consts/tcpopt.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NETINET_TCP_H_ */
|
4
libc/isystem/netinet/udp.h
Normal file
4
libc/isystem/netinet/udp.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NETINET_UDP_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NETINET_UDP_H_
|
||||
#include "libc/sysv/consts/sol.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NETINET_UDP_H_ */
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_POLL_H_
|
||||
#define LIBC_ISYSTEM_POLL_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/pollfd.h"
|
||||
#include "libc/sysv/consts/poll.h"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#ifndef LIBC_ISYSTEM_PTHREAD_H_
|
||||
#define LIBC_ISYSTEM_PTHREAD_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/thread/thread2.h"
|
||||
#endif /* LIBC_ISYSTEM_PTHREAD_H_ */
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/cpuset.h"
|
||||
#include "libc/calls/struct/sched_param.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/sched.h"
|
||||
#endif
|
||||
|
|
|
@ -6,4 +6,5 @@
|
|||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
#include "libc/sysv/consts/sicode.h"
|
||||
#include "libc/sysv/consts/ss.h"
|
||||
#endif
|
||||
|
|
5
libc/isystem/spawn.h
Normal file
5
libc/isystem/spawn.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SPAWN_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SPAWN_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/stdio/spawn.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SPAWN_H_ */
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_STDINT_H_
|
||||
#define LIBC_ISYSTEM_STDINT_H_
|
||||
#include "libc/inttypes.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/literal.h"
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#ifndef LIBC_ISYSTEM_STDIO_H_
|
||||
#define LIBC_ISYSTEM_STDIO_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/dprintf.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/mem/fmt.h"
|
||||
#include "libc/stdio/lock.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/stdio/temp.h"
|
||||
#include "third_party/musl/tempnam.h"
|
||||
#endif
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
#ifndef LIBC_ISYSTEM_STDLIB_H_
|
||||
#define LIBC_ISYSTEM_STDLIB_H_
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/dprintf.h"
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/stdio/temp.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "third_party/musl/crypt.h"
|
||||
#include "third_party/musl/rand48.h"
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_STRINGS_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_STRINGS_H_
|
||||
#include "libc/str/locale.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
||||
#include "libc/nexgen32e/ffs.h"
|
||||
#endif
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_STRINGS_H_ */
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_SOCKET_H_
|
||||
#define LIBC_ISYSTEM_SYS_SOCKET_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/linger.h"
|
||||
#include "libc/sock/struct/msghdr.h"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_STATVFS_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_STATVFS_H_
|
||||
#include "libc/calls/struct/statvfs.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/st.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_STATVFS_H_ */
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_TIME_H_
|
||||
#define LIBC_ISYSTEM_SYS_TIME_H_
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/calls/struct/itimerval.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/select.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/sysv/consts/itimer.h"
|
||||
#include "libc/time/struct/timezone.h"
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_TIMES_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/tms.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_TIMES_H_ */
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
#define LIBC_ISYSTEM_SYS_TYPES_H_
|
||||
#include "libc/calls/makedev.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
||||
#include "libc/intrin/newbie.h"
|
||||
#include "libc/calls/typedef/u.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/intrin/newbie.h"
|
||||
#include "libc/sock/select.h"
|
||||
#include "libc/sysv/consts/endian.h"
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_UIO_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_UIO_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_UIO_H_ */
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_UN_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_UN_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_UN_H_ */
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_WAIT_H_
|
||||
#define LIBC_ISYSTEM_SYS_WAIT_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/w.h"
|
||||
#include "libc/sysv/consts/waitid.h"
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_TERMIOS_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_TERMIOS_H_
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/baud.h"
|
||||
#include "libc/sysv/consts/termios.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_TERMIOS_H_ */
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef LIBC_ISYSTEM_TGMATH_H_
|
||||
#define LIBC_ISYSTEM_TGMATH_H_
|
||||
#include "libc/complex.h"
|
||||
#include "libc/imag.h"
|
||||
#include "libc/math.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
#if __STDC_VERSION__ + 0 >= 201112
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
/* from https://en.cppreference.com/w/c/numeric/tgmath */
|
||||
|
||||
|
@ -268,8 +268,11 @@ COSMOPOLITAN_C_START_
|
|||
: remainder, long double \
|
||||
: remainderl)(x, y)
|
||||
|
||||
#define remquo(x, y) \
|
||||
_Generic((x), float : remquof, default : remquo, long double : remquol)(x, y)
|
||||
#define remquo(x, y, z) \
|
||||
_Generic((x), float \
|
||||
: remquof, default \
|
||||
: remquo, long double \
|
||||
: remquol)(x, y, z)
|
||||
|
||||
#define rint(x) \
|
||||
_Generic((x), float : rintf, default : rint, long double : rintl)(x)
|
||||
|
@ -294,38 +297,36 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
#define carg(x) \
|
||||
_Generic((x), complex float \
|
||||
: cargf, complex default \
|
||||
: cargf, default \
|
||||
: carg, complex long double \
|
||||
: cargl)(x)
|
||||
|
||||
#define conj(x) \
|
||||
_Generic((x), complex float \
|
||||
: conjf, complex default \
|
||||
: conjf, default \
|
||||
: conj, complex long double \
|
||||
: conjl)(x)
|
||||
|
||||
#undef creal
|
||||
#define creal(x) \
|
||||
_Generic((x), complex float \
|
||||
: crealf, complex default \
|
||||
: crealf, default \
|
||||
: creal, complex long double \
|
||||
: creall)(x)
|
||||
|
||||
#undef cimag
|
||||
#define cimag(x) \
|
||||
_Generic((x), complex float \
|
||||
: cimagf, complex default \
|
||||
: cimagf, default \
|
||||
: cimag, complex long double \
|
||||
: cimagl)(x)
|
||||
|
||||
#define cproj(x) \
|
||||
_Generic((x), complex float \
|
||||
: cprojf, complex default \
|
||||
: cprojf, default \
|
||||
: cproj, complex long double \
|
||||
: cprojl)(x)
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
||||
#endif /* C11 */
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* LIBC_ISYSTEM_TGMATH_H_ */
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/sysv/consts/sched.h"
|
||||
#include "libc/sysv/consts/timer.h"
|
||||
#include "libc/time/struct/tm.h"
|
||||
#include "libc/time/time.h"
|
||||
#endif
|
||||
|
|
|
@ -3,9 +3,13 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/runtime/pathconf.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/sysconf.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/ok.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "third_party/musl/crypt.h"
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#ifndef LIBC_ISYSTEM_WCHAR_H_
|
||||
#define LIBC_ISYSTEM_WCHAR_H_
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/unicode.h"
|
||||
#include "libc/time/time.h"
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_WCTYPE_H_
|
||||
#define LIBC_ISYSTEM_WCTYPE_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/str/str.h"
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue