aboutsummaryrefslogtreecommitdiff
path: root/libphobos/libdruntime
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-12-09 18:59:38 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2022-12-11 17:17:58 +0100
commit6d799f0aed18be25a5c908499b6411ab6d06b78c (patch)
tree3e6a91048c7fe3e78bae9f75b24eb37c5504681b /libphobos/libdruntime
parentcc7f509d3c0b3ab63891cf7ca2def0fdfb3642c4 (diff)
downloadgcc-6d799f0aed18be25a5c908499b6411ab6d06b78c.zip
gcc-6d799f0aed18be25a5c908499b6411ab6d06b78c.tar.gz
gcc-6d799f0aed18be25a5c908499b6411ab6d06b78c.tar.bz2
d: Merge upstream dmd, druntime c8ae4adb2e, phobos 792c8b7c1.
D front-end changes: - Import dmd v2.101.0. - Deprecate the ability to call `__traits(getAttributes)' on overload sets. - Deprecate non-empty `for' statement increment clause with no effect. - Array literals assigned to `scope' array variables can now be allocated on the stack. D runtime changes: - Import druntime v2.101.0. Phobos changes: - Import phobos v2.101.0. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd c8ae4adb2e. * typeinfo.cc (check_typeinfo_type): Update for new front-end interface. (TypeInfoVisitor::visit (TypeInfoStructDeclaration *)): Remove warning that toHash() must be declared 'nothrow @safe`. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime c8ae4adb2e. * src/MERGE: Merge upstream phobos 792c8b7c1.
Diffstat (limited to 'libphobos/libdruntime')
-rw-r--r--libphobos/libdruntime/MERGE2
-rw-r--r--libphobos/libdruntime/core/demangle.d101
-rw-r--r--libphobos/libdruntime/core/exception.d24
-rw-r--r--libphobos/libdruntime/core/internal/gc/os.d3
-rw-r--r--libphobos/libdruntime/core/runtime.d2
-rw-r--r--libphobos/libdruntime/core/sync/condition.d35
-rw-r--r--libphobos/libdruntime/core/sync/mutex.d2
-rw-r--r--libphobos/libdruntime/core/sys/posix/sys/wait.d1
-rw-r--r--libphobos/libdruntime/core/sys/windows/winsock2.d4
9 files changed, 128 insertions, 46 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 2398875..5ee6f62 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-e4f89195913be1dc638707b1abb24c4f3ae7e0bf
+c8ae4adb2eda515b09b326948e3a4aa9f489af45
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
diff --git a/libphobos/libdruntime/core/demangle.d b/libphobos/libdruntime/core/demangle.d
index c2d4032..869ade6 100644
--- a/libphobos/libdruntime/core/demangle.d
+++ b/libphobos/libdruntime/core/demangle.d
@@ -24,6 +24,11 @@ else version (WatchOS)
debug(trace) import core.stdc.stdio : printf;
debug(info) import core.stdc.stdio : printf;
+extern (C) alias CXX_DEMANGLER = char* function (const char* mangled_name,
+ char* output_buffer,
+ size_t* length,
+ int* status) nothrow pure @trusted;
+
private struct NoHooks
{
// supported hooks
@@ -2115,19 +2120,22 @@ pure @safe:
/**
- * Demangles D mangled names. If it is not a D mangled name, it returns its
- * argument name.
+ * Demangles D/C++ mangled names. If it is not a D/C++ mangled name, it
+ * returns its argument name.
*
* Params:
* buf = The string to demangle.
* dst = An optional destination buffer.
+ * __cxa_demangle = optional C++ demangler
*
* Returns:
- * The demangled name or the original string if the name is not a mangled D
- * name.
+ * The demangled name or the original string if the name is not a mangled
+ * D/C++ name.
*/
-char[] demangle(return scope const(char)[] buf, return scope char[] dst = null ) nothrow pure @safe
+char[] demangle(return scope const(char)[] buf, return scope char[] dst = null, CXX_DEMANGLER __cxa_demangle = null) nothrow pure @safe
{
+ if (buf.length > 2 && buf[0..2] == "_Z")
+ return demangleCXX(buf, __cxa_demangle, dst);
auto d = Demangle!()(buf, dst);
// fast path (avoiding throwing & catching exception) for obvious
// non-D mangled names
@@ -2210,7 +2218,7 @@ char[] reencodeMangled(return scope const(char)[] mangled) nothrow pure @safe
}
}
- bool parseLName(scope ref Remangle d) scope
+ bool parseLName(scope ref Remangle d) scope @trusted
{
flushPosition(d);
@@ -2261,7 +2269,7 @@ char[] reencodeMangled(return scope const(char)[] mangled) nothrow pure @safe
}
else
{
- idpos[id] = refpos;
+ idpos[id] = refpos; //! scope variable id used as AA key, makes this function @trusted
result ~= d.buf[refpos .. d.pos];
}
}
@@ -2706,8 +2714,10 @@ unittest
{
char[] buf = new char[i];
auto ds = demangle(s, buf);
- assert(ds == "pure nothrow @safe char[] core.demangle.demangle(scope return const(char)[], scope return char[])" ||
- ds == "pure nothrow @safe char[] core.demangle.demangle(return scope const(char)[], return scope char[])");
+ assert(ds == "pure nothrow @safe char[] core.demangle.demangle(scope return const(char)[], scope return char[], extern (C) char* function(const(char*), char*, ulong*, int*) pure nothrow @trusted*)" ||
+ ds == "pure nothrow @safe char[] core.demangle.demangle(return scope const(char)[], return scope char[], extern (C) char* function(const(char*), char*, ulong*, int*) pure nothrow @trusted*)" ||
+ ds == "pure nothrow @safe char[] core.demangle.demangle(scope return const(char)[], scope return char[], extern (C) char* function(const(char*), char*, uint*, int*) pure nothrow @trusted*)" ||
+ ds == "pure nothrow @safe char[] core.demangle.demangle(return scope const(char)[], return scope char[], extern (C) char* function(const(char*), char*, uint*, int*) pure nothrow @trusted*)", ds);
}
}
@@ -2901,3 +2911,76 @@ private string toStringConsume (immutable ManglingFlagInfo[] infos, ref ushort b
}
return null;
}
+
+private shared CXX_DEMANGLER __cxa_demangle;
+
+/**
+ * Returns:
+ * a CXX_DEMANGLER if a C++ stdlib is loaded
+ */
+
+CXX_DEMANGLER getCXXDemangler() nothrow @trusted
+{
+ if (__cxa_demangle is null)
+ version (Posix)
+ {
+ import core.sys.posix.dlfcn : dlsym;
+ version (DragonFlyBSD) import core.sys.dragonflybsd.dlfcn : RTLD_DEFAULT;
+ version (FreeBSD) import core.sys.freebsd.dlfcn : RTLD_DEFAULT;
+ version (linux) import core.sys.linux.dlfcn : RTLD_DEFAULT;
+ version (NetBSD) import core.sys.netbsd.dlfcn : RTLD_DEFAULT;
+ version (OSX) import core.sys.darwin.dlfcn : RTLD_DEFAULT;
+ version (Solaris) import core.sys.solaris.dlfcn : RTLD_DEFAULT;
+
+ if (auto found = cast(CXX_DEMANGLER) dlsym(RTLD_DEFAULT, "__cxa_demangle"))
+ __cxa_demangle = found;
+ }
+
+ if (__cxa_demangle is null)
+ __cxa_demangle = (const char* mangled_name, char* output_buffer,
+ size_t* length, int* status) nothrow pure @trusted {
+ *status = -1;
+ return null;
+ };
+
+ return __cxa_demangle;
+}
+
+/**
+ * Demangles C++ mangled names. If it is not a C++ mangled name, it
+ * returns its argument name.
+ *
+ * Params:
+ * buf = The string to demangle.
+ * __cxa_demangle = C++ demangler
+ * dst = An optional destination buffer.
+ *
+ * Returns:
+ * The demangled name or the original string if the name is not a mangled
+ * C++ name.
+ */
+private char[] demangleCXX(return scope const(char)[] buf, CXX_DEMANGLER __cxa_demangle, return scope char[] dst = null,) nothrow pure @trusted
+{
+ char[] c_string = dst; // temporarily use dst buffer if possible
+ c_string.length = buf.length + 1;
+ c_string[0 .. buf.length] = buf[0 .. buf.length];
+ c_string[buf.length] = '\0';
+
+ int status;
+ size_t demangled_length;
+ auto demangled = __cxa_demangle(&c_string[0], null, &demangled_length, &status);
+ scope (exit) {
+ import core.memory;
+ pureFree(cast(void*) demangled);
+ }
+ if (status == 0)
+ {
+ dst.length = demangled_length;
+ dst[] = demangled[0 .. demangled_length];
+ return dst;
+ }
+
+ dst.length = buf.length;
+ dst[] = buf[];
+ return dst;
+}
diff --git a/libphobos/libdruntime/core/exception.d b/libphobos/libdruntime/core/exception.d
index a05a24c..62179fe 100644
--- a/libphobos/libdruntime/core/exception.d
+++ b/libphobos/libdruntime/core/exception.d
@@ -608,7 +608,7 @@ extern (C) void onUnittestErrorMsg( string file, size_t line, string msg ) nothr
* Throws:
* $(LREF RangeError).
*/
-extern (C) void onRangeError( string file = __FILE__, size_t line = __LINE__ ) @trusted pure nothrow @nogc
+extern (C) noreturn onRangeError( string file = __FILE__, size_t line = __LINE__ ) @trusted pure nothrow @nogc
{
throw staticError!RangeError(file, line, null);
}
@@ -626,7 +626,7 @@ extern (C) void onRangeError( string file = __FILE__, size_t line = __LINE__ ) @
* Throws:
* $(LREF ArraySliceError).
*/
-extern (C) void onArraySliceError( size_t lower = 0, size_t upper = 0, size_t length = 0,
+extern (C) noreturn onArraySliceError( size_t lower = 0, size_t upper = 0, size_t length = 0,
string file = __FILE__, size_t line = __LINE__ ) @trusted pure nothrow @nogc
{
throw staticError!ArraySliceError(lower, upper, length, file, line, null);
@@ -644,7 +644,7 @@ extern (C) void onArraySliceError( size_t lower = 0, size_t upper = 0, size_t le
* Throws:
* $(LREF ArrayIndexError).
*/
-extern (C) void onArrayIndexError( size_t index = 0, size_t length = 0,
+extern (C) noreturn onArrayIndexError( size_t index = 0, size_t length = 0,
string file = __FILE__, size_t line = __LINE__ ) @trusted pure nothrow @nogc
{
throw staticError!ArrayIndexError(index, length, file, line, null);
@@ -662,7 +662,7 @@ extern (C) void onArrayIndexError( size_t index = 0, size_t length = 0,
* Throws:
* $(LREF FinalizeError).
*/
-extern (C) void onFinalizeError( TypeInfo info, Throwable e, string file = __FILE__, size_t line = __LINE__ ) @trusted nothrow
+extern (C) noreturn onFinalizeError( TypeInfo info, Throwable e, string file = __FILE__, size_t line = __LINE__ ) @trusted nothrow
{
// This error is thrown during a garbage collection, so no allocation must occur while
// generating this object. So we use a preallocated instance
@@ -679,13 +679,13 @@ version (D_BetterC)
// templates even for ordinary builds instead of providing them as an
// extern(C) library.
- void onOutOfMemoryError()(void* pretend_sideffect = null) @nogc nothrow pure @trusted
+ noreturn onOutOfMemoryError()(void* pretend_sideffect = null) @nogc nothrow pure @trusted
{
assert(0, "Memory allocation failed");
}
alias onOutOfMemoryErrorNoGC = onOutOfMemoryError;
- void onInvalidMemoryOperationError()(void* pretend_sideffect = null) @nogc nothrow pure @trusted
+ noreturn onInvalidMemoryOperationError()(void* pretend_sideffect = null) @nogc nothrow pure @trusted
{
assert(0, "Invalid memory operation");
}
@@ -699,14 +699,14 @@ else
* Throws:
* $(LREF OutOfMemoryError).
*/
- extern (C) void onOutOfMemoryError(void* pretend_sideffect = null) @trusted pure nothrow @nogc /* dmd @@@BUG11461@@@ */
+ extern (C) noreturn onOutOfMemoryError(void* pretend_sideffect = null) @trusted pure nothrow @nogc /* dmd @@@BUG11461@@@ */
{
// NOTE: Since an out of memory condition exists, no allocation must occur
// while generating this object.
throw staticError!OutOfMemoryError();
}
- extern (C) void onOutOfMemoryErrorNoGC() @trusted nothrow @nogc
+ extern (C) noreturn onOutOfMemoryErrorNoGC() @trusted nothrow @nogc
{
// suppress stacktrace until they are @nogc
throw staticError!OutOfMemoryError(false);
@@ -720,7 +720,7 @@ else
* Throws:
* $(LREF InvalidMemoryOperationError).
*/
-extern (C) void onInvalidMemoryOperationError(void* pretend_sideffect = null) @trusted pure nothrow @nogc /* dmd @@@BUG11461@@@ */
+extern (C) noreturn onInvalidMemoryOperationError(void* pretend_sideffect = null) @trusted pure nothrow @nogc /* dmd @@@BUG11461@@@ */
{
// The same restriction applies as for onOutOfMemoryError. The GC is in an
// undefined state, thus no allocation must occur while generating this object.
@@ -738,7 +738,7 @@ extern (C) void onInvalidMemoryOperationError(void* pretend_sideffect = null) @t
* Throws:
* $(LREF ConfigurationError).
*/
-extern (C) void onForkError( string file = __FILE__, size_t line = __LINE__ ) @trusted pure nothrow @nogc
+extern (C) noreturn onForkError( string file = __FILE__, size_t line = __LINE__ ) @trusted pure nothrow @nogc
{
throw staticError!ForkError( file, line, null );
}
@@ -755,7 +755,7 @@ extern (C) void onForkError( string file = __FILE__, size_t line = __LINE__ ) @t
* Throws:
* $(LREF UnicodeException).
*/
-extern (C) void onUnicodeError( string msg, size_t idx, string file = __FILE__, size_t line = __LINE__ ) @safe pure
+extern (C) noreturn onUnicodeError( string msg, size_t idx, string file = __FILE__, size_t line = __LINE__ ) @safe pure
{
throw new UnicodeException( msg, idx, file, line );
}
@@ -859,7 +859,7 @@ extern (C)
private align(2 * size_t.sizeof) void[256] _store;
// only Errors for now as those are rarely chained
-private T staticError(T, Args...)(auto ref Args args)
+package T staticError(T, Args...)(auto ref Args args)
if (is(T : Error))
{
// pure hack, what we actually need is @noreturn and allow to call that in pure functions
diff --git a/libphobos/libdruntime/core/internal/gc/os.d b/libphobos/libdruntime/core/internal/gc/os.d
index 64f1203..38b60cb 100644
--- a/libphobos/libdruntime/core/internal/gc/os.d
+++ b/libphobos/libdruntime/core/internal/gc/os.d
@@ -70,10 +70,7 @@ else version (Posix)
else if (errno == ECHILD)
return ChildStatus.done; // someone called posix.syswait
else if (waited_pid != pid || status != 0)
- {
onForkError();
- return ChildStatus.error;
- }
return ChildStatus.done;
}
diff --git a/libphobos/libdruntime/core/runtime.d b/libphobos/libdruntime/core/runtime.d
index 75e671c..799e525 100644
--- a/libphobos/libdruntime/core/runtime.d
+++ b/libphobos/libdruntime/core/runtime.d
@@ -910,7 +910,7 @@ private:
{
fixbuf[0 .. symBeg] = buf[0 .. symBeg];
- auto sym = demangle(buf[symBeg .. symEnd], fixbuf[symBeg .. $]);
+ auto sym = demangle(buf[symBeg .. symEnd], fixbuf[symBeg .. $], getCXXDemangler());
if (sym.ptr !is fixbuf.ptr + symBeg)
{
diff --git a/libphobos/libdruntime/core/sync/condition.d b/libphobos/libdruntime/core/sync/condition.d
index 674d78d..ddd04ae 100644
--- a/libphobos/libdruntime/core/sync/condition.d
+++ b/libphobos/libdruntime/core/sync/condition.d
@@ -20,6 +20,9 @@ public import core.sync.exception;
public import core.sync.mutex;
public import core.time;
+import core.exception : AssertError, staticError;
+
+
version (Windows)
{
import core.sync.semaphore;
@@ -51,7 +54,6 @@ else
// void notifyAll();
////////////////////////////////////////////////////////////////////////////////
-
/**
* This class represents a condition variable as conceived by C.A.R. Hoare. As
* per Mesa type monitors however, "signal" has been replaced with "notify" to
@@ -74,19 +76,19 @@ class Condition
* Throws:
* SyncError on error.
*/
- this( Mutex m ) nothrow @safe
+ this( Mutex m ) nothrow @safe @nogc
{
this(m, true);
}
/// ditto
- this( shared Mutex m ) shared nothrow @safe
+ this( shared Mutex m ) shared nothrow @safe @nogc
{
this(m, true);
}
//
- private this(this Q, M)( M m, bool _unused_ ) nothrow @trusted
+ private this(this Q, M)( M m, bool _unused_ ) nothrow @trusted @nogc
if ((is(Q == Condition) && is(M == Mutex)) ||
(is(Q == shared Condition) && is(M == shared Mutex)))
{
@@ -102,12 +104,12 @@ class Condition
}
m_blockLock = cast(HANDLE_TYPE) CreateSemaphoreA( null, 1, 1, null );
if ( m_blockLock == m_blockLock.init )
- throw new SyncError( "Unable to initialize condition" );
+ throw staticError!AssertError("Unable to initialize condition", __FILE__, __LINE__);
scope(failure) CloseHandle( cast(void*) m_blockLock );
m_blockQueue = cast(HANDLE_TYPE) CreateSemaphoreA( null, 0, int.max, null );
if ( m_blockQueue == m_blockQueue.init )
- throw new SyncError( "Unable to initialize condition" );
+ throw staticError!AssertError("Unable to initialize condition", __FILE__, __LINE__);
scope(failure) CloseHandle( cast(void*) m_blockQueue );
InitializeCriticalSection( cast(RTL_CRITICAL_SECTION*) &m_unblockLock );
@@ -123,29 +125,28 @@ class Condition
pthread_condattr_t attr = void;
int rc = pthread_condattr_init( &attr );
if ( rc )
- throw new SyncError( "Unable to initialize condition" );
+ throw staticError!AssertError("Unable to initialize condition", __FILE__, __LINE__);
rc = pthread_condattr_setclock( &attr, CLOCK_MONOTONIC );
if ( rc )
- throw new SyncError( "Unable to initialize condition" );
+ throw staticError!AssertError("Unable to initialize condition", __FILE__, __LINE__);
rc = pthread_cond_init( cast(pthread_cond_t*) &m_hndl, &attr );
if ( rc )
- throw new SyncError( "Unable to initialize condition" );
+ throw staticError!AssertError("Unable to initialize condition", __FILE__, __LINE__);
rc = pthread_condattr_destroy( &attr );
if ( rc )
- throw new SyncError( "Unable to initialize condition" );
+ throw staticError!AssertError("Unable to initialize condition", __FILE__, __LINE__);
} ();
}
else
{
int rc = pthread_cond_init( cast(pthread_cond_t*) &m_hndl, null );
if ( rc )
- throw new SyncError( "Unable to initialize condition" );
+ throw staticError!AssertError("Unable to initialize condition", __FILE__, __LINE__);
}
}
}
-
- ~this()
+ ~this() @nogc
{
version (Windows)
{
@@ -231,7 +232,7 @@ class Condition
{
int rc = pthread_cond_wait( cast(pthread_cond_t*) &m_hndl, (cast(Mutex) m_assocMutex).handleAddr() );
if ( rc )
- throw new SyncError( "Unable to wait for condition" );
+ throw staticError!AssertError("Unable to wait for condition", __FILE__, __LINE__);
}
}
@@ -296,7 +297,7 @@ class Condition
return true;
if ( rc == ETIMEDOUT )
return false;
- throw new SyncError( "Unable to wait for condition" );
+ throw staticError!AssertError("Unable to wait for condition", __FILE__, __LINE__);
}
}
@@ -344,7 +345,7 @@ class Condition
rc = pthread_cond_signal( cast(pthread_cond_t*) &m_hndl );
} while ( rc == EAGAIN );
if ( rc )
- throw new SyncError( "Unable to notify condition" );
+ throw staticError!AssertError("Unable to notify condition", __FILE__, __LINE__);
}
}
@@ -392,7 +393,7 @@ class Condition
rc = pthread_cond_broadcast( cast(pthread_cond_t*) &m_hndl );
} while ( rc == EAGAIN );
if ( rc )
- throw new SyncError( "Unable to notify condition" );
+ throw staticError!AssertError("Unable to notify condition", __FILE__, __LINE__);
}
}
diff --git a/libphobos/libdruntime/core/sync/mutex.d b/libphobos/libdruntime/core/sync/mutex.d
index b848a14..e7380c46 100644
--- a/libphobos/libdruntime/core/sync/mutex.d
+++ b/libphobos/libdruntime/core/sync/mutex.d
@@ -292,7 +292,7 @@ private:
package:
version (Posix)
{
- pthread_mutex_t* handleAddr()
+ pthread_mutex_t* handleAddr() @nogc
{
return &m_hndl;
}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/wait.d b/libphobos/libdruntime/core/sys/posix/sys/wait.d
index 766a4e0..145149b 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/wait.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/wait.d
@@ -451,6 +451,7 @@ else version (NetBSD)
}
else version (OpenBSD)
{
+ int waitid(idtype_t, id_t, siginfo_t*, int);
}
else version (DragonFlyBSD)
{
diff --git a/libphobos/libdruntime/core/sys/windows/winsock2.d b/libphobos/libdruntime/core/sys/windows/winsock2.d
index 5225645..b036df3 100644
--- a/libphobos/libdruntime/core/sys/windows/winsock2.d
+++ b/libphobos/libdruntime/core/sys/windows/winsock2.d
@@ -63,11 +63,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);
-@trusted char* inet_ntoa(in_addr ina);
+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);
-@trusted protoent* getprotobynumber(int number);
+protoent* getprotobynumber(int number);
servent* getservbyname(const char* name, const char* proto);
servent* getservbyport(int port, const char* proto);
}