diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2022-03-02 18:16:08 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2022-03-02 18:21:38 +0100 |
commit | 8977f4bec650bb6975792772245b07b722ee9843 (patch) | |
tree | 495444470878e267304174ed409829358ae07740 /libphobos | |
parent | 12f8dc0b642db5edc702f252af1a5231606b29db (diff) | |
download | gcc-8977f4bec650bb6975792772245b07b722ee9843.zip gcc-8977f4bec650bb6975792772245b07b722ee9843.tar.gz gcc-8977f4bec650bb6975792772245b07b722ee9843.tar.bz2 |
d: Merge upstream dmd 423f19b41, druntime 100a608c, phobos a1f8c4c07.
D Runtime changes:
- Fix stdc.stdio bindings to not depend on druntime (PR104729).
- Implement stdc.math for Solaris (PR104735).
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd 423f19b41.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime 100a608c.
* src/MERGE: Merge upstream phobos a1f8c4c07.
Diffstat (limited to 'libphobos')
-rw-r--r-- | libphobos/libdruntime/MERGE | 2 | ||||
-rw-r--r-- | libphobos/libdruntime/core/memory.d | 9 | ||||
-rw-r--r-- | libphobos/libdruntime/core/stdc/math.d | 133 | ||||
-rw-r--r-- | libphobos/libdruntime/core/stdc/stdio.d | 16 | ||||
-rw-r--r-- | libphobos/libdruntime/core/stdcpp/exception.d | 10 | ||||
-rw-r--r-- | libphobos/libdruntime/core/stdcpp/typeinfo.d | 40 | ||||
-rw-r--r-- | libphobos/libdruntime/core/sys/posix/locale.d | 2 | ||||
-rw-r--r-- | libphobos/libdruntime/object.d | 18 | ||||
-rw-r--r-- | libphobos/src/MERGE | 2 | ||||
-rw-r--r-- | libphobos/src/std/datetime/systime.d | 35 | ||||
-rw-r--r-- | libphobos/src/std/sumtype.d | 41 |
11 files changed, 210 insertions, 98 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index 7c0bb57..c4b1538 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -caf14b0f4ebbae4157aac89368d6278332ee2aa1 +0316b981e5f2fa1525e893c5d94c59c847a8c386 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/memory.d b/libphobos/libdruntime/core/memory.d index f25ba6f..27c84e7f 100644 --- a/libphobos/libdruntime/core/memory.d +++ b/libphobos/libdruntime/core/memory.d @@ -1229,7 +1229,10 @@ void __delete(T)(ref T x) @system else static if (is(T == U*, U)) { static if (is(U == struct)) - _destructRecurse(*x); + { + if (x) + _destructRecurse(*x); + } } else static if (is(T : E[], E)) { @@ -1334,6 +1337,10 @@ unittest assert(a is null); assert(dtorCalled); assert(GC.addrOf(cast(void*) a) == null); + + // https://issues.dlang.org/show_bug.cgi?id=22779 + A *aptr; + __delete(aptr); } /// Deleting arrays diff --git a/libphobos/libdruntime/core/stdc/math.d b/libphobos/libdruntime/core/stdc/math.d index 0c5da0b..0393ea5 100644 --- a/libphobos/libdruntime/core/stdc/math.d +++ b/libphobos/libdruntime/core/stdc/math.d @@ -90,6 +90,13 @@ else version (DragonFlyBSD) /// enum int FP_ILOGBNAN = int.max; } +else version (Solaris) +{ + /// + enum int FP_ILOGB0 = -int.max; + /// + enum int FP_ILOGBNAN = int.max; +} else version (CRuntime_Bionic) { /// @@ -1380,18 +1387,128 @@ else version (DragonFlyBSD) } else version (Solaris) { - pure int __isnanf(float x); - pure int __isnan(double x); - pure int __isnanl(real x); + enum + { + FP_INFINITE = 3, + FP_NAN = 4, + FP_NORMAL = 2, + FP_SUBNORMAL = 1, + FP_ZERO = 0, + } + + enum + { + /// + FP_FAST_FMA = 0, + /// + FP_FAST_FMAF = 0, + /// + FP_FAST_FMAL = 0, + } + + extern (D) + { + //int fpclassify(real-floating x); + /// + pure int fpclassify(float x) + { + return isnan(x) ? FP_NAN : isinf(x) ? FP_INFINITE : + isnormal(x) ? FP_NORMAL : x == 0.0f ? FP_ZERO : + FP_SUBNORMAL; + } + + /// + pure int fpclassify(double x) + { + return isnan(x) ? FP_NAN : isinf(x) ? FP_INFINITE : + isnormal(x) ? FP_NORMAL : x == 0.0 ? FP_ZERO : + FP_SUBNORMAL; + } + + /// + pure int fpclassify(real x) + { + return isnan(x) ? FP_NAN : isinf(x) ? FP_INFINITE : + isnormal(x) ? FP_NORMAL : x == 0.0L ? FP_ZERO : + FP_SUBNORMAL; + } + + //int isfinite(real-floating x); + /// + pure int isfinite(float x) { return !isnan(x) && !isinf(x); } + /// + pure int isfinite(double x) { return !isnan(x) && !isinf(x); } + /// + pure int isfinite(real x) { return !isnan(x) && !isinf(x); } + + //int isinf(real-floating x); + /// + pure int isinf(float x) { return x == float.infinity || x == -float.infinity; } + /// + pure int isinf(double x) { return x == double.infinity || x == -double.infinity; } + /// + pure int isinf(real x) { return x == real.infinity || x == -real.infinity; } //int isnan(real-floating x); - /// - pragma(mangle, "__isnanf") pure int isnan(float x); /// - pragma(mangle, "__isnan") pure int isnan(double x); + pure int isnan(float x) { return x != x; } /// - pragma(mangle, real.sizeof == double.sizeof ? "__isnan" : "__isnanl") - pure int isnan(real x); + pure int isnan(double x) { return x != x; } + /// + pure int isnan(real x) { return x != x; } + + //int isnormal(real-floating x); + /// + pure int isnormal(float x) + { + import core.math; + return isfinite(x) && fabs(x) >= float.min_normal; + } + /// + pure int isnormal(double x) + { + import core.math; + return isfinite(x) && fabs(x) >= double.min_normal; + } + /// + pure int isnormal(real x) + { + import core.math; + return isfinite(x) && fabs(x) >= real.min_normal; + } + + //int signbit(real-floating x); + /// + pure int signbit(float x) + { + version (SPARC_Any) + return cast(int)(*cast(uint*)&x >> 31); + else version (X86_Any) + return cast(int)(*cast(uint*)&x >> 31); + else + static assert(false, "Architecture not supported."); + } + /// + pure int signbit(double x) + { + version (SPARC_Any) + return cast(int)(*cast(uint*)&x >> 31); + else version (X86_Any) + return cast(int)((cast(uint*)&x)[1] >> 31); + else + static assert(false, "Architecture not supported."); + } + /// + pure int signbit(real x) + { + version (SPARC_Any) + return cast(int)(*cast(uint*)&x >> 31); + else version (X86_Any) + return cast(int)((cast(ushort *)&x)[4] >> 15); + else + static assert(false, "Architecture not supported."); + } + } } else version (CRuntime_Bionic) { diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d index 0dcdb6e..cd53f0a 100644 --- a/libphobos/libdruntime/core/stdc/stdio.d +++ b/libphobos/libdruntime/core/stdc/stdio.d @@ -983,7 +983,7 @@ else version (NetBSD) _IONBF = 2, } - private extern __gshared FILE[3] __sF; + private extern shared FILE[3] __sF; @property auto __stdin()() { return &__sF[0]; } @property auto __stdout()() { return &__sF[1]; } @property auto __stderr()() { return &__sF[2]; } @@ -1006,7 +1006,7 @@ else version (OpenBSD) _IONBF = 2, } - private extern __gshared FILE[3] __sF; + private extern shared FILE[3] __sF; @property auto __stdin()() { return &__sF[0]; } @property auto __stdout()() { return &__sF[1]; } @property auto __stderr()() { return &__sF[2]; } @@ -1061,11 +1061,11 @@ else version (Solaris) private extern shared FILE[_NFILE] __iob; /// - shared stdin = &__iob[0]; + @property auto stdin()() { return &__iob[0]; } /// - shared stdout = &__iob[1]; + @property auto stdout()() { return &__iob[1]; } /// - shared stderr = &__iob[2]; + @property auto stderr()() { return &__iob[2]; } } else version (CRuntime_Bionic) { @@ -1082,11 +1082,11 @@ else version (CRuntime_Bionic) private extern shared FILE[3] __sF; /// - shared stdin = &__sF[0]; + @property auto stdin()() { return &__sF[0]; } /// - shared stdout = &__sF[1]; + @property auto stdout()() { return &__sF[1]; } /// - shared stderr = &__sF[2]; + @property auto stderr()() { return &__sF[2]; } } else version (CRuntime_Musl) { diff --git a/libphobos/libdruntime/core/stdcpp/exception.d b/libphobos/libdruntime/core/stdcpp/exception.d index d65cd8d..d533996 100644 --- a/libphobos/libdruntime/core/stdcpp/exception.d +++ b/libphobos/libdruntime/core/stdcpp/exception.d @@ -69,7 +69,7 @@ version (GenericBaseException) { @nogc: /// - this() nothrow {} + extern(D) this() nothrow {} /// @weak ~this() nothrow {} // HACK: this should extern, but then we have link errors! @@ -77,7 +77,7 @@ version (GenericBaseException) @weak const(char)* what() const nothrow { return "unknown"; } // HACK: this should extern, but then we have link errors! protected: - this(const(char)*, int = 1) nothrow { this(); } // compat with MS derived classes + extern(D) this(const(char)*, int = 1) nothrow { this(); } // compat with MS derived classes } } else version (CppRuntime_DigitalMars) @@ -87,7 +87,7 @@ else version (CppRuntime_DigitalMars) { @nogc: /// - this() nothrow {} + extern(D) this() nothrow {} //virtual ~this(); void dtor() { } // reserve slot in vtbl[] @@ -105,7 +105,7 @@ else version (CppRuntime_Microsoft) { @nogc: /// - this(const(char)* message = "unknown", int = 1) nothrow { msg = message; } + extern(D) this(const(char)* message = "unknown", int = 1) nothrow { msg = message; } /// @weak ~this() nothrow {} @@ -131,7 +131,7 @@ class bad_exception : exception { @nogc: /// - this(const(char)* message = "bad exception") { super(message); } + extern(D) this(const(char)* message = "bad exception") nothrow { super(message); } version (GenericBaseException) { diff --git a/libphobos/libdruntime/core/stdcpp/typeinfo.d b/libphobos/libdruntime/core/stdcpp/typeinfo.d index 53b25c5..24f2938 100644 --- a/libphobos/libdruntime/core/stdcpp/typeinfo.d +++ b/libphobos/libdruntime/core/stdcpp/typeinfo.d @@ -18,10 +18,10 @@ version (CppRuntime_DigitalMars) import core.stdcpp.exception; extern (C++, "std"): - @nogc: class type_info { + @nogc: void* pdata; public: @@ -41,8 +41,9 @@ version (CppRuntime_DigitalMars) class bad_cast : exception { - this() nothrow { } - this(const bad_cast) nothrow { } + @nogc: + extern(D) this() nothrow { } + extern(D) this(const bad_cast) nothrow { } //bad_cast operator=(const bad_cast) nothrow { return this; } //virtual ~this() nothrow; override const(char)* what() const nothrow; @@ -50,8 +51,9 @@ version (CppRuntime_DigitalMars) class bad_typeid : exception { - this() nothrow { } - this(const bad_typeid) nothrow { } + @nogc: + extern(D) this() nothrow { } + extern(D) this(const bad_typeid) nothrow { } //bad_typeid operator=(const bad_typeid) nothrow { return this; } //virtual ~this() nothrow; override const (char)* what() const nothrow; @@ -62,7 +64,6 @@ else version (CppRuntime_Microsoft) import core.stdcpp.exception; extern (C++, "std"): - @nogc: struct __type_info_node { @@ -74,6 +75,7 @@ else version (CppRuntime_Microsoft) class type_info { + @nogc: @weak ~this() nothrow {} //bool operator==(const type_info rhs) const; //bool operator!=(const type_info rhs) const; @@ -88,13 +90,15 @@ else version (CppRuntime_Microsoft) class bad_cast : exception { - this(const(char)* msg = "bad cast") @nogc nothrow { super(msg); } + @nogc: + extern(D) this(const(char)* msg = "bad cast") nothrow { super(msg); } //virtual ~this(); } class bad_typeid : exception { - this(const(char)* msg = "bad typeid") @nogc nothrow { super(msg); } + @nogc: + extern(D) this(const(char)* msg = "bad typeid") nothrow { super(msg); } //virtual ~this(); } } @@ -108,10 +112,10 @@ else version (CppRuntime_Gcc) } extern (C++, "std"): - @nogc: abstract class type_info { + @nogc: @weak ~this() {} @weak final const(char)* name() const nothrow { @@ -133,19 +137,21 @@ else version (CppRuntime_Gcc) protected: const(char)* _name; - this(const(char)* name) { _name = name; } + extern(D) this(const(char)* name) { _name = name; } } class bad_cast : exception { - this() nothrow {} + @nogc: + extern(D) this() nothrow {} //~this(); @weak override const(char)* what() const nothrow { return "bad cast"; } } class bad_typeid : exception { - this() nothrow {} + @nogc: + extern(D) this() nothrow {} //~this(); @weak override const(char)* what() const nothrow { return "bad typeid"; } } @@ -155,10 +161,10 @@ else version (CppRuntime_Clang) import core.stdcpp.exception; extern (C++, "std"): - @nogc: abstract class type_info { + @nogc: @weak ~this() {} @weak final const(char)* name() const nothrow { @@ -173,19 +179,21 @@ else version (CppRuntime_Clang) protected: const(char)* __type_name; - this(const(char)* __n) { __type_name = __n; } + extern(D) this(const(char)* __n) { __type_name = __n; } } class bad_cast : exception { - this() nothrow {} + @nogc: + extern(D) this() nothrow {} //~this(); @weak override const(char)* what() const nothrow { return "bad cast"; } } class bad_typeid : exception { - this() nothrow {} + @nogc: + extern(D) this() nothrow {} //~this(); @weak override const(char)* what() const nothrow { return "bad typeid"; } } diff --git a/libphobos/libdruntime/core/sys/posix/locale.d b/libphobos/libdruntime/core/sys/posix/locale.d index 18558a2..85e2fb6 100644 --- a/libphobos/libdruntime/core/sys/posix/locale.d +++ b/libphobos/libdruntime/core/sys/posix/locale.d @@ -31,7 +31,7 @@ version (FreeBSD) version = DarwinBSDLocale; version (NetBSD) version = DarwinBSDLocale; -version (DragonflyBSD) +version (DragonFlyBSD) version = DarwinBSDLocale; version (CRuntime_Glibc) diff --git a/libphobos/libdruntime/object.d b/libphobos/libdruntime/object.d index 56a2efe..a15616c 100644 --- a/libphobos/libdruntime/object.d +++ b/libphobos/libdruntime/object.d @@ -4445,7 +4445,11 @@ void destroy(bool initialize = true, T)(T obj) if (is(T == class)) } } else - rt_finalize(cast(void*)obj); + { + // Bypass overloaded opCast + auto ptr = (() @trusted => *cast(void**) &obj)(); + rt_finalize(ptr); + } } /// ditto @@ -4707,6 +4711,18 @@ nothrow unittest assert(C.dtorCount == 1); } +// https://issues.dlang.org/show_bug.cgi?id=22832 +nothrow unittest +{ + static struct A {} + static class B + { + A opCast(T : A)() { return A(); } + } + + destroy(B.init); +} + /// ditto void destroy(bool initialize = true, T)(ref T obj) if (__traits(isStaticArray, T)) diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index e15541e..5fd357c 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -41aaf8c2636df0e2e3ad39933b321d2b4cd231fa +a1f8c4c0700ce4e256f4130ad7883c6ea3890901 The first line of this file holds the git revision number of the last merge done from the dlang/phobos repository. diff --git a/libphobos/src/std/datetime/systime.d b/libphobos/src/std/datetime/systime.d index 9b2a844..db325f7 100644 --- a/libphobos/src/std/datetime/systime.d +++ b/libphobos/src/std/datetime/systime.d @@ -8713,13 +8713,14 @@ public: /++ Creates a $(LREF SysTime) from a string with the format - YYYYMMDDTHHMMSS.FFFFFFFTZ (where F is fractional seconds is the time - zone). Whitespace is stripped from the given string. + YYYYMMDDTHHMMSS.FFFFFFFTZ (where F is fractional seconds and TZ + is the time zone). Whitespace is stripped from the given string. - The exact format is exactly as described in `toISOString` except that - trailing zeroes are permitted - including having fractional seconds with - all zeroes. However, a decimal point with nothing following it is - invalid. Also, while $(LREF toISOString) will never generate a string + The exact format is exactly as described in $(LREF toISOString) except + that trailing zeroes are permitted - including having fractional seconds + with all zeroes. The time zone and fractional seconds are optional, + however, a decimal point with nothing following it is invalid. + Also, while $(LREF toISOString) will never generate a string with more than 7 digits in the fractional seconds (because that's the limit with hecto-nanosecond precision), it will allow more than 7 digits in order to read strings from other sources that have higher precision @@ -9024,13 +9025,14 @@ public: /++ Creates a $(LREF SysTime) from a string with the format - YYYY-MM-DDTHH:MM:SS.FFFFFFFTZ (where F is fractional seconds is the - time zone). Whitespace is stripped from the given string. + YYYY-MM-DDTHH:MM:SS.FFFFFFFTZ (where F is fractional seconds and TZ + is the time zone). Whitespace is stripped from the given string. - The exact format is exactly as described in `toISOExtString` + The exact format is exactly as described in $(LREF toISOExtString) except that trailing zeroes are permitted - including having fractional - seconds with all zeroes. However, a decimal point with nothing following - it is invalid. Also, while $(LREF toISOExtString) will never generate a + seconds with all zeroes. The time zone and fractional seconds are + optional, however, a decimal point with nothing following it is invalid. + Also, while $(LREF toISOExtString) will never generate a string with more than 7 digits in the fractional seconds (because that's the limit with hecto-nanosecond precision), it will allow more than 7 digits in order to read strings from other sources that have higher @@ -9273,13 +9275,14 @@ public: /++ Creates a $(LREF SysTime) from a string with the format - YYYY-MM-DD HH:MM:SS.FFFFFFFTZ (where F is fractional seconds is the - time zone). Whitespace is stripped from the given string. + YYYY-Mon-DD HH:MM:SS.FFFFFFFTZ (where F is fractional seconds and TZ + is the time zone). Whitespace is stripped from the given string. - The exact format is exactly as described in `toSimpleString` except + The exact format is exactly as described in $(LREF toSimpleString) except that trailing zeroes are permitted - including having fractional seconds - with all zeroes. However, a decimal point with nothing following it is - invalid. Also, while $(LREF toSimpleString) will never generate a + with all zeroes. The time zone and fractional seconds are optional, + however, a decimal point with nothing following it is invalid. + Also, while $(LREF toSimpleString) will never generate a string with more than 7 digits in the fractional seconds (because that's the limit with hecto-nanosecond precision), it will allow more than 7 digits in order to read strings from other sources that have higher diff --git a/libphobos/src/std/sumtype.d b/libphobos/src/std/sumtype.d index 0dd636e..3833c84 100644 --- a/libphobos/src/std/sumtype.d +++ b/libphobos/src/std/sumtype.d @@ -1569,27 +1569,7 @@ private enum bool isSumTypeInstance(T) = is(T == SumType!Args, Args...); } /// True if `T` is a [SumType] or implicitly converts to one, otherwise false. -template isSumType(T) -{ - static if (is(T : SumType!Args, Args...)) - { - enum isSumType = true; - } - else static if (is(T == struct) && __traits(getAliasThis, T).length > 0) - { - // Workaround for https://issues.dlang.org/show_bug.cgi?id=21975 - import std.traits : ReturnType; - - alias AliasThisType = ReturnType!((T t) => - __traits(getMember, t, __traits(getAliasThis, T)[0]) - ); - enum isSumType = .isSumType!AliasThisType; - } - else - { - enum isSumType = false; - } -} +enum bool isSumType(T) = is(T : SumType!Args, Args...); /// @safe unittest @@ -1610,25 +1590,6 @@ template isSumType(T) assert(!isSumType!ContainsSumType); } -@safe unittest -{ - static struct AliasThisVar(T) - { - SumType!T payload; - alias payload this; - } - - static struct AliasThisFunc(T) - { - SumType!T payload; - ref get() { return payload; } - alias get this; - } - - static assert(isSumType!(AliasThisVar!int)); - static assert(isSumType!(AliasThisFunc!int)); -} - /** * Calls a type-appropriate function with the value held in a [SumType]. * |