From: Iain Buclaw Date: Mon, 27 Apr 2020 21:33:18 +0000 (+0200) Subject: libphobos: Backport extern(C) bindings from druntime 2.091 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6dffa67b46dc2d4deb25951f8b17e823f559cf3a;p=gcc.git libphobos: Backport extern(C) bindings from druntime 2.091 Merge upstream druntime 47688279. Reviewed-on: https://github.com/dlang/druntime/pull/3073 Fixes: PR d/90718 Fixes: PR d/90719 libphobos/ChangeLog: * libdruntime/Makefile.am (DRUNTIME_DSOURCES_LINUX): Remove core/sys/linux/sys/netinet/tcp.d. * libdruntime/Makefile.in: Regenerate. --- diff --git a/libphobos/ChangeLog b/libphobos/ChangeLog index f40f2764e1b..cc5275112ba 100644 --- a/libphobos/ChangeLog +++ b/libphobos/ChangeLog @@ -1,3 +1,9 @@ +2020-04-27 Iain Buclaw + + * libdruntime/Makefile.am (DRUNTIME_DSOURCES_LINUX): Remove + core/sys/linux/sys/netinet/tcp.d. + * libdruntime/Makefile.in: Regenerate. + 2020-04-27 Iain Buclaw * configure.tgt: Add hppa-*-linux* as a supported target. diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index e3763485adf..c6357317ddc 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -2b5c0b2766949e788e4929c5fb0e2ba698ff79a3 +476882795473a884f837bea6da850ac5181868d1 The first line of this file holds the git revision number of the last merge done from the dlang/druntime repository. diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am index e1a38153de0..e1f47d36f90 100644 --- a/libphobos/libdruntime/Makefile.am +++ b/libphobos/libdruntime/Makefile.am @@ -255,12 +255,12 @@ DRUNTIME_DSOURCES_LINUX = core/sys/linux/config.d \ core/sys/linux/sched.d core/sys/linux/stdio.d core/sys/linux/string.d \ core/sys/linux/sys/auxv.d core/sys/linux/sys/eventfd.d \ core/sys/linux/sys/file.d core/sys/linux/sys/inotify.d \ - core/sys/linux/sys/mman.d core/sys/linux/sys/netinet/tcp.d \ - core/sys/linux/sys/prctl.d core/sys/linux/sys/signalfd.d \ - core/sys/linux/sys/socket.d core/sys/linux/sys/sysinfo.d \ - core/sys/linux/sys/time.d core/sys/linux/sys/xattr.d \ - core/sys/linux/termios.d core/sys/linux/time.d \ - core/sys/linux/timerfd.d core/sys/linux/tipc.d core/sys/linux/unistd.d + core/sys/linux/sys/mman.d core/sys/linux/sys/prctl.d \ + core/sys/linux/sys/signalfd.d core/sys/linux/sys/socket.d \ + core/sys/linux/sys/sysinfo.d core/sys/linux/sys/time.d \ + core/sys/linux/sys/xattr.d core/sys/linux/termios.d \ + core/sys/linux/time.d core/sys/linux/timerfd.d core/sys/linux/tipc.d \ + core/sys/linux/unistd.d DRUNTIME_DSOURCES_NETBSD = core/sys/netbsd/dlfcn.d \ core/sys/netbsd/execinfo.d core/sys/netbsd/string.d \ diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in index 4130e96d7be..53402842cb4 100644 --- a/libphobos/libdruntime/Makefile.in +++ b/libphobos/libdruntime/Makefile.in @@ -334,13 +334,12 @@ am__objects_17 = core/sys/linux/config.lo core/sys/linux/dlfcn.lo \ core/sys/linux/stdio.lo core/sys/linux/string.lo \ core/sys/linux/sys/auxv.lo core/sys/linux/sys/eventfd.lo \ core/sys/linux/sys/file.lo core/sys/linux/sys/inotify.lo \ - core/sys/linux/sys/mman.lo core/sys/linux/sys/netinet/tcp.lo \ - core/sys/linux/sys/prctl.lo core/sys/linux/sys/signalfd.lo \ - core/sys/linux/sys/socket.lo core/sys/linux/sys/sysinfo.lo \ - core/sys/linux/sys/time.lo core/sys/linux/sys/xattr.lo \ - core/sys/linux/termios.lo core/sys/linux/time.lo \ - core/sys/linux/timerfd.lo core/sys/linux/tipc.lo \ - core/sys/linux/unistd.lo + core/sys/linux/sys/mman.lo core/sys/linux/sys/prctl.lo \ + core/sys/linux/sys/signalfd.lo core/sys/linux/sys/socket.lo \ + core/sys/linux/sys/sysinfo.lo core/sys/linux/sys/time.lo \ + core/sys/linux/sys/xattr.lo core/sys/linux/termios.lo \ + core/sys/linux/time.lo core/sys/linux/timerfd.lo \ + core/sys/linux/tipc.lo core/sys/linux/unistd.lo @DRUNTIME_OS_LINUX_TRUE@am__objects_18 = $(am__objects_17) am__objects_19 = core/sys/windows/accctrl.lo \ core/sys/windows/aclapi.lo core/sys/windows/aclui.lo \ @@ -878,12 +877,12 @@ DRUNTIME_DSOURCES_LINUX = core/sys/linux/config.d \ core/sys/linux/sched.d core/sys/linux/stdio.d core/sys/linux/string.d \ core/sys/linux/sys/auxv.d core/sys/linux/sys/eventfd.d \ core/sys/linux/sys/file.d core/sys/linux/sys/inotify.d \ - core/sys/linux/sys/mman.d core/sys/linux/sys/netinet/tcp.d \ - core/sys/linux/sys/prctl.d core/sys/linux/sys/signalfd.d \ - core/sys/linux/sys/socket.d core/sys/linux/sys/sysinfo.d \ - core/sys/linux/sys/time.d core/sys/linux/sys/xattr.d \ - core/sys/linux/termios.d core/sys/linux/time.d \ - core/sys/linux/timerfd.d core/sys/linux/tipc.d core/sys/linux/unistd.d + core/sys/linux/sys/mman.d core/sys/linux/sys/prctl.d \ + core/sys/linux/sys/signalfd.d core/sys/linux/sys/socket.d \ + core/sys/linux/sys/sysinfo.d core/sys/linux/sys/time.d \ + core/sys/linux/sys/xattr.d core/sys/linux/termios.d \ + core/sys/linux/time.d core/sys/linux/timerfd.d core/sys/linux/tipc.d \ + core/sys/linux/unistd.d DRUNTIME_DSOURCES_NETBSD = core/sys/netbsd/dlfcn.d \ core/sys/netbsd/execinfo.d core/sys/netbsd/string.d \ @@ -1526,11 +1525,6 @@ core/sys/linux/sys/eventfd.lo: core/sys/linux/sys/$(am__dirstamp) core/sys/linux/sys/file.lo: core/sys/linux/sys/$(am__dirstamp) core/sys/linux/sys/inotify.lo: core/sys/linux/sys/$(am__dirstamp) core/sys/linux/sys/mman.lo: core/sys/linux/sys/$(am__dirstamp) -core/sys/linux/sys/netinet/$(am__dirstamp): - @$(MKDIR_P) core/sys/linux/sys/netinet - @: > core/sys/linux/sys/netinet/$(am__dirstamp) -core/sys/linux/sys/netinet/tcp.lo: \ - core/sys/linux/sys/netinet/$(am__dirstamp) core/sys/linux/sys/prctl.lo: core/sys/linux/sys/$(am__dirstamp) core/sys/linux/sys/signalfd.lo: core/sys/linux/sys/$(am__dirstamp) core/sys/linux/sys/socket.lo: core/sys/linux/sys/$(am__dirstamp) @@ -1867,8 +1861,6 @@ mostlyclean-compile: -rm -f core/sys/linux/netinet/*.lo -rm -f core/sys/linux/sys/*.$(OBJEXT) -rm -f core/sys/linux/sys/*.lo - -rm -f core/sys/linux/sys/netinet/*.$(OBJEXT) - -rm -f core/sys/linux/sys/netinet/*.lo -rm -f core/sys/netbsd/*.$(OBJEXT) -rm -f core/sys/netbsd/*.lo -rm -f core/sys/netbsd/sys/*.$(OBJEXT) @@ -2027,7 +2019,6 @@ clean-libtool: -rm -rf core/sys/linux/.libs core/sys/linux/_libs -rm -rf core/sys/linux/netinet/.libs core/sys/linux/netinet/_libs -rm -rf core/sys/linux/sys/.libs core/sys/linux/sys/_libs - -rm -rf core/sys/linux/sys/netinet/.libs core/sys/linux/sys/netinet/_libs -rm -rf core/sys/netbsd/.libs core/sys/netbsd/_libs -rm -rf core/sys/netbsd/sys/.libs core/sys/netbsd/sys/_libs -rm -rf core/sys/openbsd/.libs core/sys/openbsd/_libs @@ -2183,7 +2174,6 @@ distclean-generic: -rm -f core/sys/linux/$(am__dirstamp) -rm -f core/sys/linux/netinet/$(am__dirstamp) -rm -f core/sys/linux/sys/$(am__dirstamp) - -rm -f core/sys/linux/sys/netinet/$(am__dirstamp) -rm -f core/sys/netbsd/$(am__dirstamp) -rm -f core/sys/netbsd/sys/$(am__dirstamp) -rm -f core/sys/openbsd/$(am__dirstamp) diff --git a/libphobos/libdruntime/core/math.d b/libphobos/libdruntime/core/math.d index 878623258cd..219b4263ff2 100644 --- a/libphobos/libdruntime/core/math.d +++ b/libphobos/libdruntime/core/math.d @@ -167,9 +167,11 @@ unittest /************************************* * Round argument to a specific precision. * - * D language types specify a minimum precision, not a maximum. The - * `toPrec()` function forces rounding of the argument `f` to the - * precision of the specified floating point type `T`. + * D language types specify only a minimum precision, not a maximum. The + * `toPrec()` function forces rounding of the argument `f` to the precision + * of the specified floating point type `T`. + * The rounding mode used is inevitably target-dependent, but will be done in + * a way to maximize accuracy. In most cases, the default is round-to-nearest. * * Params: * T = precision type to round to @@ -206,9 +208,10 @@ T toPrec(T:real)(real f) { pragma(inline, false); return f; } @safe unittest { - static float f = 1.1f; - static double d = 1.1; - static real r = 1.1L; + // Test all instantiations work with all combinations of float. + float f = 1.1f; + double d = 1.1; + real r = 1.1L; f = toPrec!float(f + f); f = toPrec!float(d + d); f = toPrec!float(r + r); @@ -219,19 +222,32 @@ T toPrec(T:real)(real f) { pragma(inline, false); return f; } r = toPrec!real(d + d); r = toPrec!real(r + r); - /+ Uncomment these once compiler support has been added. + // Comparison tests. + bool approxEqual(T)(T lhs, T rhs) + { + return fabs((lhs - rhs) / rhs) <= 1e-2 || fabs(lhs - rhs) <= 1e-5; + } + enum real PIR = 0xc.90fdaa22168c235p-2; enum double PID = 0x1.921fb54442d18p+1; enum float PIF = 0x1.921fb6p+1; - - assert(toPrec!float(PIR) == PIF); - assert(toPrec!double(PIR) == PID); - assert(toPrec!real(PIR) == PIR); - assert(toPrec!float(PID) == PIF); - assert(toPrec!double(PID) == PID); - assert(toPrec!real(PID) == PID); - assert(toPrec!float(PIF) == PIF); - assert(toPrec!double(PIF) == PIF); - assert(toPrec!real(PIF) == PIF); - +/ + static assert(approxEqual(toPrec!float(PIR), PIF)); + static assert(approxEqual(toPrec!double(PIR), PID)); + static assert(approxEqual(toPrec!real(PIR), PIR)); + static assert(approxEqual(toPrec!float(PID), PIF)); + static assert(approxEqual(toPrec!double(PID), PID)); + static assert(approxEqual(toPrec!real(PID), PID)); + static assert(approxEqual(toPrec!float(PIF), PIF)); + static assert(approxEqual(toPrec!double(PIF), PIF)); + static assert(approxEqual(toPrec!real(PIF), PIF)); + + assert(approxEqual(toPrec!float(PIR), PIF)); + assert(approxEqual(toPrec!double(PIR), PID)); + assert(approxEqual(toPrec!real(PIR), PIR)); + assert(approxEqual(toPrec!float(PID), PIF)); + assert(approxEqual(toPrec!double(PID), PID)); + assert(approxEqual(toPrec!real(PID), PID)); + assert(approxEqual(toPrec!float(PIF), PIF)); + assert(approxEqual(toPrec!double(PIF), PIF)); + assert(approxEqual(toPrec!real(PIF), PIF)); } diff --git a/libphobos/libdruntime/core/stdc/assert_.d b/libphobos/libdruntime/core/stdc/assert_.d index 18af7132e38..fc9402f6051 100644 --- a/libphobos/libdruntime/core/stdc/assert_.d +++ b/libphobos/libdruntime/core/stdc/assert_.d @@ -17,6 +17,15 @@ module core.stdc.assert_; +version (OSX) + version = Darwin; +else version (iOS) + version = Darwin; +else version (TVOS) + version = Darwin; +else version (WatchOS) + version = Darwin; + extern (C): @trusted: nothrow: @@ -39,10 +48,10 @@ else version (CRuntime_Microsoft) /// void _assert(const(char)* exp, const(char)* file, uint line); } -else version (OSX) +else version (Darwin) { /*** - * Assert failure function in the OSX C library. + * Assert failure function in the Darwin C library. */ void __assert_rtn(const(char)* func, const(char)* file, uint line, const(char)* exp); } diff --git a/libphobos/libdruntime/core/stdc/errno.d b/libphobos/libdruntime/core/stdc/errno.d index 80105d70de7..767ed242472 100644 --- a/libphobos/libdruntime/core/stdc/errno.d +++ b/libphobos/libdruntime/core/stdc/errno.d @@ -211,6 +211,50 @@ version (Windows) enum ENOTEMPTY = 41; /// Directory not empty enum EILSEQ = 42; /// Illegal byte sequence enum EDEADLOCK = EDEADLK; /// Resource deadlock would occur + + // POSIX compatibility + // See_Also: https://docs.microsoft.com/en-us/cpp/c-runtime-library/errno-constants + enum EADDRINUSE = 100; + enum EADDRNOTAVAIL = 101; + enum EAFNOSUPPORT = 102; + enum EALREADY = 103; + enum EBADMSG = 104; + enum ECANCELED = 105; + enum ECONNABORTED = 106; + enum ECONNREFUSED = 107; + enum ECONNRESET = 108; + enum EDESTADDRREQ = 109; + enum EHOSTUNREACH = 110; + enum EIDRM = 111; + enum EINPROGRESS = 112; + enum EISCONN = 113; + enum ELOOP = 114; + enum EMSGSIZE = 115; + enum ENETDOWN = 116; + enum ENETRESET = 117; + enum ENETUNREACH = 118; + enum ENOBUFS = 119; + enum ENODATA = 120; + enum ENOLINK = 121; + enum ENOMSG = 122; + enum ENOPROTOOPT = 123; + enum ENOSR = 124; + enum ENOSTR = 125; + enum ENOTCONN = 126; + enum ENOTRECOVERABLE = 127; + enum ENOTSOCK = 128; + enum ENOTSUP = 129; + enum EOPNOTSUPP = 130; + enum EOTHER = 131; + enum EOVERFLOW = 132; + enum EOWNERDEAD = 133; + enum EPROTO = 134; + enum EPROTONOSUPPORT = 135; + enum EPROTOTYPE = 136; + enum ETIME = 137; + enum ETIMEDOUT = 138; + enum ETXTBSY = 139; + enum EWOULDBLOCK = 140; } else version (linux) { diff --git a/libphobos/libdruntime/core/stdc/stdint.d b/libphobos/libdruntime/core/stdc/stdint.d index b04283174c1..0e310521e0e 100644 --- a/libphobos/libdruntime/core/stdc/stdint.d +++ b/libphobos/libdruntime/core/stdc/stdint.d @@ -19,6 +19,14 @@ private import core.stdc.stddef; // for wchar_t private import core.stdc.signal; // for sig_atomic_t private import core.stdc.wchar_; // for wint_t +version (OSX) + version = Darwin; +else version (iOS) + version = Darwin; +else version (TVOS) + version = Darwin; +else version (WatchOS) + version = Darwin; // Can't be `private` because of @@@BUG11173@@@. T _typify(T)(T val) @safe pure nothrow { return val; } @@ -77,7 +85,7 @@ version (Windows) alias intmax_t = long; /// alias uintmax_t = ulong; /// } -else version (OSX) +else version (Darwin) { alias int8_t = byte; /// alias int16_t = short; /// @@ -140,6 +148,15 @@ else version (Posix) alias int_fast32_t = int; /// alias uint_fast32_t = uint; /// } + else version (CRuntime_Musl) + { + alias int_fast8_t = byte; /// + alias uint_fast8_t = ubyte; /// + alias int_fast16_t = int; /// + alias uint_fast16_t = uint; /// + alias int_fast32_t = int; /// + alias uint_fast32_t = uint; /// + } else { alias int_fast8_t = byte; /// diff --git a/libphobos/libdruntime/core/stdc/string.d b/libphobos/libdruntime/core/stdc/string.d index b7660d8f8ea..0929a4eab53 100644 --- a/libphobos/libdruntime/core/stdc/string.d +++ b/libphobos/libdruntime/core/stdc/string.d @@ -23,6 +23,12 @@ else version (TVOS) else version (WatchOS) version = Darwin; +// Those libs don't expose the mandated C interface +version (CRuntime_Glibc) + version = ReturnStrerrorR; +else version (CRuntime_UClibc) + version = ReturnStrerrorR; + extern (C): @system: nothrow: @@ -76,50 +82,17 @@ pure inout(char)* strstr(return inout(char)* s1, scope const char* s2); char* strtok(return char* s1, scope const char* s2); /// char* strerror(int errnum); -version (CRuntime_Glibc) +// This `strerror_r` definition is not following the POSIX standard +version (ReturnStrerrorR) { /// const(char)* strerror_r(int errnum, return char* buf, size_t buflen); } -else version (Darwin) -{ - int strerror_r(int errnum, scope char* buf, size_t buflen); -} -else version (FreeBSD) -{ - int strerror_r(int errnum, scope char* buf, size_t buflen); -} -else version (NetBSD) -{ - int strerror_r(int errnum, char* buf, size_t buflen); -} -else version (OpenBSD) -{ - int strerror_r(int errnum, scope char* buf, size_t buflen); -} -else version (DragonFlyBSD) +// This one is +else { int strerror_r(int errnum, scope char* buf, size_t buflen); } -else version (Solaris) -{ - int strerror_r(int errnum, scope char* buf, size_t buflen); -} -else version (CRuntime_Bionic) -{ - /// - int strerror_r(int errnum, scope char* buf, size_t buflen); -} -else version (CRuntime_Musl) -{ - /// - int strerror_r(int errnum, scope char *buf, size_t buflen); -} -else version (CRuntime_UClibc) -{ - /// - const(char)* strerror_r(int errnum, return char* buf, size_t buflen); -} /// pure size_t strlen(scope const char* s); /// diff --git a/libphobos/libdruntime/core/sys/darwin/mach/port.d b/libphobos/libdruntime/core/sys/darwin/mach/port.d index b9551fa52e0..1c5cf6df2c0 100644 --- a/libphobos/libdruntime/core/sys/darwin/mach/port.d +++ b/libphobos/libdruntime/core/sys/darwin/mach/port.d @@ -25,12 +25,5 @@ else version (WatchOS) version (Darwin): extern (C): -version (X86) - version = i386; -version (X86_64) - version = i386; -version (i386) -{ - alias uint natural_t; - alias natural_t mach_port_t; -} +alias natural_t = uint; +alias mach_port_t = natural_t; diff --git a/libphobos/libdruntime/core/sys/darwin/mach/thread_act.d b/libphobos/libdruntime/core/sys/darwin/mach/thread_act.d index 78f9ee4eeaa..b61673fb4f1 100644 --- a/libphobos/libdruntime/core/sys/darwin/mach/thread_act.d +++ b/libphobos/libdruntime/core/sys/darwin/mach/thread_act.d @@ -34,6 +34,11 @@ version (X86) version = i386; version (X86_64) version = i386; +version (AArch64) + version = AnyARM; +version (ARM) + version = AnyARM; + version (i386) { alias mach_port_t thread_act_t; @@ -135,3 +140,98 @@ version (i386) kern_return_t thread_resume(thread_act_t); kern_return_t thread_get_state(thread_act_t, thread_state_flavor_t, thread_state_t*, mach_msg_type_number_t*); } +// https://github.com/apple/darwin-xnu/blob/master/osfmk/mach/arm/_structs.h +// https://github.com/apple/darwin-xnu/blob/master/osfmk/mach/arm/thread_status.h +else version (AnyARM) +{ + alias thread_act_t = mach_port_t; + alias thread_state_t = void; + alias thread_state_flavor_t = int; + alias mach_msg_type_number_t = natural_t; + + enum + { + ARM_THREAD_STATE = 1, + ARM_UNIFIED_THREAD_STATE = ARM_THREAD_STATE, + ARM_VFP_STATE = 2, + ARM_EXCEPTION_STATE = 3, + ARM_DEBUG_STATE = 4, /* pre-armv8 */ + THREAD_STATE_NONE = 5, + ARM_THREAD_STATE64 = 6, + ARM_EXCEPTION_STATE64 = 7, + // ARM_THREAD_STATE_LAST = 8, /* legacy */ + ARM_THREAD_STATE32 = 9 + } + + enum + { + ARM_DEBUG_STATE32 = 14, + ARM_DEBUG_STATE64 = 15, + ARM_NEON_STATE = 16, + ARM_NEON_STATE64 = 17, + ARM_CPMU_STATE64 = 18 + } + + enum + { + ARM_AMX_STATE = 24, + ARM_AMX_STATE_V1 = 25 + } + + struct arm_thread_state_t + { + uint[13] r; /// General purpose register r0-r12 + uint sp; /// Stack pointer r13 + uint lr; /// Link register r14 + uint pc; /// Program counter r15 + uint cpsr; /// Current program status register + } + + alias arm_thread_state32_t = arm_thread_state_t; + + struct arm_thread_state64_t + { + ulong[29] x; /// General purpose registers x0-x28 + ulong fp; /// Frame pointer x29 + ulong lr; /// Link register x30 + ulong sp; /// Stack pointer x31 + ulong pc; /// Program counter + ulong cpsr; /// Current program status register + ulong pad; /// Same size for 32-bit or 64-bit clients + } + + struct arm_state_hdr_t + { + uint flavor; + uint count; + } + + struct arm_unified_thread_state_t + { + arm_state_hdr_t ash; + + union _uts + { + arm_thread_state32_t ts_32; + arm_thread_state64_t ts_64; + } + + _uts uts; + } + + enum : mach_msg_type_number_t + { + ARM_THREAD_STATE_COUNT = cast(mach_msg_type_number_t) (arm_thread_state_t.sizeof / uint.sizeof), + ARM_THREAD_STATE32_COUNT = cast(mach_msg_type_number_t) (arm_thread_state32_t.sizeof / uint.sizeof), + ARM_THREAD_STATE64_COUNT = cast(mach_msg_type_number_t) (arm_thread_state64_t.sizeof / uint.sizeof), + ARM_UNIFIED_THREAD_STATE_COUNT = cast(mach_msg_type_number_t) (arm_unified_thread_state_t.sizeof / uint.sizeof) + } + + alias MACHINE_THREAD_STATE = ARM_THREAD_STATE; + alias MACHINE_THREAD_STATE_COUNT = ARM_UNIFIED_THREAD_STATE_COUNT; + + mach_port_t mach_thread_self(); + kern_return_t thread_suspend(thread_act_t); + kern_return_t thread_resume(thread_act_t); + kern_return_t thread_get_state(thread_act_t, thread_state_flavor_t, thread_state_t*, mach_msg_type_number_t*); +} diff --git a/libphobos/libdruntime/core/sys/freebsd/dlfcn.d b/libphobos/libdruntime/core/sys/freebsd/dlfcn.d index e390743692d..95b6c1dfbae 100644 --- a/libphobos/libdruntime/core/sys/freebsd/dlfcn.d +++ b/libphobos/libdruntime/core/sys/freebsd/dlfcn.d @@ -86,16 +86,13 @@ static if (__BSD_VISIBLE) }; } -private template __externC(RT, P...) -{ - alias __externC = extern(C) RT function(P) nothrow @nogc; -} - /* XSI functions first. */ -static assert(is(typeof(&dlclose) == __externC!(int, void*))); -static assert(is(typeof(&dlerror) == __externC!(char*))); -static assert(is(typeof(&dlopen) == __externC!(void*, const char*, int))); -static assert(is(typeof(&dlsym) == __externC!(void*, void*, const char*))); +extern(C) { + static assert(is(typeof(&dlclose) == int function(void*))); + static assert(is(typeof(&dlerror) == char* function())); + static assert(is(typeof(&dlopen) == void* function(in char*, int))); + static assert(is(typeof(&dlsym) == void* function(void*, in char*))); +} static if (__BSD_VISIBLE) { diff --git a/libphobos/libdruntime/core/sys/freebsd/execinfo.d b/libphobos/libdruntime/core/sys/freebsd/execinfo.d index cbdf70219dc..125ef097d27 100644 --- a/libphobos/libdruntime/core/sys/freebsd/execinfo.d +++ b/libphobos/libdruntime/core/sys/freebsd/execinfo.d @@ -38,6 +38,8 @@ else asm nothrow @trusted { mov p[EBP], EBP; } else version (D_InlineAsm_X86_64) asm nothrow @trusted { mov p[RBP], RBP; } + else version (AArch64) + asm nothrow @trusted { "str x29, %0" : "=m" (p); } else static assert(false, "Architecture not supported."); diff --git a/libphobos/libdruntime/core/sys/linux/config.d b/libphobos/libdruntime/core/sys/linux/config.d index 96126674b01..03d3e17e166 100644 --- a/libphobos/libdruntime/core/sys/linux/config.d +++ b/libphobos/libdruntime/core/sys/linux/config.d @@ -27,6 +27,3 @@ deprecated("use _DEFAULT_SOURCE") enum __USE_MISC = _DEFAULT_SOURCE; enum __USE_ATFILE = _ATFILE_SOURCE; enum __USE_GNU = _GNU_SOURCE; - -// Available in bionic from API 21 -version (CRuntime_Bionic) enum __WORDSIZE = 32; diff --git a/libphobos/libdruntime/core/sys/linux/link.d b/libphobos/libdruntime/core/sys/linux/link.d index e242d2b2876..4d7eb1eb7d3 100644 --- a/libphobos/libdruntime/core/sys/linux/link.d +++ b/libphobos/libdruntime/core/sys/linux/link.d @@ -31,7 +31,15 @@ import core.sys.linux.dlfcn : Lmid_t; import core.sys.linux.elf; // -version (X86_Any) +version (Android) +{ + alias __WORDSIZE __ELF_NATIVE_CLASS; + version (D_LP64) + alias uint64_t Elf_Symndx; + else + alias uint32_t Elf_Symndx; +} +else version (X86_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h alias __WORDSIZE __ELF_NATIVE_CLASS; diff --git a/libphobos/libdruntime/core/sys/linux/sys/netinet/tcp.d b/libphobos/libdruntime/core/sys/linux/sys/netinet/tcp.d deleted file mode 100644 index d4957363951..00000000000 --- a/libphobos/libdruntime/core/sys/linux/sys/netinet/tcp.d +++ /dev/null @@ -1,9 +0,0 @@ -/** - * D header file for GNU/Linux - * - * Authors: Martin Nowak - */ -deprecated("Import core.sys.linux.netinet.tcp instead") -module core.sys.linux.sys.netinet.tcp; - -public import core.sys.linux.netinet.tcp; diff --git a/libphobos/libdruntime/core/sys/linux/sys/socket.d b/libphobos/libdruntime/core/sys/linux/sys/socket.d index b8ad94c52d2..339a6022dc8 100644 --- a/libphobos/libdruntime/core/sys/linux/sys/socket.d +++ b/libphobos/libdruntime/core/sys/linux/sys/socket.d @@ -156,3 +156,21 @@ enum SO_PEERGROUPS = 59, SO_ZEROCOPY = 60, } + +enum : uint +{ + MSG_TRYHARD = 0x04, + MSG_PROXY = 0x10, + MSG_DONTWAIT = 0x40, + MSG_FIN = 0x200, + MSG_SYN = 0x400, + MSG_CONFIRM = 0x800, + MSG_RST = 0x1000, + MSG_ERRQUEUE = 0x2000, + MSG_MORE = 0x8000, + MSG_WAITFORONE = 0x10000, + MSG_BATCH = 0x40000, + MSG_ZEROCOPY = 0x4000000, + MSG_FASTOPEN = 0x20000000, + MSG_CMSG_CLOEXEC = 0x40000000 +} diff --git a/libphobos/libdruntime/core/sys/linux/timerfd.d b/libphobos/libdruntime/core/sys/linux/timerfd.d index 047f257d98d..f8a9719a87e 100644 --- a/libphobos/libdruntime/core/sys/linux/timerfd.d +++ b/libphobos/libdruntime/core/sys/linux/timerfd.d @@ -20,5 +20,6 @@ int timerfd_settime(int fd, int flags, const itimerspec* new_value, itimerspec* int timerfd_gettime(int fd, itimerspec* curr_value); enum TFD_TIMER_ABSTIME = 1 << 0; +enum TFD_TIMER_CANCEL_ON_SET = 1 << 1; enum TFD_CLOEXEC = 0x80000; enum TFD_NONBLOCK = 0x800; diff --git a/libphobos/libdruntime/core/sys/posix/config.d b/libphobos/libdruntime/core/sys/posix/config.d index 9ac42a130a0..20e711cb72d 100644 --- a/libphobos/libdruntime/core/sys/posix/config.d +++ b/libphobos/libdruntime/core/sys/posix/config.d @@ -61,9 +61,9 @@ version (CRuntime_Glibc) enum __USE_REENTRANT = _REENTRANT; version (D_LP64) - enum __WORDSIZE=64; + enum __WORDSIZE = 64; else - enum __WORDSIZE=32; + enum __WORDSIZE = 32; } else version (CRuntime_Musl) { @@ -109,13 +109,19 @@ else version (CRuntime_UClibc) enum __USE_REENTRANT = _REENTRANT; version (D_LP64) - enum __WORDSIZE=64; + enum __WORDSIZE = 64; else - enum __WORDSIZE=32; + enum __WORDSIZE = 32; } else version (CRuntime_Bionic) { - enum __USE_GNU = false; + enum _GNU_SOURCE = false; + enum __USE_GNU = _GNU_SOURCE; + + version (D_LP64) + enum __WORDSIZE = 64; + else + enum __WORDSIZE = 32; } else version (OpenBSD) { diff --git a/libphobos/libdruntime/core/sys/posix/dlfcn.d b/libphobos/libdruntime/core/sys/posix/dlfcn.d index f36669dd0b3..11113d36269 100644 --- a/libphobos/libdruntime/core/sys/posix/dlfcn.d +++ b/libphobos/libdruntime/core/sys/posix/dlfcn.d @@ -126,20 +126,6 @@ version (CRuntime_Glibc) char* dlerror(); void* dlopen(in char*, int); void* dlsym(void*, in char*); - - deprecated("Please use core.sys.linux.dlfcn for non-POSIX extensions") - { - int dladdr(in void* addr, Dl_info* info); - void* dlvsym(void* handle, in char* symbol, in char* version_); - - struct Dl_info - { - const(char)* dli_fname; - void* dli_fbase; - const(char)* dli_sname; - void* dli_saddr; - } - } } else version (Darwin) { diff --git a/libphobos/libdruntime/core/sys/posix/inttypes.d b/libphobos/libdruntime/core/sys/posix/inttypes.d index e2954eda5cf..15863b4f35e 100644 --- a/libphobos/libdruntime/core/sys/posix/inttypes.d +++ b/libphobos/libdruntime/core/sys/posix/inttypes.d @@ -27,7 +27,7 @@ extern (C) nothrow @nogc: intmax_t imaxabs(intmax_t); imaxdiv_t imaxdiv(intmax_t, intmax_t); intmax_t strtoimax(in char*, char**, int); -uintmax_t strtoumax(in char *, char**, int); +uintmax_t strtoumax(in char*, char**, int); intmax_t wcstoimax(in wchar_t*, wchar_t**, int); uintmax_t wcstoumax(in wchar_t*, wchar_t**, int); */ @@ -35,6 +35,6 @@ uintmax_t wcstoumax(in wchar_t*, wchar_t**, int); intmax_t imaxabs(intmax_t); imaxdiv_t imaxdiv(intmax_t, intmax_t); intmax_t strtoimax(in char*, char**, int); -uintmax_t strtoumax(in char *, char**, int); +uintmax_t strtoumax(in char*, char**, int); intmax_t wcstoimax(in wchar_t*, wchar_t**, int); uintmax_t wcstoumax(in wchar_t*, wchar_t**, int); diff --git a/libphobos/libdruntime/core/sys/posix/netdb.d b/libphobos/libdruntime/core/sys/posix/netdb.d index 327387f68ea..f1251839b16 100644 --- a/libphobos/libdruntime/core/sys/posix/netdb.d +++ b/libphobos/libdruntime/core/sys/posix/netdb.d @@ -743,9 +743,7 @@ else version (Solaris) int ai_socktype; int ai_protocol; - version (SPARC) - int _ai_pad; - else version (SPARC64) + version (SPARC64) int _ai_pad; socklen_t ai_addrlen; diff --git a/libphobos/libdruntime/core/sys/posix/signal.d b/libphobos/libdruntime/core/sys/posix/signal.d index 5abcdac1355..9a97709b473 100644 --- a/libphobos/libdruntime/core/sys/posix/signal.d +++ b/libphobos/libdruntime/core/sys/posix/signal.d @@ -1142,10 +1142,10 @@ else version (FreeBSD) int sigdelset(sigset_t*, int); int sigemptyset(sigset_t *); int sigfillset(sigset_t *); - int sigismember(in sigset_t *, int); + int sigismember(in sigset_t*, int); int sigpending(sigset_t *); int sigprocmask(int, in sigset_t*, sigset_t*); - int sigsuspend(in sigset_t *); + int sigsuspend(in sigset_t*); int sigwait(in sigset_t*, int*); } else version (NetBSD) @@ -1228,10 +1228,10 @@ else version (NetBSD) int __sigdelset14(sigset_t*, int); int __sigemptyset14(sigset_t *); int __sigfillset14(sigset_t *); - int __sigismember14(in sigset_t *, int); + int __sigismember14(in sigset_t*, int); int __sigpending14(sigset_t *); int __sigprocmask14(int, in sigset_t*, sigset_t*); - int __sigsuspend14(in sigset_t *); + int __sigsuspend14(in sigset_t*); int sigwait(in sigset_t*, int*); alias __sigaction14 sigaction; @@ -1314,10 +1314,10 @@ else version (OpenBSD) int sigdelset(sigset_t*, int); int sigemptyset(sigset_t *); int sigfillset(sigset_t *); - int sigismember(in sigset_t *, int); + int sigismember(in sigset_t*, int); int sigpending(sigset_t *); int sigprocmask(int, in sigset_t*, sigset_t*); - int sigsuspend(in sigset_t *); + int sigsuspend(in sigset_t*); int sigwait(in sigset_t*, int*); } else version (DragonFlyBSD) @@ -1363,10 +1363,10 @@ else version (DragonFlyBSD) int sigdelset(sigset_t*, int); int sigemptyset(sigset_t *); int sigfillset(sigset_t *); - int sigismember(in sigset_t *, int); + int sigismember(in sigset_t*, int); int sigpending(sigset_t *); int sigprocmask(int, in sigset_t*, sigset_t*); - int sigsuspend(in sigset_t *); + int sigsuspend(in sigset_t*); int sigwait(in sigset_t*, int*); } else version (Solaris) @@ -3258,7 +3258,7 @@ else version (CRuntime_Musl) sigfn_t2 sigset(int sig, sigfn_t2 func); int killpg(pid_t, int); - int sigaltstack(const scope stack_t*, stack_t*); + int sigaltstack(in stack_t*, stack_t*); int sighold(int); int sigignore(int); int siginterrupt(int, int); diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d index 0c6a144f520..bc2329e6bf8 100644 --- a/libphobos/libdruntime/core/sys/posix/stdio.d +++ b/libphobos/libdruntime/core/sys/posix/stdio.d @@ -180,6 +180,37 @@ else version (CRuntime_UClibc) FILE* tmpfile(); } } +else version (CRuntime_Musl) +{ + static if ( __USE_FILE_OFFSET64 ) + { + int fgetpos64(FILE*, fpos_t *); + alias fgetpos64 fgetpos; + + FILE* fopen64(in char*, in char*); + alias fopen64 fopen; + + FILE* freopen64(in char*, in char*, FILE*); + alias freopen64 freopen; + + int fseek(FILE*, c_long, int); + + int fsetpos64(FILE*, in fpos_t*); + alias fsetpos64 fsetpos; + + FILE* tmpfile64(); + alias tmpfile64 tmpfile; + } + else + { + int fgetpos(FILE*, fpos_t *); + FILE* fopen(in char*, in char*); + FILE* freopen(in char*, in char*, FILE*); + int fseek(FILE*, c_long, int); + int fsetpos(FILE*, in fpos_t*); + FILE* tmpfile(); + } +} else version (Solaris) { static if (__USE_FILE_OFFSET64 && __WORDSIZE != 64) @@ -277,6 +308,30 @@ else version (CRuntime_UClibc) off_t ftello(FILE*); } } +else version (CRuntime_Musl) +{ + enum L_ctermid = 20; + + static if ( __USE_FILE_OFFSET64 ) + { + int fseeko64(FILE*, off_t, int); + alias fseeko64 fseeko; + } + else + { + int fseeko(FILE*, off_t, int); + } + + static if ( __USE_FILE_OFFSET64 ) + { + off_t ftello64(FILE*); + alias ftello64 ftello; + } + else + { + off_t ftello(FILE*); + } +} else version (Solaris) { enum L_ctermid = 9; @@ -331,6 +386,9 @@ else version (OpenBSD) // as of OpenBSD 5.4 version = HaveMemstream; else version (CRuntime_UClibc) version = HaveMemstream; +// http://git.musl-libc.org/cgit/musl/commit/src/stdio/open_memstream.c?id=b158b32a44d56ef20407d4285b58180447ffff1f +else version (CRuntime_Musl) + version = HaveMemstream; version (HaveMemstream) { diff --git a/libphobos/libdruntime/core/sys/posix/stdlib.d b/libphobos/libdruntime/core/sys/posix/stdlib.d index dcd302739c1..a218f958077 100644 --- a/libphobos/libdruntime/core/sys/posix/stdlib.d +++ b/libphobos/libdruntime/core/sys/posix/stdlib.d @@ -574,9 +574,45 @@ else version (CRuntime_Bionic) } else version (CRuntime_Musl) { - char* realpath(in char*, char*); + c_long a64l(in char*); + double drand48(); + char* ecvt(double, int, int *, int *); // LEGACY + double erand48(ref ushort[3]); + char* fcvt(double, int, int *, int *); // LEGACY + char* gcvt(double, int, char*); // LEGACY + int getsubopt(char**, in char**, char**); + int grantpt(int); + char* initstate(uint, char*, size_t); + c_long jrand48(ref ushort[3]); + char* l64a(c_long); + void lcong48(ref ushort[7]); + c_long lrand48(); + char* mktemp(char*); // LEGACY + char* mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition + int mkstemp(char*); + c_long mrand48(); + c_long nrand48(ref ushort[3]); + int posix_openpt(int); + char* ptsname(int); int putenv(char*); + c_long random(); + char* realpath(in char*, char*); + ushort *seed48(ref ushort[3]); + void setkey(in char*); + char* setstate(in char*); + void srand48(c_long); + void srandom(uint); + int unlockpt(int); + + static if ( __USE_LARGEFILE64 ) + { + int mkstemp64(char*); + alias mkstemp64 mkstemp; + } + else + { int mkstemp(char*); + } } else version (Solaris) diff --git a/libphobos/libdruntime/core/sys/posix/sys/filio.d b/libphobos/libdruntime/core/sys/posix/sys/filio.d index 0ca070b46ee..3574bc69ada 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/filio.d +++ b/libphobos/libdruntime/core/sys/posix/sys/filio.d @@ -8,11 +8,20 @@ module core.sys.posix.sys.filio; import core.sys.posix.sys.ioccom; +version (OSX) + version = Darwin; +else version (iOS) + version = Darwin; +else version (TVOS) + version = Darwin; +else version (WatchOS) + version = Darwin; + version (Posix): nothrow @nogc: -version (OSX) +version (Darwin) { // File-descriptor ioctl's enum uint FIOCLEX = _IO('f', 1); // set close on exec on fd diff --git a/libphobos/libdruntime/core/sys/posix/sys/ioccom.d b/libphobos/libdruntime/core/sys/posix/sys/ioccom.d index 424c8a82307..51f1d2272aa 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/ioccom.d +++ b/libphobos/libdruntime/core/sys/posix/sys/ioccom.d @@ -6,11 +6,20 @@ module core.sys.posix.sys.ioccom; +version (OSX) + version = Darwin; +else version (iOS) + version = Darwin; +else version (TVOS) + version = Darwin; +else version (WatchOS) + version = Darwin; + version (Posix): nothrow @nogc: -version (OSX) +version (Darwin) { /* OSX ioctl's (based on FreeBSD) encode the command in the lower 16-bits * and the size of any in/out parameters in the lower 13 bits of the upper diff --git a/libphobos/libdruntime/core/sys/posix/sys/resource.d b/libphobos/libdruntime/core/sys/posix/sys/resource.d index 27a7ed28852..56a8fd428e8 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/resource.d +++ b/libphobos/libdruntime/core/sys/posix/sys/resource.d @@ -525,6 +525,7 @@ else version (CRuntime_Bionic) else version (CRuntime_Musl) { alias ulong rlim_t; + enum RLIM_INFINITY = cast(c_ulong)(~0UL); int getrlimit(int, rlimit*); int setrlimit(int, in rlimit*); diff --git a/libphobos/libdruntime/core/sys/posix/sys/select.d b/libphobos/libdruntime/core/sys/posix/sys/select.d index 2508366d69c..83e47582f84 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/select.d +++ b/libphobos/libdruntime/core/sys/posix/sys/select.d @@ -15,7 +15,6 @@ public import core.sys.posix.sys.types; // for time_t public import core.sys.posix.signal; // for sigset_t //debug=select; // uncomment to turn on debugging printf's -version (unittest) import core.stdc.stdio: printf; version (OSX) version = Darwin; @@ -560,6 +559,8 @@ else pure unittest { + import core.stdc.stdio: printf; + debug(select) printf("core.sys.posix.sys.select unittest\n"); fd_set fd; diff --git a/libphobos/libdruntime/core/sys/posix/sys/socket.d b/libphobos/libdruntime/core/sys/posix/sys/socket.d index 0732a48ab88..05f52fc76af 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/socket.d +++ b/libphobos/libdruntime/core/sys/posix/sys/socket.d @@ -571,8 +571,8 @@ version (CRuntime_Glibc) } int accept(int, scope sockaddr*, scope socklen_t*); - int bind(int, const scope sockaddr*, socklen_t); - int connect(int, const scope sockaddr*, socklen_t); + int bind(int, in sockaddr*, socklen_t); + int connect(int, in sockaddr*, socklen_t); int getpeername(int, scope sockaddr*, scope socklen_t*); int getsockname(int, scope sockaddr*, scope socklen_t*); int getsockopt(int, int, int, scope void*, scope socklen_t*); @@ -580,10 +580,10 @@ version (CRuntime_Glibc) ssize_t recv(int, scope void*, size_t, int); ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*); ssize_t recvmsg(int, scope msghdr*, int); - ssize_t send(int, const scope void*, size_t, int); - ssize_t sendmsg(int, const scope msghdr*, int); - ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t); - int setsockopt(int, int, int, const scope void*, socklen_t); + ssize_t send(int, in void*, size_t, int); + ssize_t sendmsg(int, in msghdr*, int); + ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t); + int setsockopt(int, int, int, in void*, socklen_t); int shutdown(int, int) @safe; int socket(int, int, int) @safe; int sockatmark(int) @safe; @@ -727,8 +727,8 @@ else version (Darwin) } int accept(int, scope sockaddr*, scope socklen_t*); - int bind(int, const scope sockaddr*, socklen_t); - int connect(int, const scope sockaddr*, socklen_t); + int bind(int, in sockaddr*, socklen_t); + int connect(int, in sockaddr*, socklen_t); int getpeername(int, scope sockaddr*, scope socklen_t*); int getsockname(int, scope sockaddr*, scope socklen_t*); int getsockopt(int, int, int, scope void*, scope socklen_t*); @@ -736,10 +736,10 @@ else version (Darwin) ssize_t recv(int, scope void*, size_t, int); ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*); ssize_t recvmsg(int, scope msghdr*, int); - ssize_t send(int, const scope void*, size_t, int); - ssize_t sendmsg(int, const scope msghdr*, int); - ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t); - int setsockopt(int, int, int, const scope void*, socklen_t); + ssize_t send(int, in void*, size_t, int); + ssize_t sendmsg(int, in msghdr*, int); + ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t); + int setsockopt(int, int, int, in void*, socklen_t); int shutdown(int, int) @safe; int socket(int, int, int) @safe; int sockatmark(int) @safe; @@ -904,8 +904,8 @@ else version (FreeBSD) } int accept(int, scope sockaddr*, scope socklen_t*); - int bind(int, const scope sockaddr*, socklen_t); - int connect(int, const scope sockaddr*, socklen_t); + int bind(int, in sockaddr*, socklen_t); + int connect(int, in sockaddr*, socklen_t); int getpeername(int, scope sockaddr*, scope socklen_t*); int getsockname(int, scope sockaddr*, scope socklen_t*); int getsockopt(int, int, int, scope void*, scope socklen_t*); @@ -913,10 +913,10 @@ else version (FreeBSD) ssize_t recv(int, scope void*, size_t, int); ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*); ssize_t recvmsg(int, scope msghdr*, int); - ssize_t send(int, const scope void*, size_t, int); - ssize_t sendmsg(int, const scope msghdr*, int); - ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t); - int setsockopt(int, int, int, const scope void*, socklen_t); + ssize_t send(int, in void*, size_t, int); + ssize_t sendmsg(int, in msghdr*, int); + ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t); + int setsockopt(int, int, int, in void*, socklen_t); int shutdown(int, int) @safe; int socket(int, int, int) @safe; int sockatmark(int) @safe; @@ -1101,8 +1101,8 @@ else version (NetBSD) } int accept(int, scope sockaddr*, scope socklen_t*); - int bind(int, const scope sockaddr*, socklen_t); - int connect(int, const scope sockaddr*, socklen_t); + int bind(int, in sockaddr*, socklen_t); + int connect(int, in sockaddr*, socklen_t); int getpeername(int, scope sockaddr*, scope socklen_t*); int getsockname(int, scope sockaddr*, scope socklen_t*); int getsockopt(int, int, int, scope void*, scope socklen_t*); @@ -1110,10 +1110,10 @@ else version (NetBSD) ssize_t recv(int, scope void*, size_t, int); ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*); ssize_t recvmsg(int, scope msghdr*, int); - ssize_t send(int, const scope void*, size_t, int); - ssize_t sendmsg(int, const scope msghdr*, int); - ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t); - int setsockopt(int, int, int, const scope void*, socklen_t); + ssize_t send(int, in void*, size_t, int); + ssize_t sendmsg(int, in msghdr*, int); + ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t); + int setsockopt(int, int, int, in void*, socklen_t); int shutdown(int, int) @safe; int socket(int, int, int) @safe; int sockatmark(int) @safe; @@ -1274,8 +1274,8 @@ else version (OpenBSD) } int accept(int, scope sockaddr*, scope socklen_t*); - int bind(int, const scope sockaddr*, socklen_t); - int connect(int, const scope sockaddr*, socklen_t); + int bind(int, in sockaddr*, socklen_t); + int connect(int, in sockaddr*, socklen_t); int getpeername(int, scope sockaddr*, scope socklen_t*); int getsockname(int, scope sockaddr*, scope socklen_t*); int getsockopt(int, int, int, scope void*, scope socklen_t*); @@ -1283,10 +1283,10 @@ else version (OpenBSD) ssize_t recv(int, scope void*, size_t, int); ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*); ssize_t recvmsg(int, scope msghdr*, int); - ssize_t send(int, const scope void*, size_t, int); - ssize_t sendmsg(int, const scope msghdr*, int); - ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t); - int setsockopt(int, int, int, const scope void*, socklen_t); + ssize_t send(int, in void*, size_t, int); + ssize_t sendmsg(int, in msghdr*, int); + ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t); + int setsockopt(int, int, int, in void*, socklen_t); int shutdown(int, int) @safe; int socket(int, int, int) @safe; int sockatmark(int) @safe; @@ -1655,8 +1655,8 @@ else version (Solaris) } int accept(int, scope sockaddr*, scope socklen_t*); - int bind(int, const scope sockaddr*, socklen_t); - int connect(int, const scope sockaddr*, socklen_t); + int bind(int, in sockaddr*, socklen_t); + int connect(int, in sockaddr*, socklen_t); int getpeername(int, scope sockaddr*, scope socklen_t*); int getsockname(int, scope sockaddr*, scope socklen_t*); int getsockopt(int, int, int, scope void*, scope socklen_t*); @@ -1664,10 +1664,10 @@ else version (Solaris) ssize_t recv(int, scope void*, size_t, int); ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*); ssize_t recvmsg(int, scope msghdr*, int); - ssize_t send(int, const scope void*, size_t, int); - ssize_t sendmsg(int, const scope msghdr*, int); - ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t); - int setsockopt(int, int, int, const scope void*, socklen_t); + ssize_t send(int, in void*, size_t, int); + ssize_t sendmsg(int, in msghdr*, int); + ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t); + int setsockopt(int, int, int, in void*, socklen_t); int shutdown(int, int) @safe; int socket(int, int, int) @safe; int sockatmark(int) @safe; @@ -1816,8 +1816,8 @@ else version (CRuntime_Bionic) enum SOCK_RDM = 4; int accept(int, scope sockaddr*, scope socklen_t*); - int bind(int, const scope sockaddr*, socklen_t); - int connect(int, const scope sockaddr*, socklen_t); + int bind(int, in sockaddr*, socklen_t); + int connect(int, in sockaddr*, socklen_t); int getpeername(int, scope sockaddr*, scope socklen_t*); int getsockname(int, scope sockaddr*, scope socklen_t*); int getsockopt(int, int, int, scope void*, scope socklen_t*); @@ -1825,10 +1825,10 @@ else version (CRuntime_Bionic) ssize_t recv(int, scope void*, size_t, int); ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*); int recvmsg(int, scope msghdr*, int); - ssize_t send(int, const scope void*, size_t, int); - int sendmsg(int, const scope msghdr*, int); - ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t); - int setsockopt(int, int, int, const scope void*, socklen_t); + ssize_t send(int, in void*, size_t, int); + int sendmsg(int, in msghdr*, int); + ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t); + int setsockopt(int, int, int, in void*, socklen_t); int shutdown(int, int) @safe; int socket(int, int, int) @safe; int sockatmark(int) @safe; diff --git a/libphobos/libdruntime/core/sys/posix/sys/stat.d b/libphobos/libdruntime/core/sys/posix/sys/stat.d index 52b51bd3c71..b0d57f28ee6 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/stat.d +++ b/libphobos/libdruntime/core/sys/posix/sys/stat.d @@ -1391,7 +1391,6 @@ else version (Solaris) dev_t st_rdev; c_long[2] st_pad2; off_t st_size; - c_long st_pad3; union { timestruc_t st_atim; diff --git a/libphobos/libdruntime/core/sys/posix/sys/ttycom.d b/libphobos/libdruntime/core/sys/posix/sys/ttycom.d index d1530979cca..38abb2fcf86 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/ttycom.d +++ b/libphobos/libdruntime/core/sys/posix/sys/ttycom.d @@ -10,11 +10,20 @@ import core.sys.posix.sys.ioccom; import core.sys.posix.termios; import core.sys.posix.sys.time; +version (OSX) + version = Darwin; +else version (iOS) + version = Darwin; +else version (TVOS) + version = Darwin; +else version (WatchOS) + version = Darwin; + version (Posix): nothrow @nogc: -version (OSX) +version (Darwin) { struct winsize { ushort ws_row; // rows, in characters diff --git a/libphobos/libdruntime/core/sys/posix/sys/types.d b/libphobos/libdruntime/core/sys/posix/sys/types.d index 169287c3bec..451c8b4fccc 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/types.d +++ b/libphobos/libdruntime/core/sys/posix/sys/types.d @@ -852,7 +852,7 @@ else version (Darwin) { version (D_LP64) { - enum __PTHREAD_SIZE__ = 1168; + enum __PTHREAD_SIZE__ = 8176; enum __PTHREAD_ATTR_SIZE__ = 56; enum __PTHREAD_MUTEXATTR_SIZE__ = 8; enum __PTHREAD_MUTEX_SIZE__ = 56; @@ -864,7 +864,7 @@ else version (Darwin) } else { - enum __PTHREAD_SIZE__ = 596; + enum __PTHREAD_SIZE__ = 4088; enum __PTHREAD_ATTR_SIZE__ = 36; enum __PTHREAD_MUTEXATTR_SIZE__ = 8; enum __PTHREAD_MUTEX_SIZE__ = 40; diff --git a/libphobos/libdruntime/core/sys/posix/sys/uio.d b/libphobos/libdruntime/core/sys/posix/sys/uio.d index c115bf17660..df34ef35c2a 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/uio.d +++ b/libphobos/libdruntime/core/sys/posix/sys/uio.d @@ -138,8 +138,8 @@ else version (CRuntime_Musl) { struct iovec { - void* iov_base; - uint iov_len; + void* iov_base; + size_t iov_len; } ssize_t readv(int, in iovec*, int); diff --git a/libphobos/libdruntime/core/sys/posix/syslog.d b/libphobos/libdruntime/core/sys/posix/syslog.d index 64548fb0563..a319b01bd0d 100644 --- a/libphobos/libdruntime/core/sys/posix/syslog.d +++ b/libphobos/libdruntime/core/sys/posix/syslog.d @@ -526,3 +526,63 @@ else version (CRuntime_UClibc) void syslog (int __pri, const char *__fmt, ...); void closelog(); } +else version (CRuntime_Musl) +{ + //PRIORITY + enum { + LOG_EMERG = 0, /* system is unusable */ + LOG_ALERT = 1, /* action must be taken immediately */ + LOG_CRIT = 2, /* critical conditions */ + LOG_ERR = 3, /* error conditions */ + LOG_WARNING = 4, /* warning conditions */ + LOG_NOTICE = 5, /* normal but significant condition */ + LOG_INFO = 6, /* informational */ + LOG_DEBUG = 7, /* debug-level messages */ + }; + + //OPTIONS + enum { + LOG_PID = 0x01, /* log the pid with each message */ + LOG_CONS = 0x02, /* log on the console if errors in sending */ + LOG_ODELAY = 0x04, /* delay open until first syslog() (default) */ + LOG_NDELAY = 0x08, /* don't delay open */ + LOG_NOWAIT = 0x10, /* don't wait for console forks: DEPRECATED */ + LOG_PERROR = 0x20, /* log to stderr as well */ + }; + + //FACILITY + enum { + LOG_KERN = (0<<3), /* kernel messages */ + LOG_USER = (1<<3), /* random user-level messages */ + LOG_MAIL = (2<<3), /* mail system */ + LOG_DAEMON = (3<<3), /* system daemons */ + LOG_AUTH = (4<<3), /* security/authorization messages */ + LOG_SYSLOG = (5<<3), /* messages generated internally by syslogd */ + LOG_LPR = (6<<3), /* line printer subsystem */ + LOG_NEWS = (7<<3), /* network news subsystem */ + LOG_UUCP = (8<<3), /* UUCP subsystem */ + LOG_CRON = (9<<3), /* clock daemon */ + LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */ + LOG_FTP = (11<<3), /* ftp daemon */ + + /* other codes through 15 reserved for system use */ + LOG_LOCAL0 = (16<<3), /* reserved for local use */ + LOG_LOCAL1 = (17<<3), /* reserved for local use */ + LOG_LOCAL2 = (18<<3), /* reserved for local use */ + LOG_LOCAL3 = (19<<3), /* reserved for local use */ + LOG_LOCAL4 = (20<<3), /* reserved for local use */ + LOG_LOCAL5 = (21<<3), /* reserved for local use */ + LOG_LOCAL6 = (22<<3), /* reserved for local use */ + LOG_LOCAL7 = (23<<3), /* reserved for local use */ + + LOG_NFACILITIES = 24, /* current number of facilities */ + }; + + int LOG_MASK(int pri) { return 1 << pri; } /* mask for one priority */ + int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; } /* all priorities through pri */ + + void openlog (const char *, int __option, int __facility); + int setlogmask (int __mask); + void syslog (int __pri, const char *__fmt, ...); + void closelog(); +} diff --git a/libphobos/libdruntime/core/sys/posix/time.d b/libphobos/libdruntime/core/sys/posix/time.d index 2859558b2b9..82a3f199247 100644 --- a/libphobos/libdruntime/core/sys/posix/time.d +++ b/libphobos/libdruntime/core/sys/posix/time.d @@ -624,6 +624,9 @@ else version (CRuntime_Bionic) } else version (CRuntime_Musl) { + extern __gshared int daylight; + extern __gshared c_long timezone; + tm* getdate(in char*); char* strptime(in char*, in char*, tm*); } diff --git a/libphobos/libdruntime/core/sys/posix/unistd.d b/libphobos/libdruntime/core/sys/posix/unistd.d index 6e035e54502..418d63d439b 100644 --- a/libphobos/libdruntime/core/sys/posix/unistd.d +++ b/libphobos/libdruntime/core/sys/posix/unistd.d @@ -1342,9 +1342,162 @@ else version (CRuntime_Bionic) enum W_OK = 2; enum X_OK = 1; - enum _SC_PAGESIZE = 0x0027; - enum _SC_NPROCESSORS_ONLN = 0x0061; - enum _SC_THREAD_STACK_MIN = 0x004c; + enum + { + _SC_ARG_MAX = 0x0000, + _SC_BC_BASE_MAX = 0x0001, + _SC_BC_DIM_MAX = 0x0002, + _SC_BC_SCALE_MAX = 0x0003, + _SC_BC_STRING_MAX = 0x0004, + _SC_CHILD_MAX = 0x0005, + _SC_CLK_TCK = 0x0006, + _SC_COLL_WEIGHTS_MAX = 0x0007, + _SC_EXPR_NEST_MAX = 0x0008, + _SC_LINE_MAX = 0x0009, + _SC_NGROUPS_MAX = 0x000a, + _SC_OPEN_MAX = 0x000b, + _SC_PASS_MAX = 0x000c, + _SC_2_C_BIND = 0x000d, + _SC_2_C_DEV = 0x000e, + _SC_2_C_VERSION = 0x000f, + _SC_2_CHAR_TERM = 0x0010, + _SC_2_FORT_DEV = 0x0011, + _SC_2_FORT_RUN = 0x0012, + _SC_2_LOCALEDEF = 0x0013, + _SC_2_SW_DEV = 0x0014, + _SC_2_UPE = 0x0015, + _SC_2_VERSION = 0x0016, + _SC_JOB_CONTROL = 0x0017, + _SC_SAVED_IDS = 0x0018, + _SC_VERSION = 0x0019, + _SC_RE_DUP_MAX = 0x001a, + _SC_STREAM_MAX = 0x001b, + _SC_TZNAME_MAX = 0x001c, + _SC_XOPEN_CRYPT = 0x001d, + _SC_XOPEN_ENH_I18N = 0x001e, + _SC_XOPEN_SHM = 0x001f, + _SC_XOPEN_VERSION = 0x0020, + _SC_XOPEN_XCU_VERSION = 0x0021, + _SC_XOPEN_REALTIME = 0x0022, + _SC_XOPEN_REALTIME_THREADS = 0x0023, + _SC_XOPEN_LEGACY = 0x0024, + _SC_ATEXIT_MAX = 0x0025, + _SC_IOV_MAX = 0x0026, + _SC_UIO_MAXIOV = _SC_IOV_MAX, + _SC_PAGESIZE = 0x0027, + _SC_PAGE_SIZE = 0x0028, + _SC_XOPEN_UNIX = 0x0029, + _SC_XBS5_ILP32_OFF32 = 0x002a, + _SC_XBS5_ILP32_OFFBIG = 0x002b, + _SC_XBS5_LP64_OFF64 = 0x002c, + _SC_XBS5_LPBIG_OFFBIG = 0x002d, + _SC_AIO_LISTIO_MAX = 0x002e, + _SC_AIO_MAX = 0x002f, + _SC_AIO_PRIO_DELTA_MAX = 0x0030, + _SC_DELAYTIMER_MAX = 0x0031, + _SC_MQ_OPEN_MAX = 0x0032, + _SC_MQ_PRIO_MAX = 0x0033, + _SC_RTSIG_MAX = 0x0034, + _SC_SEM_NSEMS_MAX = 0x0035, + _SC_SEM_VALUE_MAX = 0x0036, + _SC_SIGQUEUE_MAX = 0x0037, + _SC_TIMER_MAX = 0x0038, + _SC_ASYNCHRONOUS_IO = 0x0039, + _SC_FSYNC = 0x003a, + _SC_MAPPED_FILES = 0x003b, + _SC_MEMLOCK = 0x003c, + _SC_MEMLOCK_RANGE = 0x003d, + _SC_MEMORY_PROTECTION = 0x003e, + _SC_MESSAGE_PASSING = 0x003f, + _SC_PRIORITIZED_IO = 0x0040, + _SC_PRIORITY_SCHEDULING = 0x0041, + _SC_REALTIME_SIGNALS = 0x0042, + _SC_SEMAPHORES = 0x0043, + _SC_SHARED_MEMORY_OBJECTS = 0x0044, + _SC_SYNCHRONIZED_IO = 0x0045, + _SC_TIMERS = 0x0046, + _SC_GETGR_R_SIZE_MAX = 0x0047, + _SC_GETPW_R_SIZE_MAX = 0x0048, + _SC_LOGIN_NAME_MAX = 0x0049, + _SC_THREAD_DESTRUCTOR_ITERATIONS = 0x004a, + _SC_THREAD_KEYS_MAX = 0x004b, + _SC_THREAD_STACK_MIN = 0x004c, + _SC_THREAD_THREADS_MAX = 0x004d, + _SC_TTY_NAME_MAX = 0x004e, + + _SC_THREADS = 0x004f, + _SC_THREAD_ATTR_STACKADDR = 0x0050, + _SC_THREAD_ATTR_STACKSIZE = 0x0051, + _SC_THREAD_PRIORITY_SCHEDULING = 0x0052, + _SC_THREAD_PRIO_INHERIT = 0x0053, + _SC_THREAD_PRIO_PROTECT = 0x0054, + _SC_THREAD_SAFE_FUNCTIONS = 0x0055, + + _SC_NPROCESSORS_CONF = 0x0060, + _SC_NPROCESSORS_ONLN = 0x0061, + _SC_PHYS_PAGES = 0x0062, + _SC_AVPHYS_PAGES = 0x0063, + _SC_MONOTONIC_CLOCK = 0x0064, + + _SC_2_PBS = 0x0065, + _SC_2_PBS_ACCOUNTING = 0x0066, + _SC_2_PBS_CHECKPOINT = 0x0067, + _SC_2_PBS_LOCATE = 0x0068, + _SC_2_PBS_MESSAGE = 0x0069, + _SC_2_PBS_TRACK = 0x006a, + _SC_ADVISORY_INFO = 0x006b, + _SC_BARRIERS = 0x006c, + _SC_CLOCK_SELECTION = 0x006d, + _SC_CPUTIME = 0x006e, + _SC_HOST_NAME_MAX = 0x006f, + _SC_IPV6 = 0x0070, + _SC_RAW_SOCKETS = 0x0071, + _SC_READER_WRITER_LOCKS = 0x0072, + _SC_REGEXP = 0x0073, + _SC_SHELL = 0x0074, + _SC_SPAWN = 0x0075, + _SC_SPIN_LOCKS = 0x0076, + _SC_SPORADIC_SERVER = 0x0077, + _SC_SS_REPL_MAX = 0x0078, + _SC_SYMLOOP_MAX = 0x0079, + _SC_THREAD_CPUTIME = 0x007a, + _SC_THREAD_PROCESS_SHARED = 0x007b, + _SC_THREAD_ROBUST_PRIO_INHERIT = 0x007c, + _SC_THREAD_ROBUST_PRIO_PROTECT = 0x007d, + _SC_THREAD_SPORADIC_SERVER = 0x007e, + _SC_TIMEOUTS = 0x007f, + _SC_TRACE = 0x0080, + _SC_TRACE_EVENT_FILTER = 0x0081, + _SC_TRACE_EVENT_NAME_MAX = 0x0082, + _SC_TRACE_INHERIT = 0x0083, + _SC_TRACE_LOG = 0x0084, + _SC_TRACE_NAME_MAX = 0x0085, + _SC_TRACE_SYS_MAX = 0x0086, + _SC_TRACE_USER_EVENT_MAX = 0x0087, + _SC_TYPED_MEMORY_OBJECTS = 0x0088, + _SC_V7_ILP32_OFF32 = 0x0089, + _SC_V7_ILP32_OFFBIG = 0x008a, + _SC_V7_LP64_OFF64 = 0x008b, + _SC_V7_LPBIG_OFFBIG = 0x008c, + _SC_XOPEN_STREAMS = 0x008d, + _SC_XOPEN_UUCP = 0x008e, + + _SC_LEVEL1_ICACHE_SIZE = 0x008f, + _SC_LEVEL1_ICACHE_ASSOC = 0x0090, + _SC_LEVEL1_ICACHE_LINESIZE = 0x0091, + _SC_LEVEL1_DCACHE_SIZE = 0x0092, + _SC_LEVEL1_DCACHE_ASSOC = 0x0093, + _SC_LEVEL1_DCACHE_LINESIZE = 0x0094, + _SC_LEVEL2_CACHE_SIZE = 0x0095, + _SC_LEVEL2_CACHE_ASSOC = 0x0096, + _SC_LEVEL2_CACHE_LINESIZE = 0x0097, + _SC_LEVEL3_CACHE_SIZE = 0x0098, + _SC_LEVEL3_CACHE_ASSOC = 0x0099, + _SC_LEVEL3_CACHE_LINESIZE = 0x009a, + _SC_LEVEL4_CACHE_SIZE = 0x009b, + _SC_LEVEL4_CACHE_ASSOC = 0x009c, + _SC_LEVEL4_CACHE_LINESIZE = 0x009d, + } } else version (Solaris) { @@ -2403,7 +2556,7 @@ else version (OpenBSD) { char* crypt(in char*, in char*); //char* ctermid(char*); - void encrypt(ref char[64], int) @trusted; + //void encrypt(ref char[64], int) @trusted; int fchdir(int) @trusted; c_long gethostid() @trusted; pid_t getpgid(pid_t) @trusted;