diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2022-06-22 17:03:33 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2022-06-22 17:57:56 +0200 |
commit | 445d8deffb6c9bc1f4a5ed0a8e02d7f31d3caec7 (patch) | |
tree | 4b9aa4224d827abfe081adf2289af34436d3e552 /libphobos/libdruntime | |
parent | d844478ab47a16c8ae65f253fd1cdc685c7951fc (diff) | |
download | gcc-445d8deffb6c9bc1f4a5ed0a8e02d7f31d3caec7.zip gcc-445d8deffb6c9bc1f4a5ed0a8e02d7f31d3caec7.tar.gz gcc-445d8deffb6c9bc1f4a5ed0a8e02d7f31d3caec7.tar.bz2 |
d: Merge upstream dmd 6203135dc, druntime e150cca1, phobos a4a18d21c.
D front-end changes:
- Input parameters can now be applied on extern(C++) functions to
bind to `const &' when the `-fpreview=in' flag is in effect.
D runtime changes:
- Run-time flag `--DRT-oncycle=deprecate' has been removed.
Phobos changes:
- Removed std.experimental.logger's capability to set the minimal
LogLevel at compile time.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd 6203135dc.
* typeinfo.cc (TypeInfoVisitor::visit (TypeInfoStructDeclaration *)):
Update for new front-end interface.
(SpeculativeTypeVisitor::visit (TypeStruct *)): Likewise.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime e150cca1.
* src/MERGE: Merge upstream phobos a4a18d21c.
* testsuite/libphobos.cycles/cycles.exp (cycle_test_list): Update
expected result of deprecate test.
Diffstat (limited to 'libphobos/libdruntime')
20 files changed, 433 insertions, 239 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index 8b2839d..3f4a0ec 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -454471d8077d12ec6bf0ae8fcd9571aad1bce7be +e150cca179515ce5113e828aac94c20c0b983b7c 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/core/stdc/config.d b/libphobos/libdruntime/core/stdc/config.d index 037af25..c576e99 100644 --- a/libphobos/libdruntime/core/stdc/config.d +++ b/libphobos/libdruntime/core/stdc/config.d @@ -185,6 +185,37 @@ else version (Posix) alias ulong cpp_ulonglong; } } +else version (WASI) +{ + static if ( (void*).sizeof > int.sizeof ) + { + enum __c_longlong : long; + enum __c_ulonglong : ulong; + + alias long c_long; + alias ulong c_ulong; + + alias long cpp_long; + alias ulong cpp_ulong; + + alias __c_longlong cpp_longlong; + alias __c_ulonglong cpp_ulonglong; + } + else + { + enum __c_long : int; + enum __c_ulong : uint; + + alias int c_long; + alias uint c_ulong; + + alias __c_long cpp_long; + alias __c_ulong cpp_ulong; + + alias long cpp_longlong; + alias ulong cpp_ulonglong; + } +} version (GNU) alias c_long_double = real; diff --git a/libphobos/libdruntime/core/stdc/errno.d b/libphobos/libdruntime/core/stdc/errno.d index 57bc15d..24b4138 100644 --- a/libphobos/libdruntime/core/stdc/errno.d +++ b/libphobos/libdruntime/core/stdc/errno.d @@ -2079,6 +2079,143 @@ else version (Haiku) enum B_NO_TRANSLATOR = (B_TRANSLATION_ERROR_BASE + 1); enum B_ILLEGAL_DATA = (B_TRANSLATION_ERROR_BASE + 2); } +else version (WASI) +{ + enum EPERM = 1; + enum ENOENT = 2; + enum ESRCH = 3; + enum EINTR = 4; + enum EIO = 5; + enum ENXIO = 6; + enum E2BIG = 7; + enum ENOEXEC = 8; + enum EBADF = 9; + enum ECHILD = 10; + enum EAGAIN = 11; + enum ENOMEM = 12; + enum EACCES = 13; + enum EFAULT = 14; + enum ENOTBLK = 15; + enum EBUSY = 16; + enum EEXIST = 17; + enum EXDEV = 18; + enum ENODEV = 19; + enum ENOTDIR = 20; + enum EISDIR = 21; + enum EINVAL = 22; + enum ENFILE = 23; + enum EMFILE = 24; + enum ENOTTY = 25; + enum ETXTBSY = 26; + enum EFBIG = 27; + enum ENOSPC = 28; + enum ESPIPE = 29; + enum EROFS = 30; + enum EMLINK = 31; + enum EPIPE = 32; + enum EDOM = 33; + enum ERANGE = 34; + enum EDEADLK = 35; + enum ENAMETOOLONG = 36; + enum ENOLCK = 37; + enum ENOSYS = 38; + enum ENOTEMPTY = 39; + enum ELOOP = 40; + enum EWOULDBLOCK = EAGAIN; + enum ENOMSG = 42; + enum EIDRM = 43; + enum ECHRNG = 44; + enum EL2NSYNC = 45; + enum EL3HLT = 46; + enum EL3RST = 47; + enum ELNRNG = 48; + enum EUNATCH = 49; + enum ENOCSI = 50; + enum EL2HLT = 51; + enum EBADE = 52; + enum EBADR = 53; + enum EXFULL = 54; + enum ENOANO = 55; + enum EBADRQC = 56; + enum EBADSLT = 57; + enum EDEADLOCK = EDEADLK; + enum EBFONT = 59; + enum ENOSTR = 60; + enum ENODATA = 61; + enum ETIME = 62; + enum ENOSR = 63; + enum ENONET = 64; + enum ENOPKG = 65; + enum EREMOTE = 66; + enum ENOLINK = 67; + enum EADV = 68; + enum ESRMNT = 69; + enum ECOMM = 70; + enum EPROTO = 71; + enum EMULTIHOP = 72; + enum EDOTDOT = 73; + enum EBADMSG = 74; + enum EOVERFLOW = 75; + enum ENOTUNIQ = 76; + enum EBADFD = 77; + enum EREMCHG = 78; + enum ELIBACC = 79; + enum ELIBBAD = 80; + enum ELIBSCN = 81; + enum ELIBMAX = 82; + enum ELIBEXEC = 83; + enum EILSEQ = 84; + enum ERESTART = 85; + enum ESTRPIPE = 86; + enum EUSERS = 87; + enum ENOTSOCK = 88; + enum EDESTADDRREQ = 89; + enum EMSGSIZE = 90; + enum EPROTOTYPE = 91; + enum ENOPROTOOPT = 92; + enum EPROTONOSUPPORT = 93; + enum ESOCKTNOSUPPORT = 94; + enum EOPNOTSUPP = 95; + enum ENOTSUP = EOPNOTSUPP; + enum EPFNOSUPPORT = 96; + enum EAFNOSUPPORT = 97; + enum EADDRINUSE = 98; + enum EADDRNOTAVAIL = 99; + enum ENETDOWN = 100; + enum ENETUNREACH = 101; + enum ENETRESET = 102; + enum ECONNABORTED = 103; + enum ECONNRESET = 104; + enum ENOBUFS = 105; + enum EISCONN = 106; + enum ENOTCONN = 107; + enum ESHUTDOWN = 108; + enum ETOOMANYREFS = 109; + enum ETIMEDOUT = 110; + enum ECONNREFUSED = 111; + enum EHOSTDOWN = 112; + enum EHOSTUNREACH = 113; + enum EALREADY = 114; + enum EINPROGRESS = 115; + enum ESTALE = 116; + enum EUCLEAN = 117; + enum ENOTNAM = 118; + enum ENAVAIL = 119; + enum EISNAM = 120; + enum EREMOTEIO = 121; + enum EDQUOT = 122; + enum ENOMEDIUM = 123; + enum EMEDIUMTYPE = 124; + enum ECANCELED = 125; + enum ENOKEY = 126; + enum EKEYEXPIRED = 127; + enum EKEYREVOKED = 128; + enum EKEYREJECTED = 129; + enum EOWNERDEAD = 130; + enum ENOTRECOVERABLE = 131; + enum ERFKILL = 132; + enum EHWPOISON = 133; +} else { static assert(false, "Unsupported platform"); diff --git a/libphobos/libdruntime/core/stdc/stdarg.d b/libphobos/libdruntime/core/stdc/stdarg.d index 9a67f2e..646905e 100644 --- a/libphobos/libdruntime/core/stdc/stdarg.d +++ b/libphobos/libdruntime/core/stdc/stdarg.d @@ -47,6 +47,8 @@ version (MIPS32) version = MIPS_Any; version (MIPS64) version = MIPS_Any; version (PPC) version = PPC_Any; version (PPC64) version = PPC_Any; +version (RISCV32) version = RISCV_Any; +version (RISCV64) version = RISCV_Any; version (GNU) { @@ -130,6 +132,12 @@ else version (AAPCS64) { alias va_list = core.internal.vararg.aarch64.va_list; } +else version (RISCV_Any) +{ + // The va_list type is void*, according to RISCV Calling Convention + // https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc + alias va_list = void*; +} else { alias va_list = char*; // incl. unknown platforms @@ -259,6 +267,19 @@ T va_arg(T)(ref va_list ap) ap += T.sizeof.alignUp; return *p; } + else version (RISCV_Any) + { + static if (T.sizeof > (size_t.sizeof << 1)) + auto p = *cast(T**) ap; + else + { + static if (T.alignof == (size_t.sizeof << 1)) + ap = ap.alignUp!(size_t.sizeof << 1); + auto p = cast(T*) ap; + } + ap += T.sizeof.alignUp; + return *p; + } else static assert(0, "Unsupported platform"); } diff --git a/libphobos/libdruntime/core/stdc/stddef.d b/libphobos/libdruntime/core/stdc/stddef.d index 1d1d962..56b3c9b 100644 --- a/libphobos/libdruntime/core/stdc/stddef.d +++ b/libphobos/libdruntime/core/stdc/stddef.d @@ -34,3 +34,8 @@ else version (Posix) /// alias dchar wchar_t; } +else version (WASI) +{ + /// + alias dchar wchar_t; +} diff --git a/libphobos/libdruntime/core/stdc/stdint.d b/libphobos/libdruntime/core/stdc/stdint.d index 556ac01..476c42f 100644 --- a/libphobos/libdruntime/core/stdc/stdint.d +++ b/libphobos/libdruntime/core/stdc/stdint.d @@ -377,6 +377,41 @@ else version (Solaris) alias intmax_t = long; /// alias uintmax_t = ulong; /// } +else version (WASI) +{ + alias int8_t = byte; /// + alias int16_t = short; /// + alias uint8_t = ubyte; /// + alias uint16_t = ushort; /// + alias int32_t = int; /// + alias uint32_t = uint; /// + alias int64_t = long; /// + alias uint64_t = ulong; /// + + alias int_least8_t = byte; /// + alias uint_least8_t = ubyte; /// + alias int_least16_t = short; /// + alias uint_least16_t = ushort; /// + alias int_least32_t = int; /// + alias uint_least32_t = uint; /// + alias int_least64_t = long; /// + alias uint_least64_t = ulong; /// + + alias int_fast8_t = byte; /// + alias uint_fast8_t = ubyte; /// + alias int_fast16_t = ptrdiff_t; /// + alias uint_fast16_t = size_t; /// + alias int_fast32_t = ptrdiff_t; /// + alias uint_fast32_t = size_t; /// + + alias int_fast64_t = long; /// + alias uint_fast64_t = ulong; /// + + alias intptr_t = ptrdiff_t; /// + alias uintptr_t = size_t; /// + alias intmax_t = long; /// + alias uintmax_t = ulong; /// +} else { static assert(false, "Unsupported architecture."); diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d index cd53f0a..2e83811 100644 --- a/libphobos/libdruntime/core/stdc/stdio.d +++ b/libphobos/libdruntime/core/stdc/stdio.d @@ -347,6 +347,24 @@ else version (CRuntime_UClibc) L_tmpnam = 20 } } +else version (WASI) +{ + enum + { + /// + BUFSIZ = 1024, + /// + EOF = -1, + /// + FOPEN_MAX = 1000, + /// + FILENAME_MAX = 4096, + /// + TMP_MAX = 10000, + /// + L_tmpnam = 20 + } +} else { static assert( false, "Unsupported platform" ); @@ -449,6 +467,20 @@ else version (CRuntime_Glibc) /// alias shared(_IO_FILE) FILE; } +else version (WASI) +{ + union fpos_t + { + char[16] __opaque = 0; + double __align; + } + struct _IO_FILE; + + /// + alias _IO_FILE _iobuf; // needed for phobos + /// + alias shared(_IO_FILE) FILE; +} else version (CRuntime_Musl) { union fpos_t @@ -1125,6 +1157,24 @@ else version (CRuntime_UClibc) /// extern shared FILE* stderr; } +else version (WASI) +{ + // needs tail const + extern shared FILE* stdin; + /// + extern shared FILE* stdout; + /// + extern shared FILE* stderr; + enum + { + /// + _IOFBF = 0, + /// + _IOLBF = 1, + /// + _IONBF = 2, + } +} else { static assert( false, "Unsupported platform" ); @@ -1793,6 +1843,28 @@ else version (CRuntime_UClibc) pragma(printf) int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); } +else version (WASI) +{ + // No unsafe pointer manipulation. + @trusted + { + /// + void rewind(FILE* stream); + /// + pure void clearerr(FILE* stream); + /// + pure int feof(FILE* stream); + /// + pure int ferror(FILE* stream); + /// + int fileno(FILE *); + } + + /// + int snprintf(scope char* s, size_t n, scope const char* format, ...); + /// + int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); +} else { static assert( false, "Unsupported platform" ); diff --git a/libphobos/libdruntime/core/stdc/stdlib.d b/libphobos/libdruntime/core/stdc/stdlib.d index dbe55a4..920c311 100644 --- a/libphobos/libdruntime/core/stdc/stdlib.d +++ b/libphobos/libdruntime/core/stdc/stdlib.d @@ -99,6 +99,7 @@ else version (Solaris) enum RAND_MAX = 0x7fff; else version (CRuntime_Bionic) enum RAND_MAX = 0x7fffffff; else version (CRuntime_Musl) enum RAND_MAX = 0x7fffffff; else version (CRuntime_UClibc) enum RAND_MAX = 0x7fffffff; +else version (WASI) enum RAND_MAX = 0x7fffffff; else static assert( false, "Unsupported platform" ); /// diff --git a/libphobos/libdruntime/core/sys/elf/package.d b/libphobos/libdruntime/core/sys/elf/package.d index 69e5209..2dcfd20 100644 --- a/libphobos/libdruntime/core/sys/elf/package.d +++ b/libphobos/libdruntime/core/sys/elf/package.d @@ -2510,3 +2510,66 @@ enum R_TILEGX_GNU_VTINHERIT = 128; enum R_TILEGX_GNU_VTENTRY = 129; enum R_TILEGX_NUM = 130; + +enum EF_RISCV_RVC = 0x0001; +enum EF_RISCV_FLOAT_ABI = 0x0006; +enum EF_RISCV_FLOAT_ABI_SOFT = 0x0000; +enum EF_RISCV_FLOAT_ABI_SINGLE = 0x0002; +enum EF_RISCV_FLOAT_ABI_DOUBLE = 0x0004; +enum EF_RISCV_FLOAT_ABI_QUAD = 0x0006; +enum R_RISCV_NONE = 0; +enum R_RISCV_32 = 1; +enum R_RISCV_64 = 2; +enum R_RISCV_RELATIVE = 3; +enum R_RISCV_COPY = 4; +enum R_RISCV_JUMP_SLOT = 5; +enum R_RISCV_TLS_DTPMOD32 = 6; +enum R_RISCV_TLS_DTPMOD64 = 7; +enum R_RISCV_TLS_DTPREL32 = 8; +enum R_RISCV_TLS_DTPREL64 = 9; +enum R_RISCV_TLS_TPREL32 = 10; +enum R_RISCV_TLS_TPREL64 = 11; +enum R_RISCV_BRANCH = 16; +enum R_RISCV_JAL = 17; +enum R_RISCV_CALL = 18; +enum R_RISCV_CALL_PLT = 19; +enum R_RISCV_GOT_HI20 = 20; +enum R_RISCV_TLS_GOT_HI20 = 21; +enum R_RISCV_TLS_GD_HI20 = 22; +enum R_RISCV_PCREL_HI20 = 23; +enum R_RISCV_PCREL_LO12_I = 24; +enum R_RISCV_PCREL_LO12_S = 25; +enum R_RISCV_HI20 = 26; +enum R_RISCV_LO12_I = 27; +enum R_RISCV_LO12_S = 28; +enum R_RISCV_TPREL_HI20 = 29; +enum R_RISCV_TPREL_LO12_I = 30; +enum R_RISCV_TPREL_LO12_S = 31; +enum R_RISCV_TPREL_ADD = 32; +enum R_RISCV_ADD8 = 33; +enum R_RISCV_ADD16 = 34; +enum R_RISCV_ADD32 = 35; +enum R_RISCV_ADD64 = 36; +enum R_RISCV_SUB8 = 37; +enum R_RISCV_SUB16 = 38; +enum R_RISCV_SUB32 = 39; +enum R_RISCV_SUB64 = 40; +enum R_RISCV_GNU_VTINHERIT = 41; +enum R_RISCV_GNU_VTENTRY = 42; +enum R_RISCV_ALIGN = 43; +enum R_RISCV_RVC_BRANCH = 44; +enum R_RISCV_RVC_JUMP = 45; +enum R_RISCV_RVC_LUI = 46; +enum R_RISCV_GPREL_I = 47; +enum R_RISCV_GPREL_S = 48; +enum R_RISCV_TPREL_I = 49; +enum R_RISCV_TPREL_S = 50; +enum R_RISCV_RELAX = 51; +enum R_RISCV_SUB6 = 52; +enum R_RISCV_SET6 = 53; +enum R_RISCV_SET8 = 54; +enum R_RISCV_SET16 = 55; +enum R_RISCV_SET32 = 56; +enum R_RISCV_32_PCREL = 57; +enum R_RISCV_IRELATIVE = 58; +enum R_RISCV_NUM = 59; diff --git a/libphobos/libdruntime/core/sys/posix/fcntl.d b/libphobos/libdruntime/core/sys/posix/fcntl.d index 3c196d2..dc0a183 100644 --- a/libphobos/libdruntime/core/sys/posix/fcntl.d +++ b/libphobos/libdruntime/core/sys/posix/fcntl.d @@ -123,6 +123,12 @@ version (linux) enum F_SETLK = 6; enum F_SETLKW = 7; } + else version (RISCV64) + { + enum F_GETLK = 5; + enum F_SETLK = 6; + enum F_SETLKW = 7; + } else version (SystemZ) { static assert(off_t.sizeof == 8); diff --git a/libphobos/libdruntime/core/sys/windows/winsock2.d b/libphobos/libdruntime/core/sys/windows/winsock2.d index 55a45be..8a4b1fd 100644 --- a/libphobos/libdruntime/core/sys/windows/winsock2.d +++ b/libphobos/libdruntime/core/sys/windows/winsock2.d @@ -45,15 +45,15 @@ enum NI_MAXSERV = 32; @nogc { int WSAStartup(ushort wVersionRequested, LPWSADATA lpWSAData); -int WSACleanup(); -SOCKET socket(int af, int type, int protocol); +@trusted int WSACleanup(); +@trusted SOCKET socket(int af, int type, int protocol); int ioctlsocket(SOCKET s, int cmd, uint* argp); int bind(SOCKET s, const(sockaddr)* name, socklen_t namelen); int connect(SOCKET s, const(sockaddr)* name, socklen_t namelen); -int listen(SOCKET s, int backlog); +@trusted int listen(SOCKET s, int backlog); SOCKET accept(SOCKET s, sockaddr* addr, socklen_t* addrlen); -int closesocket(SOCKET s); -int shutdown(SOCKET s, int how); +@trusted int closesocket(SOCKET s); +@trusted int shutdown(SOCKET s, int how); int getpeername(SOCKET s, sockaddr* name, socklen_t* namelen); int getsockname(SOCKET s, sockaddr* name, socklen_t* namelen); int send(SOCKET s, const(void)* buf, int len, int flags); @@ -64,11 +64,11 @@ int getsockopt(SOCKET s, int level, int optname, void* optval, socklen_t* optlen int setsockopt(SOCKET s, int level, int optname, const(void)* optval, socklen_t optlen); uint inet_addr(const char* cp); int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* errorfds, const(timeval)* timeout); -char* inet_ntoa(in_addr ina); +@trusted char* inet_ntoa(in_addr ina); hostent* gethostbyname(const char* name); hostent* gethostbyaddr(const(void)* addr, int len, int type); protoent* getprotobyname(const char* name); -protoent* getprotobynumber(int number); +@trusted protoent* getprotobynumber(int number); servent* getservbyname(const char* name, const char* proto); servent* getservbyport(int port, const char* proto); } diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d index ef073a9..1165320 100644 --- a/libphobos/libdruntime/core/thread/osthread.d +++ b/libphobos/libdruntime/core/thread/osthread.d @@ -2104,7 +2104,7 @@ private extern (D) void resume(ThreadBase _t) nothrow @nogc * garbage collector on startup and before any other thread routines * are called. */ -extern (C) void thread_init() @nogc +extern (C) void thread_init() @nogc nothrow { // NOTE: If thread_init itself performs any allocations then the thread // routines reserved for garbage collector use may be called while @@ -2191,7 +2191,7 @@ package __gshared align(__traits(classInstanceAlignment, Thread)) MainThreadStor * Terminates the thread module. No other thread routine may be called * afterwards. */ -extern (C) void thread_term() @nogc +extern (C) void thread_term() @nogc nothrow { thread_term_tpl!(Thread)(_mainThreadStore); } diff --git a/libphobos/libdruntime/core/thread/threadbase.d b/libphobos/libdruntime/core/thread/threadbase.d index 217a33a..909bffc 100644 --- a/libphobos/libdruntime/core/thread/threadbase.d +++ b/libphobos/libdruntime/core/thread/threadbase.d @@ -569,14 +569,14 @@ package(core.thread): __gshared align(mutexAlign) void[mutexClassInstanceSize] _slock; __gshared align(mutexAlign) void[mutexClassInstanceSize] _criticalRegionLock; - static void initLocks() @nogc + static void initLocks() @nogc nothrow { import core.lifetime : emplace; emplace!Mutex(_slock[]); emplace!Mutex(_criticalRegionLock[]); } - static void termLocks() @nogc + static void termLocks() @nogc nothrow { (cast(Mutex)_slock.ptr).__dtor(); (cast(Mutex)_criticalRegionLock.ptr).__dtor(); @@ -756,13 +756,13 @@ package(core.thread): private alias attachThread = externDFunc!("core.thread.osthread.attachThread", ThreadBase function(ThreadBase) @nogc nothrow); -extern (C) void _d_monitordelete_nogc(Object h) @nogc; +extern (C) void _d_monitordelete_nogc(Object h) @nogc nothrow; /** * Terminates the thread module. No other thread routine may be called * afterwards. */ -package void thread_term_tpl(ThreadT, MainThreadStore)(ref MainThreadStore _mainThreadStore) @nogc +package void thread_term_tpl(ThreadT, MainThreadStore)(ref MainThreadStore _mainThreadStore) @nogc nothrow { assert(_mainThreadStore.ptr is cast(void*) ThreadBase.sm_main); @@ -1332,13 +1332,13 @@ package return cast(Mutex)ll_lock.ptr; } - void initLowlevelThreads() @nogc + void initLowlevelThreads() @nogc nothrow { import core.lifetime : emplace; emplace(lowlevelLock()); } - void termLowlevelThreads() @nogc + void termLowlevelThreads() @nogc nothrow { lowlevelLock.__dtor(); } diff --git a/libphobos/libdruntime/core/time.d b/libphobos/libdruntime/core/time.d index 91f218e..9b8391e 100644 --- a/libphobos/libdruntime/core/time.d +++ b/libphobos/libdruntime/core/time.d @@ -2488,7 +2488,7 @@ private immutable long[__traits(allMembers, ClockType).length] _ticksPerSecond; // https://issues.dlang.org/show_bug.cgi?id=14863 // The assert will occur when someone attempts to use _ticksPerSecond for that // value. -extern(C) void _d_initMonoTime() +extern(C) void _d_initMonoTime() @nogc nothrow { // We need a mutable pointer to the ticksPerSecond array. Although this // would appear to break immutability, it is logically the same as a static @@ -3823,7 +3823,7 @@ unittest } version (Darwin) -long machTicksPerSecond() +long machTicksPerSecond() @nogc nothrow { // Be optimistic that ticksPerSecond (1e9*denom/numer) is integral. So far // so good on Darwin based platforms OS X, iOS. diff --git a/libphobos/libdruntime/core/vararg.d b/libphobos/libdruntime/core/vararg.d index 935b2bd..2c3e965 100644 --- a/libphobos/libdruntime/core/vararg.d +++ b/libphobos/libdruntime/core/vararg.d @@ -28,6 +28,8 @@ version (MIPS32) version = MIPS_Any; version (MIPS64) version = MIPS_Any; version (PPC) version = PPC_Any; version (PPC64) version = PPC_Any; +version (RISCV32) version = RISCV_Any; +version (RISCV64) version = RISCV_Any; version (ARM_Any) { @@ -136,6 +138,21 @@ void va_arg()(ref va_list ap, TypeInfo ti, void* parmn) ap += tsize.alignUp; parmn[0..tsize] = p[0..tsize]; } + else version (RISCV_Any) + { + const tsize = ti.tsize; + void* p; + if (tsize > (size_t.sizeof << 1)) + p = *cast(void**) ap; + else + { + if (tsize == (size_t.sizeof << 1)) + ap = ap.alignUp!(size_t.sizeof << 1); + p = cast(void*) ap; + } + ap += tsize.alignUp; + parmn[0..tsize] = p[0..tsize]; + } else static assert(0, "Unsupported platform"); } diff --git a/libphobos/libdruntime/rt/critical_.d b/libphobos/libdruntime/rt/critical_.d index ae18122..36552a3 100644 --- a/libphobos/libdruntime/rt/critical_.d +++ b/libphobos/libdruntime/rt/critical_.d @@ -18,13 +18,13 @@ nothrow: import rt.monitor_, core.atomic; -extern (C) void _d_critical_init() +extern (C) void _d_critical_init() @nogc nothrow { initMutex(cast(Mutex*)&gcs.mtx); head = &gcs; } -extern (C) void _d_critical_term() +extern (C) void _d_critical_term() @nogc nothrow { // This function is only ever called by the runtime shutdown code // and therefore is single threaded so the following cast is fine. diff --git a/libphobos/libdruntime/rt/dmain2.d b/libphobos/libdruntime/rt/dmain2.d index 5ef2695..0739b74 100644 --- a/libphobos/libdruntime/rt/dmain2.d +++ b/libphobos/libdruntime/rt/dmain2.d @@ -62,22 +62,21 @@ struct UnitTestResult bool summarize; } -extern (C) void _d_monitor_staticctor(); -extern (C) void _d_monitor_staticdtor(); -extern (C) void _d_critical_init(); -extern (C) void _d_critical_term(); +extern (C) void _d_monitor_staticctor() @nogc nothrow; +extern (C) void _d_monitor_staticdtor() @nogc nothrow; +extern (C) void _d_critical_init() @nogc nothrow; +extern (C) void _d_critical_term() @nogc nothrow; extern (C) void gc_init(); extern (C) void gc_term(); -extern (C) void thread_init() @nogc; -extern (C) void thread_term() @nogc; -extern (C) void lifetime_init(); +extern (C) void thread_init() @nogc nothrow; +extern (C) void thread_term() @nogc nothrow; extern (C) void rt_moduleCtor(); extern (C) void rt_moduleTlsCtor(); extern (C) void rt_moduleDtor(); extern (C) void rt_moduleTlsDtor(); extern (C) void thread_joinAll(); extern (C) UnitTestResult runModuleUnitTests(); -extern (C) void _d_initMonoTime(); +extern (C) void _d_initMonoTime() @nogc nothrow; version (CRuntime_Microsoft) { @@ -134,7 +133,6 @@ extern (C) int rt_init() thread_init(); // TODO: fixme - calls GC.addRange -> Initializes GC initStaticDataGC(); - lifetime_init(); rt_moduleCtor(); rt_moduleTlsCtor(); return 1; diff --git a/libphobos/libdruntime/rt/lifetime.d b/libphobos/libdruntime/rt/lifetime.d index 5a18968..18ecc31 100644 --- a/libphobos/libdruntime/rt/lifetime.d +++ b/libphobos/libdruntime/rt/lifetime.d @@ -40,9 +40,11 @@ private } } -extern (C) void lifetime_init() +// Now-removed symbol, kept around for ABI +// Some programs are dynamically linked, so best to err on the side of keeping symbols around for a while (especially extern(C) ones) +// https://github.com/dlang/druntime/pull/3361 +deprecated extern (C) void lifetime_init() { - // this is run before static ctors, so it is safe to modify immutables } /** diff --git a/libphobos/libdruntime/rt/minfo.d b/libphobos/libdruntime/rt/minfo.d index 0d5cd22..7489150 100644 --- a/libphobos/libdruntime/rt/minfo.d +++ b/libphobos/libdruntime/rt/minfo.d @@ -58,7 +58,7 @@ struct ModuleGroup // target modules are involved in a cycle. // // The return value is malloc'd using C, so it must be freed after use. - private size_t[] genCyclePath(size_t srcidx, size_t targetidx, int[][] edges) + private size_t[] genCyclePath(size_t srcidx, size_t targetidx, int[][] edges) nothrow { import core.bitop : bt, btc, bts; @@ -109,7 +109,7 @@ struct ModuleGroup // release mode. if (distance[target] != curdist) { - throw new Error("internal error printing module cycle"); + assert(0, "internal error printing module cycle"); } // determine the path. This is tricky, because we have to @@ -162,14 +162,13 @@ struct ModuleGroup * Throws: * Exception if it fails. */ - void sortCtors(string cycleHandling) + void sortCtors(string cycleHandling) nothrow { import core.bitop : bts, btr, bt, BitRange; import core.internal.container.hashtab; enum OnCycle { - deprecate, abort, print, ignore @@ -180,7 +179,9 @@ struct ModuleGroup switch (cycleHandling) with(OnCycle) { case "deprecate": - onCycle = deprecate; + import core.stdc.stdio : fprintf, stderr; + // Option deprecated in 2.101, remove in 2.111 + fprintf(stderr, "`--DRT-oncycle=deprecate` is no longer supported, using `abort` instead\n"); break; case "abort": onCycle = abort; @@ -196,7 +197,7 @@ struct ModuleGroup break; default: // invalid cycle handling option. - throw new Error("DRT invalid cycle handling option: " ~ cycleHandling); + assert(0, "DRT invalid cycle handling option: " ~ cycleHandling); } debug (printModuleDependencies) @@ -280,7 +281,7 @@ struct ModuleGroup .free(edges.ptr); } - void buildCycleMessage(size_t sourceIdx, size_t cycleIdx, scope void delegate(string) sink) + void buildCycleMessage(size_t sourceIdx, size_t cycleIdx, scope void delegate(string) nothrow sink) { version (Windows) enum EOL = "\r\n"; @@ -312,7 +313,7 @@ struct ModuleGroup // // If a cycle is detected, returns the index of the module that completes the cycle. // Returns: true for success, false for a deprecated cycle error - bool findDeps(size_t idx, size_t* reachable) + bool findDeps(size_t idx, size_t* reachable) nothrow { static struct stackFrame { @@ -356,14 +357,6 @@ struct ModuleGroup // was already started, this is a cycle. final switch (onCycle) with(OnCycle) { - case deprecate: - // check with old algorithm - if (sortCtorsOld(edges)) - { - // unwind to print deprecation message. - return false; // deprecated cycle error - } - goto case abort; // fall through case abort: string errmsg = ""; @@ -418,7 +411,7 @@ struct ModuleGroup // ctor/dtors that must be dealt with. It recurses only when it finds // dependencies that also have static ctor/dtors. // Returns: true for success, false for a deprecated cycle error - bool processMod(size_t curidx) + bool processMod(size_t curidx) nothrow { immutable ModuleInfo* current = _modules[curidx]; @@ -461,7 +454,7 @@ struct ModuleGroup } // returns `false` if deprecated cycle error otherwise set `result`. - bool doSort(size_t relevantFlags, ref immutable(ModuleInfo)*[] result) + bool doSort(size_t relevantFlags, ref immutable(ModuleInfo)*[] result) nothrow { clearFlags(relevant); clearFlags(ctorstart); @@ -533,193 +526,6 @@ struct ModuleGroup sortCtors(rt_configOption("oncycle")); } - /****************************** - * This is the old ctor sorting algorithm that does not find all cycles. - * - * It is here to allow the deprecated behavior from the original algorithm - * until people have fixed their code. - * - * If no cycles are found, the _ctors and _tlsctors are replaced with the - * ones generated by this algorithm to preserve the old incorrect ordering - * behavior. - * - * Params: - * edges = The module edges as found in the `importedModules` member of - * each ModuleInfo. Generated in sortCtors. - * Returns: - * true if no cycle is found, false if one was. - */ - bool sortCtorsOld(int[][] edges) - { - immutable len = edges.length; - assert(len == _modules.length); - - static struct StackRec - { - @property int mod() - { - return _mods[_idx]; - } - - int[] _mods; - size_t _idx; - } - - auto stack = (cast(StackRec*).calloc(len, StackRec.sizeof))[0 .. len]; - // TODO: reuse GCBits by moving it to core.internal.container - immutable nwords = (len + 8 * size_t.sizeof - 1) / (8 * size_t.sizeof); - auto ctorstart = cast(size_t*).malloc(nwords * size_t.sizeof); - auto ctordone = cast(size_t*).malloc(nwords * size_t.sizeof); - int[] initialEdges = (cast(int *)malloc(int.sizeof * len))[0 .. len]; - if (!stack.ptr || ctorstart is null || ctordone is null || !initialEdges.ptr) - assert(0); - scope (exit) - { - .free(stack.ptr); - .free(ctorstart); - .free(ctordone); - .free(initialEdges.ptr); - } - - // initialize the initial edges - foreach (i, ref v; initialEdges) - v = cast(int)i; - - bool sort(ref immutable(ModuleInfo)*[] ctors, uint mask) - { - import core.bitop; - - ctors = (cast(immutable(ModuleInfo)**).malloc(len * size_t.sizeof))[0 .. len]; - if (!ctors.ptr) - assert(0); - - // clean flags - memset(ctorstart, 0, nwords * size_t.sizeof); - memset(ctordone, 0, nwords * size_t.sizeof); - size_t stackidx = 0; - size_t cidx; - - int[] mods = initialEdges; - - size_t idx; - while (true) - { - while (idx < mods.length) - { - auto m = mods[idx]; - - if (bt(ctordone, m)) - { - // this module has already been processed, skip - ++idx; - continue; - } - else if (bt(ctorstart, m)) - { - /* Trace back to the begin of the cycle. - */ - bool ctorInCycle; - size_t start = stackidx; - while (start--) - { - auto sm = stack[start].mod; - if (sm == m) - break; - assert(sm >= 0); - if (bt(ctorstart, sm)) - ctorInCycle = true; - } - assert(stack[start].mod == m); - if (ctorInCycle) - { - return false; - } - else - { - /* This is also a cycle, but the import chain does not constrain - * the order of initialization, either because the imported - * modules have no ctors or the ctors are standalone. - */ - ++idx; - } - } - else - { - auto curmod = _modules[m]; - if (curmod.flags & mask) - { - if (curmod.flags & MIstandalone || !edges[m].length) - { // trivial ctor => sort in - ctors[cidx++] = curmod; - bts(ctordone, m); - } - else - { // non-trivial ctor => defer - bts(ctorstart, m); - } - } - else // no ctor => mark as visited - { - bts(ctordone, m); - } - - if (edges[m].length) - { - /* Internal runtime error, recursion exceeds number of modules. - */ - (stackidx < len) || assert(0); - - // recurse - stack[stackidx++] = StackRec(mods, idx); - idx = 0; - mods = edges[m]; - } - } - } - - if (stackidx) - { // pop old value from stack - --stackidx; - mods = stack[stackidx]._mods; - idx = stack[stackidx]._idx; - auto m = mods[idx++]; - if (bt(ctorstart, m) && !bts(ctordone, m)) - ctors[cidx++] = _modules[m]; - } - else // done - break; - } - // store final number and shrink array - ctors = (cast(immutable(ModuleInfo)**).realloc(ctors.ptr, cidx * size_t.sizeof))[0 .. cidx]; - return true; - } - - /* Do two passes: ctor/dtor, tlsctor/tlsdtor - */ - immutable(ModuleInfo)*[] _ctors2; - immutable(ModuleInfo)*[] _tlsctors2; - auto result = sort(_ctors2, MIctor | MIdtor) && sort(_tlsctors2, MItlsctor | MItlsdtor); - if (result) // no cycle - { - // fall back to original ordering as part of the deprecation. - if (_ctors.ptr) - .free(_ctors.ptr); - _ctors = _ctors2; - if (_tlsctors.ptr) - .free(_tlsctors.ptr); - _tlsctors = _tlsctors2; - } - else - { - // free any allocated memory that will be forgotten - if (_ctors2.ptr) - .free(_ctors2.ptr); - if (_tlsctors2.ptr) - .free(_tlsctors2.ptr); - } - return result; - } - void runCtors() { // run independent ctors diff --git a/libphobos/libdruntime/rt/monitor_.d b/libphobos/libdruntime/rt/monitor_.d index 0f1d0e9..c1f3f3c 100644 --- a/libphobos/libdruntime/rt/monitor_.d +++ b/libphobos/libdruntime/rt/monitor_.d @@ -54,7 +54,7 @@ extern (C) void _d_monitordelete(Object h, bool det) } // does not call dispose events, for internal use only -extern (C) void _d_monitordelete_nogc(Object h) @nogc +extern (C) void _d_monitordelete_nogc(Object h) @nogc nothrow { auto m = getMonitor(h); if (m is null) @@ -148,7 +148,7 @@ extern (C) void rt_detachDisposeEvent(Object h, DEvent e) nothrow: -extern (C) void _d_monitor_staticctor() +extern (C) void _d_monitor_staticctor() @nogc nothrow { version (Posix) { @@ -158,7 +158,7 @@ extern (C) void _d_monitor_staticctor() initMutex(&gmtx); } -extern (C) void _d_monitor_staticdtor() +extern (C) void _d_monitor_staticdtor() @nogc nothrow { destroyMutex(&gmtx); version (Posix) |