aboutsummaryrefslogtreecommitdiff
path: root/libphobos
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-02-20 20:02:23 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2022-02-20 23:37:32 +0100
commit6384eff56dba1fac071c1b525f7e49cf03f2737f (patch)
tree7263a4a6ec603a81f6df660f4f6b19a4607513fc /libphobos
parente49508ac6b36adb8a2056c5a1fb6e0178de2439d (diff)
downloadgcc-6384eff56dba1fac071c1b525f7e49cf03f2737f.zip
gcc-6384eff56dba1fac071c1b525f7e49cf03f2737f.tar.gz
gcc-6384eff56dba1fac071c1b525f7e49cf03f2737f.tar.bz2
d: Merge upstream dmd cb49e99f8, druntime 55528bd1, phobos 1a3e80ec2.
D front-end changes: - Import dmd v2.099.0-beta.1. - It's now an error to use `alias this' for partial assignment. - The `delete' keyword has been removed from the language. - Using `this' and `super' as types has been removed from the language, the parser no longer specially handles this wrong code with an informative error. D Runtime changes: - Import druntime v2.099.0-beta.1. Phobos changes: - Import phobos v2.099.0-beta.1. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd cb49e99f8. * dmd/VERSION: Update version to v2.099.0-beta.1. * decl.cc (layout_class_initializer): Update call to NewExp::create. * expr.cc (ExprVisitor::visit (DeleteExp *)): Remove handling of deleting arrays and pointers. (ExprVisitor::visit (DotVarExp *)): Convert complex types to the front-end library type representing them. (ExprVisitor::visit (StringExp *)): Use getCodeUnit instead of charAt to get the value of each index in a string expression. * runtime.def (DELMEMORY): Remove. (DELARRAYT): Remove. * types.cc (TypeVisitor::visit (TypeEnum *)): Handle anonymous enums. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 55528bd1. * src/MERGE: Merge upstream phobos 1a3e80ec2. * testsuite/libphobos.hash/test_hash.d: Update. * testsuite/libphobos.betterc/test19933.d: New test.
Diffstat (limited to 'libphobos')
-rw-r--r--libphobos/libdruntime/MERGE2
-rw-r--r--libphobos/libdruntime/__builtins.di65
-rw-r--r--libphobos/libdruntime/core/attribute.d49
-rw-r--r--libphobos/libdruntime/core/bitop.d13
-rw-r--r--libphobos/libdruntime/core/int128.d2
-rw-r--r--libphobos/libdruntime/core/internal/array/appending.d8
-rw-r--r--libphobos/libdruntime/core/internal/array/comparison.d33
-rw-r--r--libphobos/libdruntime/core/internal/convert.d22
-rw-r--r--libphobos/libdruntime/core/lifetime.d4
-rw-r--r--libphobos/libdruntime/core/math.d1
-rw-r--r--libphobos/libdruntime/core/runtime.d2
-rw-r--r--libphobos/libdruntime/core/stdc/stdio.d17
-rw-r--r--libphobos/libdruntime/core/sys/linux/config.d3
-rw-r--r--libphobos/libdruntime/core/sys/linux/dlfcn.d22
-rw-r--r--libphobos/libdruntime/core/sys/linux/errno.d2
-rw-r--r--libphobos/libdruntime/core/sys/linux/netinet/in_.d10
-rw-r--r--libphobos/libdruntime/core/sys/linux/string.d2
-rw-r--r--libphobos/libdruntime/core/sys/linux/sys/mman.d72
-rw-r--r--libphobos/libdruntime/core/sys/posix/aio.d132
-rw-r--r--libphobos/libdruntime/core/sys/posix/config.d58
-rw-r--r--libphobos/libdruntime/core/sys/posix/spawn.d12
-rw-r--r--libphobos/libdruntime/core/sys/posix/sys/ipc.d65
-rw-r--r--libphobos/libdruntime/core/sys/posix/sys/mman.d4
-rw-r--r--libphobos/libdruntime/core/sys/posix/sys/shm.d12
-rw-r--r--libphobos/libdruntime/core/sys/posix/sys/socket.d32
-rw-r--r--libphobos/libdruntime/core/sys/posix/sys/stat.d24
-rw-r--r--libphobos/libdruntime/core/sys/posix/sys/statvfs.d2
-rw-r--r--libphobos/libdruntime/core/sys/posix/sys/types.d2
-rw-r--r--libphobos/libdruntime/object.d4
-rw-r--r--libphobos/libdruntime/rt/util/typeinfo.d289
-rw-r--r--libphobos/src/MERGE2
-rw-r--r--libphobos/src/std/algorithm/internal.d2
-rw-r--r--libphobos/src/std/bigint.d16
-rw-r--r--libphobos/src/std/container/rbtree.d16
-rw-r--r--libphobos/src/std/conv.d2
-rw-r--r--libphobos/src/std/file.d27
-rw-r--r--libphobos/src/std/functional.d9
-rw-r--r--libphobos/src/std/internal/math/biguintcore.d6
-rw-r--r--libphobos/src/std/socket.d17
-rw-r--r--libphobos/src/std/sumtype.d20
-rw-r--r--libphobos/src/std/typecons.d42
-rw-r--r--libphobos/src/std/uni/package.d2
-rw-r--r--libphobos/src/std/zip.d35
-rw-r--r--libphobos/testsuite/libphobos.betterc/test19933.d11
-rw-r--r--libphobos/testsuite/libphobos.hash/test_hash.d2
45 files changed, 615 insertions, 559 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 251d78d..49f6ae2 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-dbd0c874a345438b8b4379a67525a933436d039a
+55528bd1e963d858eaa63901fc818b957c349fbc
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/__builtins.di b/libphobos/libdruntime/__builtins.di
index cd64881..e5c448e 100644
--- a/libphobos/libdruntime/__builtins.di
+++ b/libphobos/libdruntime/__builtins.di
@@ -38,3 +38,68 @@ alias __builtin_va_copy = core.stdc.stdarg.va_copy;
/* dmd's ImportC rewrites __builtin_va_arg into an instantiation of va_arg
*/
alias va_arg = core.stdc.stdarg.va_arg;
+
+version (CRuntime_Microsoft)
+{
+ //https://docs.microsoft.com/en-us/cpp/cpp/int8-int16-int32-int64?view=msvc-170
+ alias __int8 = byte;
+ alias __int16 = short;
+ alias __int32 = int;
+ alias __int64 = long;
+}
+
+/*********** floating point *************/
+
+/* https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
+ */
+
+version (DigitalMars)
+{
+ double __builtin_inf()() { return double.infinity; }
+ float __builtin_inff()() { return float.infinity; }
+ real __builtin_infl()() { return real.infinity; }
+
+ alias __builtin_huge_val = __builtin_inf;
+ alias __builtin_huge_valf = __builtin_inff;
+ alias __builtin_huge_vall = __builtin_infl;
+
+ import core.stdc.math;
+
+ alias __builtin_fabs = core.stdc.math.fabs;
+ alias __builtin_fabsf = core.stdc.math.fabsf;
+ alias __builtin_fabsl = core.stdc.math.fabsl;
+
+ ushort __builtin_bswap16()(ushort value)
+ {
+ import core.bitop;
+ return core.bitop.byteswap(value);
+ }
+
+ uint __builtin_bswap32()(uint value)
+ {
+ import core.bitop;
+ return core.bitop.bswap(value);
+ }
+
+ ulong __builtin_bswap64()(ulong value)
+ {
+ import core.bitop;
+ return core.bitop.bswap(value);
+ }
+
+ // Stub these out to no-ops
+ int __builtin_constant_p(T)(T exp) { return 0; } // should be something like __traits(compiles, enum X = expr)
+ long __builtin_expect()(long exp, long c) { return exp; }
+ void* __builtin_assume_aligned()(const void* p, size_t align_, ...) { return cast(void*)p; }
+
+ // https://releases.llvm.org/13.0.0/tools/clang/docs/LanguageExtensions.html#builtin-assume
+ void __builtin_assume(T)(lazy T arg) { }
+
+ /* Header on macOS for arm64 references this.
+ * Don't need to implement it, it just needs to compile
+ */
+ align (16) struct __uint128_t
+ {
+ ulong a, b;
+ }
+}
diff --git a/libphobos/libdruntime/core/attribute.d b/libphobos/libdruntime/core/attribute.d
index b0b973f..69b20f0 100644
--- a/libphobos/libdruntime/core/attribute.d
+++ b/libphobos/libdruntime/core/attribute.d
@@ -241,3 +241,52 @@ version (UdaGNUAbiTag) struct gnuAbiTag
this.tags = tags;
}
}
+
+/**
+ * Use this attribute to ensure that values of a `struct` or `union` type are
+ * not discarded.
+ *
+ * The value of an expression is considered to be discarded if
+ *
+ * $(UL
+ * $(LI
+ * the expression is the top-level expression in a statement or the
+ * left-hand expression in a comma expression, and
+ * ),
+ * $(LI
+ * the expression is not an assignment (`=`, `+=`, etc.), increment
+ * (`++`), or decrement (`--`) expression.
+ * ),
+ * )
+ *
+ * If the declaration of a `struct` or `union` type has the `@mustuse`
+ * attribute, the compiler will emit an error any time a value of that type
+ * would be discarded.
+ *
+ * Currently, `@mustuse` is only recognized by the compiler when attached to
+ * `struct` and `union` declarations. To allow for future expansion, attaching
+ * `@mustuse` to a `class`, `interface`, `enum`, or function declaration is
+ * currently forbidden, and will result in a compile-time error. All other uses
+ * of `@mustuse` are ignored.
+ *
+ * Examples:
+ * ---
+ * @mustuse struct ErrorCode { int value; }
+ *
+ * extern(C) ErrorCode doSomething();
+ *
+ * void main()
+ * {
+ * // error: would discard a value of type ErrorCode
+ * //doSomething();
+ *
+ * ErrorCode result;
+ * // ok: value is assigned to a variable
+ * result = doSomething();
+ *
+ * // ok: can ignore the value explicitly with a cast
+ * cast(void) doSomething();
+ * }
+ * ---
+ */
+enum mustuse;
diff --git a/libphobos/libdruntime/core/bitop.d b/libphobos/libdruntime/core/bitop.d
index 40f2242..59445f0 100644
--- a/libphobos/libdruntime/core/bitop.d
+++ b/libphobos/libdruntime/core/bitop.d
@@ -758,19 +758,6 @@ version (DigitalMars) version (AnyX86)
}
-// @@@DEPRECATED_2.099@@@
-deprecated("volatileLoad has been moved to core.volatile. Use core.volatile.volatileLoad instead.")
-{
- public import core.volatile : volatileLoad;
-}
-
-// @@@DEPRECATED_2.099@@@
-deprecated("volatileStore has been moved to core.volatile. Use core.volatile.volatileStore instead.")
-{
- public import core.volatile : volatileStore;
-}
-
-
/**
* Reverses the order of bits in a 32-bit integer.
*/
diff --git a/libphobos/libdruntime/core/int128.d b/libphobos/libdruntime/core/int128.d
index aad2cf2..2f628c0 100644
--- a/libphobos/libdruntime/core/int128.d
+++ b/libphobos/libdruntime/core/int128.d
@@ -801,6 +801,7 @@ unittest
const Cm10_0 = inc(com(C10_0)); // Cent(0, -10);
const Cm10_1 = inc(com(C10_1)); // Cent(-1, -11);
const Cm10_3 = inc(com(C10_3)); // Cent(-3, -11);
+ const Cm20_0 = inc(com(C20_0)); // Cent(0, -20);
enum Cs_3 = Cent(3, I.min);
@@ -904,6 +905,7 @@ unittest
assert(mul(C9_3, C10) == C90_30);
assert(mul(Cs_3, C10) == C30);
assert(mul(Cm10, Cm10) == C100);
+ assert(mul(C20_0, Cm1) == Cm20_0);
assert( or(C4_8, C3_1) == C7_9);
assert(and(C4_8, C7_9) == C4_8);
diff --git a/libphobos/libdruntime/core/internal/array/appending.d b/libphobos/libdruntime/core/internal/array/appending.d
index 1e58ddc..172263c 100644
--- a/libphobos/libdruntime/core/internal/array/appending.d
+++ b/libphobos/libdruntime/core/internal/array/appending.d
@@ -35,14 +35,14 @@ template _d_arrayappendcTXImpl(Tarr : T[], T)
* is temporarily declared `@trusted pure` until the implementation can be brought up to modern D expectations.
*/
static if (isCopyingNothrow!T) // `nothrow` deduction doesn't work, so this is needed
- ref Tarr _d_arrayappendcTX(return scope ref Tarr px, size_t n) @trusted pure nothrow
+ ref Tarr _d_arrayappendcTX(return ref scope Tarr px, size_t n) @trusted pure nothrow
{
pragma(inline, false);
mixin(_d_arrayappendcTXBody);
}
else
- ref Tarr _d_arrayappendcTX(return scope ref Tarr px, size_t n) @trusted pure nothrow
+ ref Tarr _d_arrayappendcTX(return ref scope Tarr px, size_t n) @trusted pure nothrow
{
pragma(inline, false);
@@ -96,14 +96,14 @@ template _d_arrayappendTImpl(Tarr : T[], T)
* is temporarily declared `@trusted pure` until the implementation can be brought up to modern D expectations.
*/
static if (isCopyingNothrow!T)
- ref Tarr _d_arrayappendT(return scope ref Tarr x, scope Tarr y) @trusted pure nothrow
+ ref Tarr _d_arrayappendT(return ref scope Tarr x, scope Tarr y) @trusted pure nothrow
{
pragma(inline, false);
mixin(_d_arrayappendTBody);
}
else
- ref Tarr _d_arrayappendT(return scope ref Tarr x, scope Tarr y) @trusted pure
+ ref Tarr _d_arrayappendT(return ref scope Tarr x, scope Tarr y) @trusted pure
{
pragma(inline, false);
diff --git a/libphobos/libdruntime/core/internal/array/comparison.d b/libphobos/libdruntime/core/internal/array/comparison.d
index 1a68b9b..821f96e 100644
--- a/libphobos/libdruntime/core/internal/array/comparison.d
+++ b/libphobos/libdruntime/core/internal/array/comparison.d
@@ -60,24 +60,21 @@ int __cmp(T)(scope const T[] lhs, scope const T[] rhs) @trusted
immutable len = lhs.length <= rhs.length ? lhs.length : rhs.length;
foreach (const u; 0 .. len)
{
- static if (__traits(isFloating, T))
+ auto a = lhs.ptr[u], b = rhs.ptr[u];
+ static if (is(T : creal))
{
- immutable a = lhs.ptr[u], b = rhs.ptr[u];
- static if (is(T == cfloat) || is(T == cdouble)
- || is(T == creal))
- {
- // Use rt.cmath2._Ccmp instead ?
- auto r = (a.re > b.re) - (a.re < b.re);
- if (!r) r = (a.im > b.im) - (a.im < b.im);
- }
- else
- {
- const r = (a > b) - (a < b);
- }
- if (r) return r;
+ // Use rt.cmath2._Ccmp instead ?
+ // Also: if NaN is present, numbers will appear equal.
+ auto r = (a.re > b.re) - (a.re < b.re);
+ if (!r) r = (a.im > b.im) - (a.im < b.im);
+ }
+ else
+ {
+ // This pattern for three-way comparison is better than conditional operators
+ // See e.g. https://godbolt.org/z/3j4vh1
+ const r = (a > b) - (a < b);
}
- else if (lhs.ptr[u] != rhs.ptr[u])
- return lhs.ptr[u] < rhs.ptr[u] ? -1 : 1;
+ if (r) return r;
}
return (lhs.length > rhs.length) - (lhs.length < rhs.length);
}
@@ -117,8 +114,8 @@ if (!__traits(isScalar, T1) && !__traits(isScalar, T2))
}
else static if (__traits(compiles, at(s1, u) < at(s2, u)))
{
- if (at(s1, u) != at(s2, u))
- return at(s1, u) < at(s2, u) ? -1 : 1;
+ if (int result = (at(s1, u) > at(s2, u)) - (at(s1, u) < at(s2, u)))
+ return result;
}
else
{
diff --git a/libphobos/libdruntime/core/internal/convert.d b/libphobos/libdruntime/core/internal/convert.d
index a876fcc..92eb243 100644
--- a/libphobos/libdruntime/core/internal/convert.d
+++ b/libphobos/libdruntime/core/internal/convert.d
@@ -741,28 +741,6 @@ const(ubyte)[] toUbyte(T)(const ref scope T val) if (is(T == __vector))
}
}
-// @@@DEPRECATED_2022-02@@@
-deprecated
-@trusted pure nothrow @nogc
-const(ubyte)[] toUbyte(T)(const ref return scope T val) if (__traits(isFloating, T) && is(T : creal))
-{
- if (__ctfe)
- {
- auto re = val.re;
- auto im = val.im;
- auto a = re.toUbyte();
- auto b = im.toUbyte();
- ubyte[] result = ctfe_alloc(a.length + b.length);
- result[0 .. a.length] = a[0 .. a.length];
- result[a.length .. $] = b[0 .. b.length];
- return result;
- }
- else
- {
- return (cast(const(ubyte)*)&val)[0 .. T.sizeof];
- }
-}
-
@trusted pure nothrow @nogc
const(ubyte)[] toUbyte(T)(const ref return scope T val) if (is(T == enum))
{
diff --git a/libphobos/libdruntime/core/lifetime.d b/libphobos/libdruntime/core/lifetime.d
index 091269a..3a7c8e0 100644
--- a/libphobos/libdruntime/core/lifetime.d
+++ b/libphobos/libdruntime/core/lifetime.d
@@ -2646,9 +2646,9 @@ T _d_newThrowable(T, Args...)(auto ref Args args) @trusted
{
debug(PRINTF) printf("_d_newThrowable(%s)\n", cast(char*) T.stringof);
- import core.stdc.stdlib : malloc;
+ import core.memory : pureMalloc;
auto init = __traits(initSymbol, T);
- void* p = malloc(init.length);
+ void* p = pureMalloc(init.length);
if (!p)
{
import core.exception : onOutOfMemoryError;
diff --git a/libphobos/libdruntime/core/math.d b/libphobos/libdruntime/core/math.d
index 4d46b67..30fc130 100644
--- a/libphobos/libdruntime/core/math.d
+++ b/libphobos/libdruntime/core/math.d
@@ -36,6 +36,7 @@ nothrow:
* greater than long.max, the result is
* indeterminate.
*/
+deprecated("rndtonl is to be removed by 2.100. Please use round instead")
extern (C) real rndtonl(real x);
pure:
diff --git a/libphobos/libdruntime/core/runtime.d b/libphobos/libdruntime/core/runtime.d
index 81d2d26..d1378af 100644
--- a/libphobos/libdruntime/core/runtime.d
+++ b/libphobos/libdruntime/core/runtime.d
@@ -285,7 +285,7 @@ struct Runtime
* an appropriate calling context from which to begin the trace.
*
* Params:
- * h = The new trace handler. Set to null to use the default handler.
+ * h = The new trace handler. Set to null to disable exception backtracing.
*/
extern(C) pragma(mangle, "rt_setTraceHandler") static @property void traceHandler(TraceHandler h);
diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d
index c76b922..0dcdb6e 100644
--- a/libphobos/libdruntime/core/stdc/stdio.d
+++ b/libphobos/libdruntime/core/stdc/stdio.d
@@ -700,9 +700,8 @@ else version (Solaris)
}
else version (CRuntime_Bionic)
{
- import core.sys.posix.sys.types : off_t;
///
- alias off_t fpos_t;
+ alias c_long fpos_t; // couldn't use off_t because of static if issue
///
struct __sFILE
@@ -745,12 +744,10 @@ else version (CRuntime_UClibc)
import core.stdc.stddef : wchar_t;
import core.sys.posix.sys.types : ssize_t, pthread_mutex_t;
- alias long off_t;
-
///
struct fpos_t
{
- off_t __pos;
+ long __pos; // couldn't use off_t because of static if issue
mbstate_t __state;
int __mblen_pending;
}
@@ -759,7 +756,7 @@ else version (CRuntime_UClibc)
{
ssize_t function(void* __cookie, char* __buf, size_t __bufsize) read;
ssize_t function(void* __cookie, const char* __buf, size_t __bufsize) write;
- int function(void* __cookie, off_t* __pos, int __whence) seek;
+ int function(void* __cookie, long* __pos, int __whence) seek;
int function(void* __cookie) close;
}
@@ -900,12 +897,14 @@ else version (CRuntime_Microsoft)
extern shared void function() _fcloseallp;
+ FILE* __acrt_iob_func(int hnd); // VS2015+, reimplemented in msvc.d for VS2013-
+
///
- shared FILE* stdin; // = &__iob_func()[0];
+ FILE* stdin()() { return __acrt_iob_func(0); }
///
- shared FILE* stdout; // = &__iob_func()[1];
+ FILE* stdout()() { return __acrt_iob_func(1); }
///
- shared FILE* stderr; // = &__iob_func()[2];
+ FILE* stderr()() { return __acrt_iob_func(2); }
}
else version (CRuntime_Glibc)
{
diff --git a/libphobos/libdruntime/core/sys/linux/config.d b/libphobos/libdruntime/core/sys/linux/config.d
index 03d3e17..5d38244f 100644
--- a/libphobos/libdruntime/core/sys/linux/config.d
+++ b/libphobos/libdruntime/core/sys/linux/config.d
@@ -24,6 +24,9 @@ deprecated("use _DEFAULT_SOURCE")
enum _SVID_SOURCE = true;
}
+deprecated("use _DEFAULT_SOURCE")
enum __USE_MISC = _DEFAULT_SOURCE;
+deprecated("use _ATFILE_SOURCE")
enum __USE_ATFILE = _ATFILE_SOURCE;
+deprecated("use _GNU_SOURCE")
enum __USE_GNU = _GNU_SOURCE;
diff --git a/libphobos/libdruntime/core/sys/linux/dlfcn.d b/libphobos/libdruntime/core/sys/linux/dlfcn.d
index 4a12284..fbb8462 100644
--- a/libphobos/libdruntime/core/sys/linux/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/linux/dlfcn.d
@@ -34,7 +34,7 @@ import core.sys.linux.config;
version (X86_Any)
{
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
- static if (__USE_GNU)
+ static if (_GNU_SOURCE)
{
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
{
@@ -48,7 +48,7 @@ version (X86_Any)
else version (HPPA_Any)
{
// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/hppa/bits/dlfcn.h
- static if (__USE_GNU)
+ static if (_GNU_SOURCE)
{
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
{
@@ -62,7 +62,7 @@ else version (HPPA_Any)
else version (MIPS_Any)
{
// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/mips/bits/dlfcn.h
- static if (__USE_GNU)
+ static if (_GNU_SOURCE)
{
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
{
@@ -76,7 +76,7 @@ else version (MIPS_Any)
else version (PPC_Any)
{
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
- static if (__USE_GNU)
+ static if (_GNU_SOURCE)
{
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
{
@@ -90,7 +90,7 @@ else version (PPC_Any)
else version (ARM_Any)
{
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
- static if (__USE_GNU)
+ static if (_GNU_SOURCE)
{
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
{
@@ -104,7 +104,7 @@ else version (ARM_Any)
else version (RISCV_Any)
{
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
- static if (__USE_GNU)
+ static if (_GNU_SOURCE)
{
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
{
@@ -118,7 +118,7 @@ else version (RISCV_Any)
else version (SPARC_Any)
{
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
- static if (__USE_GNU)
+ static if (_GNU_SOURCE)
{
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
{
@@ -132,7 +132,7 @@ else version (SPARC_Any)
else version (IBMZ_Any)
{
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
- static if (__USE_GNU)
+ static if (_GNU_SOURCE)
{
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
{
@@ -148,7 +148,7 @@ else
// <bits/dlfcn.h>
-static if (__USE_GNU)
+static if (_GNU_SOURCE)
{
enum RTLD_NEXT = cast(void *)-1L;
enum RTLD_DEFAULT = cast(void *)0;
@@ -161,7 +161,7 @@ static if (__USE_GNU)
// int dlclose(void* __handle); // POSIX
// void* dlsym(void* __handle, const scope char* __name); // POSIX
-static if (__USE_GNU)
+static if (_GNU_SOURCE)
{
void* dlmopen(Lmid_t __nsid, const scope char* __file, int __mode);
void* dlvsym(void* __handle, const scope char* __name, const scope char* __version);
@@ -169,7 +169,7 @@ static if (__USE_GNU)
// char* dlerror(); // POSIX
-static if (__USE_GNU)
+static if (_GNU_SOURCE)
{
int dladdr1(void* __address, Dl_info* __info, void** __extra_info, int __flags);
diff --git a/libphobos/libdruntime/core/sys/linux/errno.d b/libphobos/libdruntime/core/sys/linux/errno.d
index 02ae151..d7a39ac 100644
--- a/libphobos/libdruntime/core/sys/linux/errno.d
+++ b/libphobos/libdruntime/core/sys/linux/errno.d
@@ -13,7 +13,7 @@ nothrow:
public import core.stdc.errno;
import core.sys.linux.config;
-static if (__USE_GNU)
+static if (_GNU_SOURCE)
{
extern __gshared char* program_invocation_name, program_invocation_short_name;
alias error_t = int;
diff --git a/libphobos/libdruntime/core/sys/linux/netinet/in_.d b/libphobos/libdruntime/core/sys/linux/netinet/in_.d
index 67bf654..1b428f5 100644
--- a/libphobos/libdruntime/core/sys/linux/netinet/in_.d
+++ b/libphobos/libdruntime/core/sys/linux/netinet/in_.d
@@ -115,7 +115,7 @@ version (linux_libc)
enum IN6ADDR_ANY_INIT = in6_addr.init;
enum IN6ADDR_LOOPBACK_INIT = in6_addr([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
- version (gnu_libc) static if (__USE_MISC)
+ version (gnu_libc) static if (_DEFAULT_SOURCE)
{
struct ip_mreq
{
@@ -174,13 +174,13 @@ version (linux_libc)
extern(D) bool IN6_ARE_ADDR_EQUAL(in6_addr* a, in6_addr* b) pure @safe { return *a == *b; }
- version (gnu_libc) static if (__USE_MISC)
+ version (gnu_libc) static if (_DEFAULT_SOURCE)
{
int bindresvport(int __sockfd, sockaddr_in* __sock_in);
int bindresvport6(int __sockfd, sockaddr_in6* _);
}
- version (gnu_libc) static if (__USE_GNU)
+ version (gnu_libc) static if (_GNU_SOURCE)
{
struct in6_pktinfo
{
@@ -254,7 +254,7 @@ version (linux_libc)
enum IP_DROP_SOURCE_MEMBERSHIP = 40;
enum IP_MSFILTER = 41;
- version (gnu_libc) static if (__USE_MISC)
+ version (gnu_libc) static if (_DEFAULT_SOURCE)
{
enum MCAST_JOIN_GROUP = 42;
enum MCAST_BLOCK_SOURCE = 43;
@@ -307,7 +307,7 @@ version (linux_libc)
enum IP_DEFAULT_MULTICAST_LOOP = 1;
enum IP_MAX_MEMBERSHIPS = 20;
- version (gnu_libc) static if (__USE_MISC)
+ version (gnu_libc) static if (_DEFAULT_SOURCE)
{
struct ip_opts
{
diff --git a/libphobos/libdruntime/core/sys/linux/string.d b/libphobos/libdruntime/core/sys/linux/string.d
index e3c94cf6..880faa4 100644
--- a/libphobos/libdruntime/core/sys/linux/string.d
+++ b/libphobos/libdruntime/core/sys/linux/string.d
@@ -16,7 +16,7 @@ nothrow:
@nogc:
@system:
-static if (__USE_GNU)
+static if (_GNU_SOURCE)
{
pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen);
}
diff --git a/libphobos/libdruntime/core/sys/linux/sys/mman.d b/libphobos/libdruntime/core/sys/linux/sys/mman.d
index a6548a7..649e2af 100644
--- a/libphobos/libdruntime/core/sys/linux/sys/mman.d
+++ b/libphobos/libdruntime/core/sys/linux/sys/mman.d
@@ -37,7 +37,7 @@ version (PPC_Any)
{
enum PROT_SAO = 0x10;
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_GROWSDOWN = 0x00100,
MAP_DENYWRITE = 0x00800,
@@ -60,7 +60,7 @@ version (PPC_Any)
// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/riscv/bits/mman.h
else version (RISCV_Any)
{
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_GROWSDOWN = 0x00100,
MAP_DENYWRITE = 0x00800,
@@ -85,7 +85,7 @@ else version (RISCV_Any)
// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/s390/bits/mman.h
else version (IBMZ_Any)
{
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_GROWSDOWN = 0x00100,
MAP_DENYWRITE = 0x00800,
@@ -101,7 +101,7 @@ else version (IBMZ_Any)
// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sh/bits/mman.h
else version (SH)
{
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_GROWSDOWN = 0x0100,
MAP_DENYWRITE = 0x0800,
@@ -117,7 +117,7 @@ else version (SH)
// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sparc/bits/mman.h
else version (SPARC_Any)
{
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_GROWSDOWN = 0x0200,
MAP_DENYWRITE = 0x0800,
@@ -141,9 +141,9 @@ else version (SPARC_Any)
// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86/bits/mman.h
else version (X86_Any)
{
- static if (__USE_MISC) enum MAP_32BIT = 0x40;
+ static if (_DEFAULT_SOURCE) enum MAP_32BIT = 0x40;
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_GROWSDOWN = 0x00100,
MAP_DENYWRITE = 0x00800,
@@ -159,7 +159,7 @@ else version (X86_Any)
// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/bits/mman.h
else version (AArch64)
{
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_GROWSDOWN = 0x00100,
MAP_DENYWRITE = 0x00800,
@@ -187,11 +187,11 @@ else version (Alpha)
enum MAP_SHARED = 0x01;
enum MAP_PRIVATE = 0x02;
- static if (__USE_MISC)
+ static if (_DEFAULT_SOURCE)
enum MAP_TYPE = 0x0f;
enum MAP_FIXED = 0x10;
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_FILE = 0,
MAP_ANONYMOUS = MAP_ANON,
@@ -201,7 +201,7 @@ else version (Alpha)
MAP_HUGE_MASK = 0x3f,
}
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_GROWSDOWN = 0x01000,
MAP_DENYWRITE = 0x02000,
@@ -229,13 +229,13 @@ else version (Alpha)
// MCL_FUTURE = 16384,
// }
- static if (__USE_GNU) enum
+ static if (_GNU_SOURCE) enum
{
MREMAP_MAYMOVE = 1,
MREMAP_FIXED = 2,
}
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MADV_NORMAL = 0,
MADV_RANDOM = 1,
@@ -255,7 +255,7 @@ else version (Alpha)
}
// in core.sys.posix.sys.mman
- // static if (__USE_XOPEN2K) enum
+ // static if (_XOPEN_SOURCE >= 600) enum
// {
// POSIX_MADV_NORMAL = 0,
// POSIX_MADV_RANDOM = 1,
@@ -267,7 +267,7 @@ else version (Alpha)
// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/arm/bits/mman.h
else version (ARM)
{
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_GROWSDOWN = 0x00100,
MAP_DENYWRITE = 0x00800,
@@ -295,11 +295,11 @@ else version (HPPA_Any)
enum MAP_SHARED = 0x01;
enum MAP_PRIVATE = 0x02;
- static if (__USE_MISC)
+ static if (_DEFAULT_SOURCE)
enum MAP_TYPE = 0x0f;
enum MAP_FIXED = 0x04;
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_FILE = 0,
MAP_ANONYMOUS = MAP_ANON,
@@ -310,7 +310,7 @@ else version (HPPA_Any)
MAP_HUGE_MASK = 0x3f,
}
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_DENYWRITE = 0x0800,
MAP_EXECUTABLE = 0x1000,
@@ -336,13 +336,13 @@ else version (HPPA_Any)
// MCL_FUTURE = 2,
// }
- static if (__USE_GNU) enum
+ static if (_GNU_SOURCE) enum
{
MREMAP_MAYMOVE = 1,
MREMAP_FIXED = 2,
}
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MADV_NORMAL = 0,
MADV_RANDOM = 1,
@@ -375,7 +375,7 @@ else version (HPPA_Any)
}
// in core.sys.posix.sys.mman
- // static if (__USE_XOPEN2K) enum
+ // static if (_XOPEN_SOURCE >= 600) enum
// {
// POSIX_MADV_NORMAL = 0,
// POSIX_MADV_RANDOM = 1,
@@ -387,7 +387,7 @@ else version (HPPA_Any)
// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/ia64/bits/mman.h
else version (IA64)
{
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_GROWSDOWN = 0x00100,
MAP_GROWSUP = 0x00200,
@@ -404,7 +404,7 @@ else version (IA64)
// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/m68k/bits/mman.h
else version (M68K)
{
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_GROWSDOWN = 0x00100,
MAP_DENYWRITE = 0x00800,
@@ -420,7 +420,7 @@ else version (M68K)
// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/mips/bits/mman.h
else version (MIPS_Any)
{
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_NORESERVE = 0x0400,
MAP_GROWSDOWN = 0x1000,
@@ -460,11 +460,11 @@ else
enum MAP_SHARED = 0x01;
enum MAP_PRIVATE = 0x02;
- static if (__USE_MISC)
+ static if (_DEFAULT_SOURCE)
enum MAP_TYPE = 0x0f;
enum MAP_FIXED = 0x10;
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MAP_FILE = 0,
MAP_ANONYMOUS = MAP_ANON,
@@ -482,13 +482,13 @@ else
// MS_INVALIDATE = 2,
// }
- static if (__USE_GNU) enum
+ static if (_GNU_SOURCE) enum
{
MREMAP_MAYMOVE = 1,
MREMAP_FIXED = 2,
}
- static if (__USE_MISC) enum
+ static if (_DEFAULT_SOURCE) enum
{
MADV_NORMAL = 0,
MADV_RANDOM = 1,
@@ -508,7 +508,7 @@ else
}
// in core.sys.posix.sys.mman
- // static if (__USE_XOPEN2K) enum
+ // static if (_XOPEN_SOURCE >= 600) enum
// {
// POSIX_MADV_NORMAL = 0,
// POSIX_MADV_RANDOM = 1,
@@ -530,12 +530,12 @@ else
// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sparc/bits/mman.h
version (SPARC_Any)
{
- static if (__USE_MISC) enum MAP_RENAME = MAP_ANONYMOUS;
+ static if (_DEFAULT_SOURCE) enum MAP_RENAME = MAP_ANONYMOUS;
}
// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/mips/bits/mman.h
else version (MIPS_Any)
{
- static if (__USE_MISC) enum MAP_RENAME = MAP_ANONYMOUS;
+ static if (_DEFAULT_SOURCE) enum MAP_RENAME = MAP_ANONYMOUS;
}
// http://sourceware.org/git/?p=glibc.git;a=blob;f=misc/sys/mman.h
@@ -548,14 +548,14 @@ else version (MIPS_Any)
// int munmap(void*, size_t);
// int mprotect(void *__addr, size_t __len, int __prot);
// int msync(void *__addr, size_t __len, int __flags);
-static if (__USE_MISC) int madvise(void *__addr, size_t __len, int __advice);
-// static if (__USE_XOPEN2K) int posix_madvise(void *__addr, size_t __len, int __advice);
+static if (_DEFAULT_SOURCE) int madvise(void *__addr, size_t __len, int __advice);
+// static if (_XOPEN_SOURCE >= 600) int posix_madvise(void *__addr, size_t __len, int __advice);
// int mlock(const(void) *__addr, size_t __len);
// int munlock(const(void) *__addr, size_t __len);
// int mlockall(int __flags);
// int munlockall();
-static if (__USE_MISC) int mincore(void *__start, size_t __len, ubyte *__vec);
-static if (__USE_GNU) void *mremap(void *__addr, size_t __old_len, size_t __new_len, int __flags, ...);
-static if (__USE_GNU) int remap_file_pages(void *__start, size_t __size, int __prot, size_t __pgoff, int __flags);
+static if (_DEFAULT_SOURCE) int mincore(void *__start, size_t __len, ubyte *__vec);
+static if (_GNU_SOURCE) void *mremap(void *__addr, size_t __old_len, size_t __new_len, int __flags, ...);
+static if (_GNU_SOURCE) int remap_file_pages(void *__start, size_t __size, int __prot, size_t __pgoff, int __flags);
// int shm_open(in char *__name, int __oflag, mode_t __mode);
// int shm_unlink(in char *__name);
diff --git a/libphobos/libdruntime/core/sys/posix/aio.d b/libphobos/libdruntime/core/sys/posix/aio.d
index f4e0f12..a76846e 100644
--- a/libphobos/libdruntime/core/sys/posix/aio.d
+++ b/libphobos/libdruntime/core/sys/posix/aio.d
@@ -99,57 +99,7 @@ else version (CRuntime_Musl)
}
else version (CRuntime_UClibc)
{
- import core.sys.posix.config;
- import core.sys.posix.sys.types;
-
- struct aiocb
- {
- int aio_fildes;
- int aio_lio_opcode;
- int aio_reqprio;
- void* aio_buf; //volatile
- size_t aio_nbytes;
- sigevent aio_sigevent;
-
- aiocb* __next_prio;
- int __abs_prio;
- int __policy;
- int __error_code;
- ssize_t __return_value;
-
- static if (__USE_LARGEFILE64)
- {
- off_t aio_offset;
- ubyte[off64_t.sizeof - off_t.sizeof] __pad;
- }
- else
- {
- off64_t aio_offset;
- }
- ubyte[32] __unused;
- }
-
- static if (__USE_LARGEFILE64)
- {
- struct aiocb64
- {
- int aio_fildes;
- int aio_lio_opcode;
- int aio_reqprio;
- void* aio_buf; //volatile
- size_t aio_nbytes;
- sigevent aio_sigevent;
-
- aiocb* __next_prio;
- int __abs_prio;
- int __policy;
- int __error_code;
- ssize_t __return_value;
-
- off64_t aio_offset;
- ubyte[32] __unused;
- }
- }
+ // UClibc does not implement aiocb.
}
else version (Darwin)
{
@@ -272,15 +222,6 @@ else version (CRuntime_Musl)
AIO_ALLDONE
}
}
-else version (CRuntime_UClibc)
-{
- enum
- {
- AIO_CANCELED,
- AIO_NOTCANCELED,
- AIO_ALLDONE
- }
-}
else version (Darwin)
{
enum
@@ -328,15 +269,6 @@ else version (CRuntime_Musl)
LIO_NOP
}
}
-else version (CRuntime_UClibc)
-{
- enum
- {
- LIO_READ,
- LIO_WRITE,
- LIO_NOP
- }
-}
else version (Darwin)
{
enum
@@ -382,14 +314,6 @@ else version (CRuntime_Musl)
LIO_NOWAIT
}
}
-else version (CRuntime_UClibc)
-{
- enum
- {
- LIO_WAIT,
- LIO_NOWAIT
- }
-}
else version (Darwin)
{
enum
@@ -456,37 +380,7 @@ else version (CRuntime_Bionic)
}
else version (CRuntime_UClibc)
{
- static if (__USE_LARGEFILE64)
- {
- int aio_read64(aiocb64* aiocbp);
- int aio_write64(aiocb64* aiocbp);
- int aio_fsync64(int op, aiocb64* aiocbp);
- int aio_error64(const(aiocb64)* aiocbp);
- ssize_t aio_return64(aiocb64* aiocbp);
- int aio_suspend64(const(aiocb64*)* aiocb_list, int nitems, const(timespec)* timeout);
- int aio_cancel64(int fd, aiocb64* aiocbp);
- int lio_listio64(int mode, const(aiocb64*)* aiocb_list, int nitems, sigevent* sevp);
-
- alias aio_read = aio_read64;
- alias aio_write = aio_write64;
- alias aio_fsync = aio_fsync64;
- alias aio_error = aio_error64;
- alias aio_return = aio_return64;
- alias aio_suspend = aio_suspend64;
- alias aio_cancel = aio_cancel64;
- alias lio_listio = lio_listio64;
- }
- else
- {
- int aio_read(aiocb* aiocbp);
- int aio_write(aiocb* aiocbp);
- int aio_fsync(int op, aiocb* aiocbp);
- int aio_error(const(aiocb)* aiocbp);
- ssize_t aio_return(aiocb* aiocbp);
- int aio_suspend(const(aiocb*)* aiocb_list, int nitems, const(timespec)* timeout);
- int aio_cancel(int fd, aiocb* aiocbp);
- int lio_listio(int mode, const(aiocb*)* aiocb_list, int nitems, sigevent* sevp);
- }
+ // UClibc does not implement aio.h
}
else version (OpenBSD)
{
@@ -507,27 +401,7 @@ else
/* Functions outside/extending POSIX requirement. */
version (CRuntime_Glibc)
{
- static if (__USE_GNU)
- {
- /* To customize the implementation one can use the following struct. */
- struct aioinit
- {
- int aio_threads;
- int aio_num;
- int aio_locks;
- int aio_usedba;
- int aio_debug;
- int aio_numusers;
- int aio_idle_time;
- int aio_reserved;
- }
-
- void aio_init(const(aioinit)* init);
- }
-}
-else version (CRuntime_UClibc)
-{
- static if (__USE_GNU)
+ static if (_GNU_SOURCE)
{
/* To customize the implementation one can use the following struct. */
struct aioinit
diff --git a/libphobos/libdruntime/core/sys/posix/config.d b/libphobos/libdruntime/core/sys/posix/config.d
index 3b575fa..7bd0722 100644
--- a/libphobos/libdruntime/core/sys/posix/config.d
+++ b/libphobos/libdruntime/core/sys/posix/config.d
@@ -51,14 +51,24 @@ version (CRuntime_Glibc)
enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT;
enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT;
- enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600;
- enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600;
- enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700;
- enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700;
+ deprecated("use _XOPEN_SOURCE >= 600")
+ {
+ enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600;
+ enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600;
+ }
+ deprecated("use _XOPEN_SOURCE >= 700")
+ {
+ enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700;
+ enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700;
+ }
+ deprecated("use _DEFAULT_SOURCE")
enum __USE_MISC = _DEFAULT_SOURCE;
+ deprecated("use _ATFILE_SOURCE")
enum __USE_ATFILE = _ATFILE_SOURCE;
+ deprecated("use _GNU_SOURCE")
enum __USE_GNU = _GNU_SOURCE;
+ deprecated("use _REENTRANT")
enum __USE_REENTRANT = _REENTRANT;
version (D_LP64)
@@ -68,6 +78,10 @@ version (CRuntime_Glibc)
}
else version (CRuntime_Musl)
{
+ enum _GNU_SOURCE = false;
+ enum _DEFAULT_SOURCE = false;
+ enum _ATFILE_SOURCE = false;
+
// off_t is always 64 bits on Musl
enum _FILE_OFFSET_BITS = 64;
@@ -99,14 +113,24 @@ else version (CRuntime_UClibc)
enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT;
enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT;
- enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600;
- enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600;
- enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700;
- enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700;
+ deprecated("use _XOPEN_SOURCE >= 600")
+ {
+ enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600;
+ enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600;
+ }
+ deprecated("use _XOPEN_SOURCE >= 700")
+ {
+ enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700;
+ enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700;
+ }
+ deprecated("use _DEFAULT_SOURCE")
enum __USE_MISC = _DEFAULT_SOURCE;
+ deprecated("use _ATFILE_SOURCE")
enum __USE_ATFILE = _ATFILE_SOURCE;
+ deprecated("use _GNU_SOURCE")
enum __USE_GNU = _GNU_SOURCE;
+ deprecated("use _REENTRANT")
enum __USE_REENTRANT = _REENTRANT;
version (D_LP64)
@@ -117,7 +141,11 @@ else version (CRuntime_UClibc)
else version (CRuntime_Bionic)
{
enum _GNU_SOURCE = false;
+ enum _DEFAULT_SOURCE = false;
+ enum _ATFILE_SOURCE = false;
+
enum __USE_FILE_OFFSET64 = false; // see https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md
+ deprecated("use _GNU_SOURCE")
enum __USE_GNU = _GNU_SOURCE;
version (D_LP64)
@@ -187,10 +215,16 @@ else version (Solaris)
enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT;
enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT;
- enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600;
- enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600;
- enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700;
- enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700;
+ deprecated("use _XOPEN_SOURCE >= 600")
+ {
+ enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600;
+ enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600;
+ }
+ deprecated("use _XOPEN_SOURCE >= 700")
+ {
+ enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700;
+ enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700;
+ }
version (D_LP64)
enum __WORDSIZE = 64;
diff --git a/libphobos/libdruntime/core/sys/posix/spawn.d b/libphobos/libdruntime/core/sys/posix/spawn.d
index 86b1751..cfa3a40 100644
--- a/libphobos/libdruntime/core/sys/posix/spawn.d
+++ b/libphobos/libdruntime/core/sys/posix/spawn.d
@@ -100,8 +100,8 @@ version (linux)
POSIX_SPAWN_SETSCHEDPARAM = 0x10,
POSIX_SPAWN_SETSCHEDULER = 0x20
}
- import core.sys.posix.config : __USE_GNU;
- static if (__USE_GNU)
+ import core.sys.posix.config : _GNU_SOURCE;
+ static if (_GNU_SOURCE)
{
enum
{
@@ -140,8 +140,8 @@ version (linux)
POSIX_SPAWN_SETSCHEDPARAM = 16,
POSIX_SPAWN_SETSCHEDULER = 32
}
- import core.sys.posix.config : __USE_GNU;
- static if (__USE_GNU)
+ import core.sys.posix.config : _GNU_SOURCE;
+ static if (_GNU_SOURCE)
{
enum
{
@@ -196,8 +196,8 @@ version (linux)
POSIX_SPAWN_SETSCHEDPARAM = 0x10,
POSIX_SPAWN_SETSCHEDULER = 0x20
}
- import core.sys.posix.config : __USE_GNU;
- static if (__USE_GNU)
+ import core.sys.posix.config : _GNU_SOURCE;
+ static if (_GNU_SOURCE)
{
enum
{
diff --git a/libphobos/libdruntime/core/sys/posix/sys/ipc.d b/libphobos/libdruntime/core/sys/posix/sys/ipc.d
index 18a6cbd..1718243 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/ipc.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/ipc.d
@@ -83,7 +83,26 @@ version (linux)
}
else version (Darwin)
{
+ align(4) struct ipc_perm
+ {
+ uid_t uid;
+ gid_t gid;
+ uid_t cuid;
+ gid_t cgid;
+ mode_t mode;
+ ushort _seq;
+ key_t _key;
+ }
+
+ enum IPC_CREAT = 0x0200; // 01000
+ enum IPC_EXCL = 0x0400; // 02000
+ enum IPC_NOWAIT = 0x0800; // 04000
+
+ enum key_t IPC_PRIVATE = 0;
+ enum IPC_RMID = 0;
+ enum IPC_SET = 1;
+ enum IPC_STAT = 2;
}
else version (FreeBSD)
{
@@ -188,6 +207,46 @@ else version (DragonFlyBSD)
enum IPC_SET = 1;
enum IPC_STAT = 2;
}
+else version (Solaris)
+{
+ version (D_LP64)
+ {
+ struct ipc_perm
+ {
+ uid_t uid;
+ gid_t gid;
+ uid_t cuid;
+ gid_t cgid;
+ mode_t mode;
+ uint seq;
+ key_t key;
+ }
+ }
+ else
+ {
+ struct ipc_perm
+ {
+ uid_t uid;
+ gid_t gid;
+ uid_t cuid;
+ gid_t cgid;
+ mode_t mode;
+ uint seq;
+ key_t key;
+ int[4] pad;
+ }
+ }
+
+ enum IPC_CREAT = 0x200;
+ enum IPC_EXCL = 0x400;
+ enum IPC_NOWAIT = 0x800;
+
+ enum key_t IPC_PRIVATE = 0;
+
+ enum IPC_RMID = 10;
+ enum IPC_SET = 11;
+ enum IPC_STAT = 12;
+}
else
{
static assert(false, "Unsupported platform");
@@ -203,7 +262,7 @@ version (CRuntime_Glibc)
}
else version (Darwin)
{
-
+ key_t ftok(const scope char*, int);
}
else version (FreeBSD)
{
@@ -221,6 +280,10 @@ else version (DragonFlyBSD)
{
key_t ftok(const scope char*, int);
}
+else version (Solaris)
+{
+ key_t ftok(const scope char*, int);
+}
else version (CRuntime_Bionic)
{
key_t ftok(const scope char*, int);
diff --git a/libphobos/libdruntime/core/sys/posix/sys/mman.d b/libphobos/libdruntime/core/sys/posix/sys/mman.d
index 33ce88f..430f215 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/mman.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/mman.d
@@ -56,7 +56,7 @@ int posix_madvise(void*, size_t, int);
version (CRuntime_Glibc)
{
- static if (__USE_XOPEN2K)
+ static if (_XOPEN_SOURCE >= 600)
{
int posix_madvise(void *__addr, size_t __len, int __advice);
}
@@ -303,7 +303,7 @@ else version (CRuntime_Musl)
}
else version (CRuntime_UClibc)
{
- static if (__USE_LARGEFILE64) void* mmap64(void*, size_t, int, int, int, off64_t);
+ static if (__USE_LARGEFILE64) void* mmap64(void*, size_t, int, int, int, off_t);
static if (__USE_FILE_OFFSET64)
alias mmap = mmap64;
else
diff --git a/libphobos/libdruntime/core/sys/posix/sys/shm.d b/libphobos/libdruntime/core/sys/posix/sys/shm.d
index ce34141..d04e792 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/shm.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/shm.d
@@ -259,6 +259,18 @@ else version (CRuntime_Musl)
int shmdt(const scope void*);
int shmget(key_t, size_t, int);
}
+else version (CRuntime_Bionic)
+{
+ enum SHMLBA = 4096;
+
+ deprecated("Not useful on Android because it's disallowed by SELinux")
+ {
+ void* shmat(int, const scope void*, int);
+ int shmctl(int, int, shmid_ds*);
+ int shmdt(const scope void*);
+ int shmget(key_t, size_t, int);
+ }
+}
else version (CRuntime_UClibc)
{
int __getpagesize();
diff --git a/libphobos/libdruntime/core/sys/posix/sys/socket.d b/libphobos/libdruntime/core/sys/posix/sys/socket.d
index 670ead7..c1309a6 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/socket.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/socket.d
@@ -1038,9 +1038,9 @@ else version (OpenBSD)
{
ubyte ss_len;
sa_family_t ss_family;
- byte[6] __ss_pad1;
+ ubyte[6] __ss_pad1;
long __ss_align;
- byte[240] __ss_pad2;
+ ubyte[240] __ss_pad2;
}
struct msghdr
@@ -1063,20 +1063,25 @@ else version (OpenBSD)
enum : uint
{
- SCM_RIGHTS = 0x01
+ SCM_RIGHTS = 0x01,
+ SCM_TIMESTAMP = 0x04
}
private // <sys/_types.h>
{
- extern (D) size_t _ALIGN(size_t p) { return (p + _ALIGNBYTES) & ~_ALIGNBYTES; }
+ enum _ALIGNBYTES = c_long.sizeof - 1;
+ extern (D) size_t _ALIGN(size_t p) pure nothrow @nogc
+ {
+ return (p + _ALIGNBYTES) & ~_ALIGNBYTES;
+ }
}
- extern (D) ubyte* CMSG_DATA(cmsghdr* cmsg)
+ extern (D) ubyte* CMSG_DATA(cmsghdr* cmsg) pure nothrow @nogc
{
return cast(ubyte*) cmsg + _ALIGN(cmsghdr.sizeof);
}
- extern (D) cmsghdr* CMSG_NXTHDR(msghdr* mhdr, cmsghdr* cmsg)
+ extern (D) cmsghdr* CMSG_NXTHDR(msghdr* mhdr, cmsghdr* cmsg) pure nothrow @nogc
{
if (cast(ubyte*) cmsg + _ALIGN(cmsg.cmsg_len) + _ALIGN(cmsghdr.sizeof) >
cast(ubyte*) mhdr.msg_control + mhdr.msg_controllen)
@@ -1085,11 +1090,24 @@ else version (OpenBSD)
return cast(cmsghdr*) (cast(ubyte*) cmsg + _ALIGN(cmsg.cmsg_len));
}
- extern (D) cmsghdr* CMSG_FIRSTHDR(msghdr* mhdr)
+ extern (D) cmsghdr* CMSG_FIRSTHDR(msghdr* mhdr) pure nothrow @nogc
{
return mhdr.msg_controllen >= cmsghdr.sizeof ? cast(cmsghdr*) mhdr.msg_control : null;
}
+ extern (D)
+ {
+ size_t CMSG_LEN(size_t len) pure nothrow @nogc
+ {
+ return _ALIGN(cmsghdr.sizeof) + len;
+ }
+ }
+
+ extern (D) size_t CMSG_SPACE(size_t len) pure nothrow @nogc
+ {
+ return _ALIGN(cmsghdr.sizeof) + _ALIGN(len);
+ }
+
struct linger
{
int l_onoff;
diff --git a/libphobos/libdruntime/core/sys/posix/sys/stat.d b/libphobos/libdruntime/core/sys/posix/sys/stat.d
index 51455a9..22f4df6 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/stat.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/stat.d
@@ -89,7 +89,7 @@ version (linux)
off_t st_size;
blksize_t st_blksize;
blkcnt_t st_blocks;
- static if (__USE_MISC || __USE_XOPEN2K8)
+ static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
{
timespec st_atim;
timespec st_mtim;
@@ -136,7 +136,7 @@ version (linux)
off_t st_size;
blksize_t st_blksize;
blkcnt_t st_blocks;
- static if (__USE_MISC || __USE_XOPEN2K8)
+ static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
{
timespec st_atim;
timespec st_mtim;
@@ -218,7 +218,7 @@ version (linux)
__blkcnt64_t st_blocks;
}
- static if ( __USE_MISC || __USE_XOPEN2K8)
+ static if ( _DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
{
__timespec st_atim;
__timespec st_mtim;
@@ -278,7 +278,7 @@ version (linux)
c_long[3] st_pad2;
off_t st_size;
}
- static if (__USE_MISC || __USE_XOPEN2K8)
+ static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
{
timespec st_atim;
timespec st_mtim;
@@ -339,7 +339,7 @@ version (linux)
uint[3] st_pad2;
off_t st_size;
}
- static if (__USE_MISC || __USE_XOPEN2K8)
+ static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
{
timespec st_atim;
timespec st_mtim;
@@ -491,7 +491,7 @@ version (linux)
__blkcnt_t st_blocks;
}
- static if (__USE_MISC)
+ static if (_DEFAULT_SOURCE)
{
__timespec st_atim;
__timespec st_mtim;
@@ -573,7 +573,7 @@ version (linux)
__blkcnt64_t st_blocks;
}
- static if ( __USE_MISC || __USE_XOPEN2K8)
+ static if ( _DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
{
__timespec st_atim;
__timespec st_mtim;
@@ -668,7 +668,7 @@ version (linux)
__blkcnt64_t st_blocks;
}
- static if (__USE_MISC)
+ static if (_DEFAULT_SOURCE)
{
__timespec st_atim;
__timespec st_mtim;
@@ -753,7 +753,7 @@ version (linux)
__blkcnt64_t st_blocks;
}
- static if (__USE_XOPEN2K8)
+ static if (_XOPEN_SOURCE >= 700)
{
__timespec st_atim;
__timespec st_mtim;
@@ -830,7 +830,7 @@ version (linux)
__blkcnt_t st_blocks;
else
__blkcnt64_t st_blocks;
- static if (__USE_XOPEN2K8)
+ static if (_XOPEN_SOURCE >= 700)
{
__timespec st_atim;
__timespec st_mtim;
@@ -894,7 +894,7 @@ version (linux)
int __glibc_reserved0;
__dev_t st_rdev;
__off_t st_size;
- static if (__USE_XOPEN2K8)
+ static if (_XOPEN_SOURCE >= 700)
{
__timespec st_atim;
__timespec st_mtim;
@@ -919,7 +919,7 @@ version (linux)
__blkcnt_t st_blocks;
c_long[3] __glibc_reserved;
}
- static if (__USE_XOPEN2K8)
+ static if (_XOPEN_SOURCE >= 700)
static assert(stat_t.sizeof == 144);
else
static assert(stat_t.sizeof == 144);
diff --git a/libphobos/libdruntime/core/sys/posix/sys/statvfs.d b/libphobos/libdruntime/core/sys/posix/sys/statvfs.d
index 49c8450..df9030d 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/statvfs.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/statvfs.d
@@ -44,7 +44,7 @@ version (CRuntime_Glibc) {
}
/* Definitions for the flag in `f_flag'. These definitions should be
kept in sync with the definitions in <sys/mount.h>. */
- static if (__USE_GNU)
+ static if (_GNU_SOURCE)
{
enum FFlag
{
diff --git a/libphobos/libdruntime/core/sys/posix/sys/types.d b/libphobos/libdruntime/core/sys/posix/sys/types.d
index 02cf799..ec229dd 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/types.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/types.d
@@ -322,7 +322,7 @@ else version (Darwin)
alias uint fsfilcnt_t;
alias c_long clock_t;
alias uint id_t;
- // key_t
+ alias int key_t;
alias int suseconds_t;
alias uint useconds_t;
}
diff --git a/libphobos/libdruntime/object.d b/libphobos/libdruntime/object.d
index 7bb6bec..cf7cf96 100644
--- a/libphobos/libdruntime/object.d
+++ b/libphobos/libdruntime/object.d
@@ -1885,8 +1885,8 @@ class TypeInfo_Struct : TypeInfo
return false;
else if (xopEquals)
{
- const dg = _memberFunc(p2, xopEquals);
- return dg.xopEquals(p1);
+ const dg = _memberFunc(p1, xopEquals);
+ return dg.xopEquals(p2);
}
else if (p1 == p2)
return true;
diff --git a/libphobos/libdruntime/rt/util/typeinfo.d b/libphobos/libdruntime/rt/util/typeinfo.d
index 26c24c4..7b55693 100644
--- a/libphobos/libdruntime/rt/util/typeinfo.d
+++ b/libphobos/libdruntime/rt/util/typeinfo.d
@@ -1,8 +1,8 @@
/**
- * This module contains utilities for TypeInfo implementation.
+ * A few predefined implementations for primitive types and arrays thereof. Also a couple of helpers.
*
* Copyright: Copyright Kenji Hara 2014-.
- * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+ * License: <a href="https://boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
* Authors: Kenji Hara
* Source: $(DRUNTIMESRC rt/util/_typeinfo.d)
*/
@@ -10,100 +10,74 @@ module rt.util.typeinfo;
import rt.util.utility : d_cfloat, d_cdouble, d_creal, isComplex;
static import core.internal.hash;
-template Floating(T)
-if (is(T == float) || is(T == double) || is(T == real))
+// Three-way compare for integrals: negative if `lhs < rhs`, positive if `lhs > rhs`, 0 otherwise.
+pragma(inline, true)
+private int cmp3(T)(const T lhs, const T rhs)
+if (__traits(isIntegral, T))
{
- pure nothrow @safe:
-
- bool equals(T f1, T f2)
- {
- return f1 == f2;
- }
-
- int compare(T d1, T d2)
- {
- if (d1 != d1 || d2 != d2) // if either are NaN
- {
- if (d1 != d1)
- {
- if (d2 != d2)
- return 0;
- return -1;
- }
- return 1;
- }
- return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1);
- }
+ static if (T.sizeof < int.sizeof)
+ // Taking the difference will always fit in an int.
+ return int(lhs) - int(rhs);
+ else
+ return (lhs > rhs) - (lhs < rhs);
+}
- public alias hashOf = core.internal.hash.hashOf;
+// Three-way compare for real fp types. NaN is smaller than all valid numbers.
+// Code is small and fast, see https://godbolt.org/z/fzb877
+pragma(inline, true)
+private int cmp3(T)(const T d1, const T d2)
+if (is(T == float) || is(T == double) || is(T == real))
+{
+ if (d2 != d2)
+ return d1 == d1; // 0 if both ar NaN, 1 if d1 is valid and d2 is NaN.
+ // If d1 is NaN, both comparisons are false so we get -1, as needed.
+ return (d1 > d2) - !(d1 >= d2);
}
-// @@@DEPRECATED_2.105@@@
-template Floating(T)
+// Three-way compare for complex types.
+pragma(inline, true)
+private int cmp3(T)(const T f1, const T f2)
if (isComplex!T)
{
- pure nothrow @safe:
-
- bool equals(T f1, T f2)
- {
- return f1.re == f2.re && f1.im == f2.im;
- }
-
- int compare(T f1, T f2)
- {
- int result;
-
- if (f1.re < f2.re)
- result = -1;
- else if (f1.re > f2.re)
- result = 1;
- else if (f1.im < f2.im)
- result = -1;
- else if (f1.im > f2.im)
- result = 1;
- else
- result = 0;
+ if (int result = cmp3(f1.re, f2.re))
return result;
- }
-
- size_t hashOf(scope const T val)
- {
- return core.internal.hash.hashOf(val.re, core.internal.hash.hashOf(val.im));
- }
+ return cmp3(f1.im, f2.im);
}
-template Array(T)
-if (is(T == float) || is(T == double) || is(T == real))
+unittest
{
- pure nothrow @safe:
-
- bool equals(T[] s1, T[] s2)
- {
- size_t len = s1.length;
- if (len != s2.length)
- return false;
- for (size_t u = 0; u < len; u++)
- {
- if (!Floating!T.equals(s1[u], s2[u]))
- return false;
- }
- return true;
- }
-
- int compare(T[] s1, T[] s2)
- {
- size_t len = s1.length;
- if (s2.length < len)
- len = s2.length;
- for (size_t u = 0; u < len; u++)
- {
- if (int c = Floating!T.compare(s1[u], s2[u]))
- return c;
- }
- return (s1.length > s2.length) - (s1.length < s2.length);
- }
-
- public alias hashOf = core.internal.hash.hashOf;
+ assert(cmp3(short.max, short.min) > 0);
+ assert(cmp3(42, 42) == 0);
+ assert(cmp3(int.max, int.min) > 0);
+
+ double x, y;
+ assert(cmp3(x, y) == 0);
+ assert(cmp3(y, x) == 0);
+ x = 42;
+ assert(cmp3(x, y) > 0);
+ assert(cmp3(y, x) < 0);
+ y = 43;
+ assert(cmp3(x, y) < 0);
+ assert(cmp3(y, x) > 0);
+ y = 42;
+ assert(cmp3(x, y) == 0);
+ assert(cmp3(y, x) == 0);
+
+ d_cdouble u, v;
+ assert(cmp3(u, v) == 0);
+ assert(cmp3(v, u) == 0);
+ u = d_cdouble(42, 42);
+ assert(cmp3(u, v) > 0);
+ assert(cmp3(v, u) < 0);
+ v = d_cdouble(43, 42);
+ assert(cmp3(u, v) < 0);
+ assert(cmp3(v, u) > 0);
+ v = d_cdouble(42, 43);
+ assert(cmp3(u, v) < 0);
+ assert(cmp3(v, u) > 0);
+ v = d_cdouble(42, 42);
+ assert(cmp3(u, v) == 0);
+ assert(cmp3(v, u) == 0);
}
// @@@DEPRECATED_2.105@@@
@@ -209,7 +183,7 @@ unittest
}();
}
-// Reduces to `T` if `cond` is `true` or `U` otherwise.
+// Reduces to `T` if `cond` is `true` or `U` otherwise. Consider moving elsewhere if useful.
private template Select(bool cond, T, U)
{
static if (cond) alias Select = T;
@@ -238,57 +212,38 @@ if (T.sizeof == Base.sizeof && T.alignof == Base.alignof)
static if (is(T == Base))
override size_t getHash(scope const void* p)
{
- static if (__traits(isFloating, T) || isComplex!T)
- return Floating!T.hashOf(*cast(T*)p);
- else
- return hashOf(*cast(const T *)p);
+ return hashOf(*cast(const T *)p);
}
// `equals` is the same for `Base` and `T`, introduce it just once.
static if (is(T == Base))
override bool equals(in void* p1, in void* p2)
{
- static if (__traits(isFloating, T) || isComplex!T)
- return Floating!T.equals(*cast(T*)p1, *cast(T*)p2);
- else
- return *cast(T *)p1 == *cast(T *)p2;
+ return *cast(const T *)p1 == *cast(const T *)p2;
}
// `T` and `Base` may have different signedness, so this function is introduced conditionally.
static if (is(T == Base) || (__traits(isIntegral, T) && T.max != Base.max))
override int compare(in void* p1, in void* p2)
{
- static if (__traits(isFloating, T) || isComplex!T)
- {
- return Floating!T.compare(*cast(T*)p1, *cast(T*)p2);
- }
- else static if (T.sizeof < int.sizeof)
- {
- // Taking the difference will always fit in an int.
- return int(*cast(T *) p1) - int(*cast(T *) p2);
- }
- else
- {
- auto lhs = *cast(T *) p1, rhs = *cast(T *) p2;
- return (lhs > rhs) - (lhs < rhs);
- }
+ return cmp3(*cast(const T*) p1, *cast(const T*) p2);
}
static if (is(T == Base))
- override @property size_t tsize() nothrow pure
+ override @property size_t tsize()
{
return T.sizeof;
}
static if (is(T == Base))
- override @property size_t talign() nothrow pure
+ override @property size_t talign()
{
return T.alignof;
}
// Override initializer only if necessary.
static if (is(T == Base) || T.init != Base.init)
- override const(void)[] initializer() @trusted
+ override const(void)[] initializer()
{
static if (__traits(isZeroInit, T))
{
@@ -311,7 +266,7 @@ if (T.sizeof == Base.sizeof && T.alignof == Base.alignof)
}
static if (is(T == Base) || RTInfo!T != RTInfo!Base)
- override @property immutable(void)* rtInfo() nothrow pure const @safe
+ override @property immutable(void)* rtInfo()
{
return RTInfo!T;
}
@@ -377,52 +332,33 @@ private class TypeInfoArrayGeneric(T, Base = T) : Select!(is(T == Base), TypeInf
static if (is(T == Base))
override size_t getHash(scope const void* p) @trusted const
{
- static if (__traits(isFloating, T) || isComplex!T)
- return Array!T.hashOf(*cast(T[]*)p);
- else
- return hashOf(*cast(const T[]*) p);
+ return hashOf(*cast(const T[]*) p);
}
static if (is(T == Base))
override bool equals(in void* p1, in void* p2) const
{
- static if (__traits(isFloating, T) || isComplex!T)
- {
- return Array!T.equals(*cast(T[]*)p1, *cast(T[]*)p2);
- }
- else
- {
- import core.stdc.string;
- auto s1 = *cast(T[]*)p1;
- auto s2 = *cast(T[]*)p2;
- return s1.length == s2.length &&
- memcmp(s1.ptr, s2.ptr, s1.length) == 0;
- }
+ // Just reuse the builtin.
+ return *cast(const(T)[]*) p1 == *cast(const(T)[]*) p2;
}
static if (is(T == Base) || (__traits(isIntegral, T) && T.max != Base.max))
override int compare(in void* p1, in void* p2) const
{
- static if (__traits(isFloating, T) || isComplex!T)
- {
- return Array!T.compare(*cast(T[]*)p1, *cast(T[]*)p2);
- }
- else
+ // Can't reuse __cmp in object.d because that handles NaN differently.
+ // (Q: would it make sense to unify behaviors?)
+ // return __cmp(*cast(const T[]*) p1, *cast(const T[]*) p2);
+ auto lhs = *cast(const T[]*) p1;
+ auto rhs = *cast(const T[]*) p2;
+ size_t len = lhs.length;
+ if (rhs.length < len)
+ len = rhs.length;
+ for (size_t u = 0; u < len; u++)
{
- auto s1 = *cast(T[]*)p1;
- auto s2 = *cast(T[]*)p2;
- auto len = s1.length;
-
- if (s2.length < len)
- len = s2.length;
- for (size_t u = 0; u < len; u++)
- {
- if (int result = (s1[u] > s2[u]) - (s1[u] < s2[u]))
- return result;
- }
- return (s1.length > s2.length) - (s1.length < s2.length);
+ if (int result = cmp3(lhs.ptr[u], rhs.ptr[u]))
+ return result;
}
- }
+ return cmp3(lhs.length, rhs.length); }
override @property inout(TypeInfo) next() inout
{
@@ -692,52 +628,37 @@ unittest
// typeof(null)
class TypeInfo_n : TypeInfo
{
- override string toString() const @safe { return "typeof(null)"; }
+ const: pure: @nogc: nothrow: @safe:
- override size_t getHash(scope const void* p) const
- {
- return 0;
- }
+ override string toString() { return "typeof(null)"; }
- override bool equals(in void* p1, in void* p2) const @trusted
- {
- return true;
- }
+ override size_t getHash(scope const void*) { return 0; }
- override int compare(in void* p1, in void* p2) const @trusted
- {
- return 0;
- }
+ override bool equals(in void*, in void*) { return true; }
- override @property size_t tsize() const
- {
- return typeof(null).sizeof;
- }
+ override int compare(in void*, in void*) { return 0; }
- override const(void)[] initializer() const @trusted
- {
- __gshared immutable void[typeof(null).sizeof] init;
- return init;
- }
+ override @property size_t tsize() { return typeof(null).sizeof; }
- override void swap(void *p1, void *p2) const @trusted
- {
- }
+ override const(void)[] initializer() @trusted { return (cast(void *)null)[0 .. size_t.sizeof]; }
- override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; }
+ override void swap(void*, void*) {}
- unittest
+ override @property immutable(void)* rtInfo() { return rtinfoNoPointers; }
+}
+
+unittest
+{
+ with (typeid(typeof(null)))
{
- with (typeid(typeof(null)))
- {
- assert(toString == "typeof(null)");
- assert(getHash(null) == 0);
- assert(equals(null, null));
- assert(compare(null, null) == 0);
- assert(tsize == typeof(null).sizeof);
- assert(initializer == new ubyte[(void*).sizeof]);
- assert(rtInfo == rtinfoNoPointers);
- }
+ assert(toString == "typeof(null)");
+ assert(getHash(null) == 0);
+ assert(equals(null, null));
+ assert(compare(null, null) == 0);
+ assert(tsize == typeof(null).sizeof);
+ assert(initializer.ptr is null);
+ assert(initializer.length == typeof(null).sizeof);
+ assert(rtInfo == rtinfoNoPointers);
}
}
diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE
index 2babfbe..b5b939f 100644
--- a/libphobos/src/MERGE
+++ b/libphobos/src/MERGE
@@ -1,4 +1,4 @@
-896b1d0e1e8b69bccac0e180ecd1b42a70f95d5b
+1a3e80ec25afab6123cdcfe20186f36f006b68bb
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/algorithm/internal.d b/libphobos/src/std/algorithm/internal.d
index 3caeefeb..6b45599 100644
--- a/libphobos/src/std/algorithm/internal.d
+++ b/libphobos/src/std/algorithm/internal.d
@@ -62,4 +62,6 @@ version (StdUnittest)
}
}
+// Used instead of `&object.member` when `member` may be
+// either a field or a @property function.
package(std) T* addressOf(T)(ref T val) { return &val; }
diff --git a/libphobos/src/std/bigint.d b/libphobos/src/std/bigint.d
index bbb55c2..b2fcc07 100644
--- a/libphobos/src/std/bigint.d
+++ b/libphobos/src/std/bigint.d
@@ -414,17 +414,17 @@ public:
/**
* Implements assignment operators of the form `BigInt op= BigInt`.
*/
- BigInt opOpAssign(string op, T)(T y) pure nothrow @safe scope return
+ BigInt opOpAssign(string op, T)(T y) pure nothrow @safe return scope
if ((op=="+" || op== "-" || op=="*" || op=="|" || op=="&" || op=="^" || op=="/" || op=="%")
&& is (T: BigInt))
{
static if (op == "+")
{
- data = BigUint.addOrSub(data, y.data, sign != y.sign, &sign);
+ data = BigUint.addOrSub(data, y.data, sign != y.sign, sign);
}
else static if (op == "-")
{
- data = BigUint.addOrSub(data, y.data, sign == y.sign, &sign);
+ data = BigUint.addOrSub(data, y.data, sign == y.sign, sign);
}
else static if (op == "*")
{
@@ -2244,7 +2244,7 @@ void divMod(const BigInt dividend, const BigInt divisor, out BigInt quotient, ou
BigUint.divMod(dividend.data, divisor.data, q, r);
quotient.sign = dividend.sign != divisor.sign;
quotient.data = q;
- remainder.sign = dividend.sign;
+ remainder.sign = r.isZero() ? false : dividend.sign;
remainder.data = r;
}
@@ -2291,6 +2291,14 @@ void divMod(const BigInt dividend, const BigInt divisor, out BigInt quotient, ou
assert(q * d + r == -c);
}
+// https://issues.dlang.org/show_bug.cgi?id=22771
+@safe pure nothrow unittest
+{
+ BigInt quotient, remainder;
+ divMod(BigInt(-50), BigInt(1), quotient, remainder);
+ assert(remainder == 0);
+}
+
// https://issues.dlang.org/show_bug.cgi?id=19740
@safe unittest
{
diff --git a/libphobos/src/std/container/rbtree.d b/libphobos/src/std/container/rbtree.d
index 0b0a0b2..622dee4 100644
--- a/libphobos/src/std/container/rbtree.d
+++ b/libphobos/src/std/container/rbtree.d
@@ -111,7 +111,7 @@ struct RBNode(V)
/**
* Get the left child
*/
- @property inout(RBNode)* left() inout
+ @property inout(RBNode)* left() inout return scope
{
return _left;
}
@@ -119,7 +119,7 @@ struct RBNode(V)
/**
* Get the right child
*/
- @property inout(RBNode)* right() inout
+ @property inout(RBNode)* right() inout return scope
{
return _right;
}
@@ -127,7 +127,7 @@ struct RBNode(V)
/**
* Get the parent
*/
- @property inout(RBNode)* parent() inout
+ @property inout(RBNode)* parent() inout return scope
{
return _parent;
}
@@ -377,7 +377,7 @@ struct RBNode(V)
* Returns the next highest valued node in the tree after this one, or end
* if this was the highest-valued node.
*/
- Node remove(Node end)
+ Node remove(Node end) return
{
//
// remove this node from the tree, fixing the color if necessary.
@@ -558,7 +558,7 @@ struct RBNode(V)
/**
* Return the leftmost descendant of this node.
*/
- @property inout(RBNode)* leftmost() inout
+ @property inout(RBNode)* leftmost() inout return
{
inout(RBNode)* result = &this;
while (result._left !is null)
@@ -569,7 +569,7 @@ struct RBNode(V)
/**
* Return the rightmost descendant of this node
*/
- @property inout(RBNode)* rightmost() inout
+ @property inout(RBNode)* rightmost() inout return
{
inout(RBNode)* result = &this;
while (result._right !is null)
@@ -583,7 +583,7 @@ struct RBNode(V)
* You should never call this on the marker node, as it is assumed that
* there is a valid next node.
*/
- @property inout(RBNode)* next() inout
+ @property inout(RBNode)* next() inout return
{
inout(RBNode)* n = &this;
if (n.right is null)
@@ -602,7 +602,7 @@ struct RBNode(V)
* You should never call this on the leftmost node of the tree as it is
* assumed that there is a valid previous node.
*/
- @property inout(RBNode)* prev() inout
+ @property inout(RBNode)* prev() inout return
{
inout(RBNode)* n = &this;
if (n.left is null)
diff --git a/libphobos/src/std/conv.d b/libphobos/src/std/conv.d
index a10f4da..8512a44 100644
--- a/libphobos/src/std/conv.d
+++ b/libphobos/src/std/conv.d
@@ -1642,7 +1642,7 @@ if (!isImplicitlyConvertible!(S, T) &&
Array-to-array conversion (except when target is a string type)
converts each element in turn by using `to`.
*/
-private T toImpl(T, S)(S value)
+private T toImpl(T, S)(scope S value)
if (!isImplicitlyConvertible!(S, T) &&
!isSomeString!S && isDynamicArray!S &&
!isExactSomeString!T && isArray!T)
diff --git a/libphobos/src/std/file.d b/libphobos/src/std/file.d
index c974ada..a99c517 100644
--- a/libphobos/src/std/file.d
+++ b/libphobos/src/std/file.d
@@ -4635,7 +4635,7 @@ private struct DirIteratorImpl
import std.path : chainPath;
auto searchPattern = chainPath(directory, "*.*");
- static auto trustedFindFirstFileW(typeof(searchPattern) pattern, WIN32_FIND_DATAW* findinfo) @trusted
+ static auto trustedFindFirstFileW(typeof(searchPattern) pattern, scope WIN32_FIND_DATAW* findinfo) @trusted
{
return FindFirstFileW(pattern.tempCString!FSChar(), findinfo);
}
@@ -4653,7 +4653,7 @@ private struct DirIteratorImpl
return toNext(true, &_findinfo);
}
- bool toNext(bool fetch, WIN32_FIND_DATAW* findinfo) @trusted
+ bool toNext(bool fetch, scope WIN32_FIND_DATAW* findinfo) @trusted
{
import core.stdc.wchar_ : wcscmp;
@@ -5274,7 +5274,21 @@ Returns:
*/
string tempDir() @trusted
{
- import std.path : dirSeparator;
+ // We must check that the end of a path is not a separator, before adding another
+ // If we don't we end up with https://issues.dlang.org/show_bug.cgi?id=22738
+ static string addSeparator(string input)
+ {
+ import std.path : dirSeparator;
+ import std.algorithm.searching : endsWith;
+
+ // It is very rare a directory path will reach this point with a directory separator at the end
+ // However on OSX this can happen, so we must verify lest we break user code i.e. https://github.com/dlang/dub/pull/2208
+ if (!input.endsWith(dirSeparator))
+ return input ~ dirSeparator;
+ else
+ return input;
+ }
+
static string cache;
if (cache is null)
{
@@ -5294,7 +5308,7 @@ string tempDir() @trusted
static string findExistingDir(T...)(lazy T alternatives)
{
foreach (dir; alternatives)
- if (!dir.empty && exists(dir)) return dir ~ dirSeparator;
+ if (!dir.empty && exists(dir)) return addSeparator(dir);
return null;
}
@@ -5309,7 +5323,7 @@ string tempDir() @trusted
if (cache is null)
{
- cache = getcwd() ~ dirSeparator;
+ cache = addSeparator(getcwd());
}
}
return cache;
@@ -5338,6 +5352,9 @@ string tempDir() @trusted
import std.algorithm.searching : endsWith;
import std.path : dirSeparator;
assert(tempDir.endsWith(dirSeparator));
+
+ // https://issues.dlang.org/show_bug.cgi?id=22738
+ assert(!tempDir.endsWith(dirSeparator ~ dirSeparator));
}
/**
diff --git a/libphobos/src/std/functional.d b/libphobos/src/std/functional.d
index bc8d368..da698e0 100644
--- a/libphobos/src/std/functional.d
+++ b/libphobos/src/std/functional.d
@@ -68,6 +68,8 @@ import std.traits : isCallable, Parameters;
import std.internal.attributes : betterC;
+public import core.lifetime : forward;
+
private template needOpCallAlias(alias fun)
{
/* Determine whether or not unaryFun and binaryFun need to alias to fun or
@@ -1845,10 +1847,3 @@ if (isCallable!(F))
static assert(! is(typeof(dg_xtrnC) == typeof(dg_xtrnD)));
}
}
-
-// forward used to be here but was moved to druntime
-template forward(args...)
-{
- import core.lifetime : fun = forward;
- alias forward = fun!args;
-}
diff --git a/libphobos/src/std/internal/math/biguintcore.d b/libphobos/src/std/internal/math/biguintcore.d
index 6a93e0a..d5c4768 100644
--- a/libphobos/src/std/internal/math/biguintcore.d
+++ b/libphobos/src/std/internal/math/biguintcore.d
@@ -813,7 +813,7 @@ public:
// If wantSub is false, return x + y, leaving sign unchanged.
// If wantSub is true, return abs(x - y), negating sign if x<y
- static BigUint addOrSub(scope BigUint x, scope BigUint y, bool wantSub, bool *sign)
+ static BigUint addOrSub(scope BigUint x, scope BigUint y, bool wantSub, ref bool sign)
pure nothrow @safe
{
BigUint r;
@@ -822,10 +822,10 @@ public:
bool negative;
// sub returns GC allocated array, can be safely cast to immutable
r.data = (() @trusted => cast(immutable) sub(x.data, y.data, &negative))();
- *sign ^= negative;
+ sign ^= negative;
if (r.isZero())
{
- *sign = false;
+ sign = false;
}
}
else
diff --git a/libphobos/src/std/socket.d b/libphobos/src/std/socket.d
index f8908cf..cd23232 100644
--- a/libphobos/src/std/socket.d
+++ b/libphobos/src/std/socket.d
@@ -787,13 +787,20 @@ class InternetHost
assert(ih.name == "www.digitalmars.com" || ih.name == "digitalmars.com",
ih.name);
- assert(ih.getHostByAddr(ih.addrList[0]));
- string getHostNameFromInt = ih.name.dup;
+ /* The following assert randomly fails in the test suite.
+ * https://issues.dlang.org/show_bug.cgi?id=22791
+ * So just ignore it when it fails.
+ */
+ //assert(ih.getHostByAddr(ih.addrList[0]));
+ if (ih.getHostByAddr(ih.addrList[0]))
+ {
+ string getHostNameFromInt = ih.name.dup;
- assert(ih.getHostByAddr(ia.toAddrString()));
- string getHostNameFromStr = ih.name.dup;
+ assert(ih.getHostByAddr(ia.toAddrString()));
+ string getHostNameFromStr = ih.name.dup;
- assert(getHostNameFromInt == getHostNameFromStr);
+ assert(getHostNameFromInt == getHostNameFromStr);
+ }
}
diff --git a/libphobos/src/std/sumtype.d b/libphobos/src/std/sumtype.d
index 658fd38..5e35a6b 100644
--- a/libphobos/src/std/sumtype.d
+++ b/libphobos/src/std/sumtype.d
@@ -262,6 +262,8 @@ private enum isHashable(T) = __traits(compiles,
private enum hasPostblit(T) = __traits(hasPostblit, T);
+private enum isInout(T) = is(T == inout);
+
/**
* A [tagged union](https://en.wikipedia.org/wiki/Tagged_union) that can hold a
* single value from any of a specified set of types.
@@ -419,6 +421,7 @@ public:
(
allSatisfy!(isCopyable, Map!(InoutOf, Types))
&& !anySatisfy!(hasPostblit, Map!(InoutOf, Types))
+ && allSatisfy!(isInout, Map!(InoutOf, Types))
)
{
/// Constructs a `SumType` that's a copy of another `SumType`.
@@ -1492,6 +1495,23 @@ version (D_BetterC) {} else
immutable SumType!(int*) si = &ni;
}
+// Immutable member type with copy constructor
+// https://issues.dlang.org/show_bug.cgi?id=22572
+@safe unittest
+{
+ static struct CopyConstruct
+ {
+ this(ref inout CopyConstruct other) inout {}
+ }
+
+ static immutable struct Value
+ {
+ CopyConstruct c;
+ }
+
+ SumType!Value s;
+}
+
/// True if `T` is an instance of the `SumType` template, otherwise false.
private enum bool isSumTypeInstance(T) = is(T == SumType!Args, Args...);
diff --git a/libphobos/src/std/typecons.d b/libphobos/src/std/typecons.d
index 28edb9b..ea8f8bd 100644
--- a/libphobos/src/std/typecons.d
+++ b/libphobos/src/std/typecons.d
@@ -2798,13 +2798,24 @@ struct Nullable(T)
}
}
- this (ref return scope inout Nullable!T rhs) inout
+ static if (__traits(hasPostblit, T))
{
- _isNull = rhs._isNull;
- if (!_isNull)
- _value.payload = rhs._value.payload;
- else
- _value = DontCallDestructorT.init;
+ this(this)
+ {
+ if (!_isNull)
+ _value.payload.__xpostblit();
+ }
+ }
+ else static if (__traits(hasCopyConstructor, T))
+ {
+ this(ref return scope inout Nullable!T rhs) inout
+ {
+ _isNull = rhs._isNull;
+ if (!_isNull)
+ _value.payload = rhs._value.payload;
+ else
+ _value = DontCallDestructorT.init;
+ }
}
/**
@@ -9630,13 +9641,28 @@ unittest
{
int b;
@disable this(this);
- this (ref return scope inout S rhs) inout
+ this(ref return scope inout S rhs) inout
{
this.b = rhs.b + 1;
}
}
Nullable!S s1 = S(1);
+ assert(s1.get().b == 2);
+ Nullable!S s2 = s1;
+ assert(s2.get().b == 3);
+}
+
+@safe unittest
+{
+ static struct S
+ {
+ int b;
+ this(this) { ++b; }
+ }
+
+ Nullable!S s1 = S(1);
+ assert(s1.get().b == 2);
Nullable!S s2 = s1;
- assert(s2.get().b > s1.get().b);
+ assert(s2.get().b == 3);
}
diff --git a/libphobos/src/std/uni/package.d b/libphobos/src/std/uni/package.d
index 192b6fd..9780b1b 100644
--- a/libphobos/src/std/uni/package.d
+++ b/libphobos/src/std/uni/package.d
@@ -5363,7 +5363,7 @@ pure @safe unittest
pure @safe unittest
{
import std.range : stride;
- static bool testAll(Matcher, Range)(scope ref Matcher m, ref Range r)
+ static bool testAll(Matcher, Range)(ref Matcher m, ref Range r) @safe
{
bool t = m.test(r);
auto save = r.idx;
diff --git a/libphobos/src/std/zip.d b/libphobos/src/std/zip.d
index 4d7422b..72d1287 100644
--- a/libphobos/src/std/zip.d
+++ b/libphobos/src/std/zip.d
@@ -222,14 +222,6 @@ final class ArchiveMember
@property @safe pure nothrow @nogc uint expandedSize() const { return _expandedSize; }
/**
- * Should be 0.
- *
- * Returns: The number of the disk where this member can be found.
- */
- deprecated("Multidisk not supported; will be removed in 2.099.0")
- @property @safe pure nothrow @nogc ushort diskNumber() const { return 0; }
-
- /**
* Data of member in compressed form.
*
* Returns: The file data in compressed form.
@@ -452,13 +444,6 @@ public:
private bool _isZip64;
static const ushort zip64ExtractVersion = 45;
- deprecated("Use digitalSignatureLength instead; will be removed in 2.098.0")
- static const int digiSignLength = 6;
- deprecated("Use zip64EndOfCentralDirLocatorLength instead; will be removed in 2.098.0")
- static const int eocd64LocLength = 20;
- deprecated("Use zip64EndOfCentralDirLength instead; will be removed in 2.098.0")
- static const int eocd64Length = 56;
-
private Segment[] _segs;
/**
@@ -469,29 +454,11 @@ public:
@property @safe @nogc pure nothrow ubyte[] data() { return _data; }
/**
- * 0 since multi-disk zip archives are not supported.
- *
- * Returns: Number of this disk.
- */
- deprecated("Multidisk not supported; will be removed in 2.099.0")
- @property @safe @nogc pure nothrow uint diskNumber() const { return 0; }
-
- /**
- * 0 since multi-disk zip archives are not supported.
- *
- * Returns: Number of the disk, where the central directory starts.
- */
- deprecated("Multidisk not supported; will be removed in 2.099.0")
- @property @safe @nogc pure nothrow uint diskStartDir() const { return 0; }
-
- /**
* Number of ArchiveMembers in the directory.
*
* Returns: The number of files in this archive.
*/
- deprecated("Use totalEntries instead; will be removed in 2.099.0")
- @property @safe @nogc pure nothrow uint numEntries() const { return cast(uint) _directory.length; }
- @property @safe @nogc pure nothrow uint totalEntries() const { return cast(uint) _directory.length; } /// ditto
+ @property @safe @nogc pure nothrow uint totalEntries() const { return cast(uint) _directory.length; }
/**
* True when the archive is in Zip64 format. Set this to true to force building a Zip64 archive.
diff --git a/libphobos/testsuite/libphobos.betterc/test19933.d b/libphobos/testsuite/libphobos.betterc/test19933.d
new file mode 100644
index 0000000..a0faadd
--- /dev/null
+++ b/libphobos/testsuite/libphobos.betterc/test19933.d
@@ -0,0 +1,11 @@
+/*******************************************/
+// https://issues.dlang.org/show_bug.cgi?id=19933
+// https://issues.dlang.org/show_bug.cgi?id=18816
+
+import core.stdc.stdio;
+
+extern(C) int main()
+{
+ fprintf(stderr, "Hello\n");
+ return 0;
+}
diff --git a/libphobos/testsuite/libphobos.hash/test_hash.d b/libphobos/testsuite/libphobos.hash/test_hash.d
index d0a8e5fb..0ad2443 100644
--- a/libphobos/testsuite/libphobos.hash/test_hash.d
+++ b/libphobos/testsuite/libphobos.hash/test_hash.d
@@ -277,7 +277,7 @@ void issue22076()
static struct S1
{
S0 a;
- inout(S0)* b() inout nothrow { return &a; }
+ inout(S0)* b() inout return nothrow { return &a; }
alias b this;
}