summaryrefslogtreecommitdiffstats
path: root/libphobos
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2021-12-10 03:14:20 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2021-12-10 05:25:41 +0100
commit9c7d5e8846edb28e5421211ee8eaad93e234de2c (patch)
tree36b78f03305b82ef82ec5ecfaf29844fadd86ddc /libphobos
parentlibstdc++: Make atomic<T*>::wait() const [PR102994] (diff)
downloadgcc-9c7d5e8846edb28e5421211ee8eaad93e234de2c.tar.gz
gcc-9c7d5e8846edb28e5421211ee8eaad93e234de2c.tar.bz2
gcc-9c7d5e8846edb28e5421211ee8eaad93e234de2c.tar.xz
d: Merge upstream dmd 3982604c5, druntime bc58b1e9, phobos 12329adb6.
D front-end changes: - Import dmd mainline development. - Split off enum EXP from enum TOK. - Integer promotions now follow C integral promotions by default. - Implements __traits(initSymbol). - Lowering of array construction has been moved to the dmd front-end. - Fix segfault in dmd.lexer from unaligned read (PR103529). Druntime changes: - Import druntime mainline development. - Define SIG_BLOCK for Solaris (PR103528). Phobos changes: - Import phobos mainline development. gcc/d/ChangeLog: PR d/103529 * dmd/MERGE: Merge upstream dmd 3982604c5. * Make-lang.in (D_FRONTEND_OBJS): Add d/root-optional.o. * d-attribs.cc (build_attributes): Update for new front-end interface. * d-codegen.cc (d_build_call): Likewise. * d-compiler.cc (Compiler::paintAsType): Likewise. * d-lang.cc (d_handle_option): Remove OPT_fpreview_intpromote, add handling of OPT_frevert_intpromote. * d-port.cc (Port::valcpy): Assert buffer is aligned. * d-target.cc (Target::isVectorOpSupported): Update for new front-end interface. * decl.cc (layout_class_initializer): Likewise. * expr.cc (lvalue_p): Likewise. (binop_assignment): Likewise. (ExprVisitor::visit): Likewise. (ExprVisitor::visit (AssignExp *)): Remove generation of _d_arrayctor and _d_arraysetctor library helpers. (ExprVisitor::visit (VarExp *)): Support __traits(initSymbol). * intrinsics.cc (expand_intrinsic_rotate): Update for new front-end interface. * lang.opt (fpreview=intpromote): Remove. (frevert=intpromote): New. * runtime.def (ARRAYCTOR): Remove. (ARRAYSETCTOR): Remove. * toir.cc (IRVisitor::visit): Update for new front-end interface. * types.cc (layout_aggregate_members): Likewise. * dmd/root/optional.d: New file. * dmd/root/optional.h: New file. libphobos/ChangeLog: PR d/103528 * libdruntime/MERGE: Merge upstream druntime bc58b1e9. * libdruntime/Makefile.am (DRUNTIME_DSOURCES_LINUX): Remove core/sys/linux/syscalls.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos 12329adb6. * testsuite/libphobos.config/config.exp: Add test22523. * libdruntime/core/sys/linux/syscalls.d: Removed. * testsuite/libphobos.config/test22523.d: New test.
Diffstat (limited to 'libphobos')
-rw-r--r--libphobos/libdruntime/MERGE2
-rw-r--r--libphobos/libdruntime/Makefile.am5
-rw-r--r--libphobos/libdruntime/Makefile.in12
-rw-r--r--libphobos/libdruntime/core/demangle.d8
-rw-r--r--libphobos/libdruntime/core/internal/array/construction.d43
-rw-r--r--libphobos/libdruntime/core/internal/convert.d8
-rw-r--r--libphobos/libdruntime/core/internal/lifetime.d49
-rw-r--r--libphobos/libdruntime/core/internal/string.d2
-rw-r--r--libphobos/libdruntime/core/internal/utf.d10
-rw-r--r--libphobos/libdruntime/core/lifetime.d111
-rw-r--r--libphobos/libdruntime/core/memory.d21
-rw-r--r--libphobos/libdruntime/core/stdc/stdlib.d10
-rw-r--r--libphobos/libdruntime/core/stdc/string.d28
-rw-r--r--libphobos/libdruntime/core/stdc/wchar_.d26
-rw-r--r--libphobos/libdruntime/core/stdcpp/exception.d2
-rw-r--r--libphobos/libdruntime/core/sync/mutex.d4
-rw-r--r--libphobos/libdruntime/core/sys/bionic/string.d2
-rw-r--r--libphobos/libdruntime/core/sys/darwin/mach/nlist.d2
-rw-r--r--libphobos/libdruntime/core/sys/darwin/string.d2
-rw-r--r--libphobos/libdruntime/core/sys/dragonflybsd/string.d2
-rw-r--r--libphobos/libdruntime/core/sys/freebsd/string.d2
-rw-r--r--libphobos/libdruntime/core/sys/linux/string.d2
-rw-r--r--libphobos/libdruntime/core/sys/linux/syscalls.d745
-rw-r--r--libphobos/libdruntime/core/sys/linux/unistd.d26
-rw-r--r--libphobos/libdruntime/core/sys/netbsd/string.d2
-rw-r--r--libphobos/libdruntime/core/sys/openbsd/string.d2
-rw-r--r--libphobos/libdruntime/core/sys/posix/signal.d26
-rw-r--r--libphobos/libdruntime/core/sys/posix/string.d8
-rw-r--r--libphobos/libdruntime/core/sys/posix/sys/socket.d2
-rw-r--r--libphobos/libdruntime/core/sys/solaris/sys/elf.d5
-rw-r--r--libphobos/libdruntime/core/sys/solaris/sys/elf_386.d3
-rw-r--r--libphobos/libdruntime/core/sys/solaris/sys/elf_SPARC.d3
-rw-r--r--libphobos/libdruntime/core/sys/windows/dbghelp.d8
-rw-r--r--libphobos/libdruntime/core/thread/osthread.d5
-rw-r--r--libphobos/libdruntime/core/thread/threadbase.d5
-rw-r--r--libphobos/libdruntime/object.d8
-rw-r--r--libphobos/libdruntime/rt/aaA.d4
-rw-r--r--libphobos/libdruntime/rt/cast_.d2
-rw-r--r--libphobos/libdruntime/rt/config.d3
-rw-r--r--libphobos/libdruntime/rt/lifetime.d4
-rw-r--r--libphobos/libdruntime/rt/monitor_.d2
-rw-r--r--libphobos/src/MERGE2
-rw-r--r--libphobos/src/std/algorithm/iteration.d52
-rw-r--r--libphobos/src/std/algorithm/mutation.d29
-rw-r--r--libphobos/src/std/algorithm/sorting.d26
-rw-r--r--libphobos/src/std/concurrency.d32
-rw-r--r--libphobos/src/std/container/dlist.d6
-rw-r--r--libphobos/src/std/container/rbtree.d2
-rw-r--r--libphobos/src/std/datetime/interval.d6
-rw-r--r--libphobos/src/std/datetime/systime.d27
-rw-r--r--libphobos/src/std/datetime/timezone.d74
-rw-r--r--libphobos/src/std/file.d28
-rw-r--r--libphobos/src/std/internal/cstring.d2
-rw-r--r--libphobos/src/std/internal/math/biguintcore.d12
-rw-r--r--libphobos/src/std/json.d10
-rw-r--r--libphobos/src/std/net/isemail.d2
-rw-r--r--libphobos/src/std/process.d4
-rw-r--r--libphobos/src/std/random.d12
-rw-r--r--libphobos/src/std/stdio.d2
-rw-r--r--libphobos/src/std/typecons.d35
-rw-r--r--libphobos/src/std/uni/package.d4
-rw-r--r--libphobos/src/std/utf.d12
-rw-r--r--libphobos/testsuite/libphobos.config/config.exp1
-rw-r--r--libphobos/testsuite/libphobos.config/test22523.d11
64 files changed, 527 insertions, 1080 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index d0d3a25ad1e..edb101758b8 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
1178c44ff362902af589603767055cfac89215652 1bc58b1e9ea68051af9094651a26313371297b79f
2 2
3The first line of this file holds the git revision number of the last 3The first line of this file holds the git revision number of the last
4merge done from the dlang/druntime repository. 4merge done from the dlang/druntime repository.
diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am
index 44d4fe16be0..224d06e78ca 100644
--- a/libphobos/libdruntime/Makefile.am
+++ b/libphobos/libdruntime/Makefile.am
@@ -280,9 +280,8 @@ DRUNTIME_DSOURCES_LINUX = core/sys/linux/config.d \
280 core/sys/linux/sys/procfs.d core/sys/linux/sys/signalfd.d \ 280 core/sys/linux/sys/procfs.d core/sys/linux/sys/signalfd.d \
281 core/sys/linux/sys/socket.d core/sys/linux/sys/sysinfo.d \ 281 core/sys/linux/sys/socket.d core/sys/linux/sys/sysinfo.d \
282 core/sys/linux/sys/time.d core/sys/linux/sys/xattr.d \ 282 core/sys/linux/sys/time.d core/sys/linux/sys/xattr.d \
283 core/sys/linux/syscalls.d core/sys/linux/termios.d \ 283 core/sys/linux/termios.d core/sys/linux/time.d \
284 core/sys/linux/time.d core/sys/linux/timerfd.d core/sys/linux/tipc.d \ 284 core/sys/linux/timerfd.d core/sys/linux/tipc.d core/sys/linux/unistd.d
285 core/sys/linux/unistd.d
286 285
287DRUNTIME_DSOURCES_NETBSD = core/sys/netbsd/dlfcn.d \ 286DRUNTIME_DSOURCES_NETBSD = core/sys/netbsd/dlfcn.d \
288 core/sys/netbsd/err.d core/sys/netbsd/execinfo.d \ 287 core/sys/netbsd/err.d core/sys/netbsd/execinfo.d \
diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in
index 84be8082f7a..bb936ddc1ff 100644
--- a/libphobos/libdruntime/Makefile.in
+++ b/libphobos/libdruntime/Makefile.in
@@ -367,9 +367,9 @@ am__objects_18 = core/sys/linux/config.lo core/sys/linux/dlfcn.lo \
367 core/sys/linux/sys/procfs.lo core/sys/linux/sys/signalfd.lo \ 367 core/sys/linux/sys/procfs.lo core/sys/linux/sys/signalfd.lo \
368 core/sys/linux/sys/socket.lo core/sys/linux/sys/sysinfo.lo \ 368 core/sys/linux/sys/socket.lo core/sys/linux/sys/sysinfo.lo \
369 core/sys/linux/sys/time.lo core/sys/linux/sys/xattr.lo \ 369 core/sys/linux/sys/time.lo core/sys/linux/sys/xattr.lo \
370 core/sys/linux/syscalls.lo core/sys/linux/termios.lo \ 370 core/sys/linux/termios.lo core/sys/linux/time.lo \
371 core/sys/linux/time.lo core/sys/linux/timerfd.lo \ 371 core/sys/linux/timerfd.lo core/sys/linux/tipc.lo \
372 core/sys/linux/tipc.lo core/sys/linux/unistd.lo 372 core/sys/linux/unistd.lo
373@DRUNTIME_OS_LINUX_TRUE@am__objects_19 = $(am__objects_18) 373@DRUNTIME_OS_LINUX_TRUE@am__objects_19 = $(am__objects_18)
374am__objects_20 = core/sys/windows/accctrl.lo \ 374am__objects_20 = core/sys/windows/accctrl.lo \
375 core/sys/windows/aclapi.lo core/sys/windows/aclui.lo \ 375 core/sys/windows/aclapi.lo core/sys/windows/aclui.lo \
@@ -944,9 +944,8 @@ DRUNTIME_DSOURCES_LINUX = core/sys/linux/config.d \
944 core/sys/linux/sys/procfs.d core/sys/linux/sys/signalfd.d \ 944 core/sys/linux/sys/procfs.d core/sys/linux/sys/signalfd.d \
945 core/sys/linux/sys/socket.d core/sys/linux/sys/sysinfo.d \ 945 core/sys/linux/sys/socket.d core/sys/linux/sys/sysinfo.d \
946 core/sys/linux/sys/time.d core/sys/linux/sys/xattr.d \ 946 core/sys/linux/sys/time.d core/sys/linux/sys/xattr.d \
947 core/sys/linux/syscalls.d core/sys/linux/termios.d \ 947 core/sys/linux/termios.d core/sys/linux/time.d \
948 core/sys/linux/time.d core/sys/linux/timerfd.d core/sys/linux/tipc.d \ 948 core/sys/linux/timerfd.d core/sys/linux/tipc.d core/sys/linux/unistd.d
949 core/sys/linux/unistd.d
950 949
951DRUNTIME_DSOURCES_NETBSD = core/sys/netbsd/dlfcn.d \ 950DRUNTIME_DSOURCES_NETBSD = core/sys/netbsd/dlfcn.d \
952 core/sys/netbsd/err.d core/sys/netbsd/execinfo.d \ 951 core/sys/netbsd/err.d core/sys/netbsd/execinfo.d \
@@ -1675,7 +1674,6 @@ core/sys/linux/sys/socket.lo: core/sys/linux/sys/$(am__dirstamp)
1675core/sys/linux/sys/sysinfo.lo: core/sys/linux/sys/$(am__dirstamp) 1674core/sys/linux/sys/sysinfo.lo: core/sys/linux/sys/$(am__dirstamp)
1676core/sys/linux/sys/time.lo: core/sys/linux/sys/$(am__dirstamp) 1675core/sys/linux/sys/time.lo: core/sys/linux/sys/$(am__dirstamp)
1677core/sys/linux/sys/xattr.lo: core/sys/linux/sys/$(am__dirstamp) 1676core/sys/linux/sys/xattr.lo: core/sys/linux/sys/$(am__dirstamp)
1678core/sys/linux/syscalls.lo: core/sys/linux/$(am__dirstamp)
1679core/sys/linux/termios.lo: core/sys/linux/$(am__dirstamp) 1677core/sys/linux/termios.lo: core/sys/linux/$(am__dirstamp)
1680core/sys/linux/time.lo: core/sys/linux/$(am__dirstamp) 1678core/sys/linux/time.lo: core/sys/linux/$(am__dirstamp)
1681core/sys/linux/timerfd.lo: core/sys/linux/$(am__dirstamp) 1679core/sys/linux/timerfd.lo: core/sys/linux/$(am__dirstamp)
diff --git a/libphobos/libdruntime/core/demangle.d b/libphobos/libdruntime/core/demangle.d
index 33ca0ddc7bd..1915fb0844a 100644
--- a/libphobos/libdruntime/core/demangle.d
+++ b/libphobos/libdruntime/core/demangle.d
@@ -54,13 +54,13 @@ pure @safe:
54 enum AddType { no, yes } 54 enum AddType { no, yes }
55 55
56 56
57 this( return const(char)[] buf_, return char[] dst_ = null ) 57 this( return scope const(char)[] buf_, return scope char[] dst_ = null )
58 { 58 {
59 this( buf_, AddType.yes, dst_ ); 59 this( buf_, AddType.yes, dst_ );
60 } 60 }
61 61
62 62
63 this( return const(char)[] buf_, AddType addType_, return char[] dst_ = null ) 63 this( return scope const(char)[] buf_, AddType addType_, return scope char[] dst_ = null )
64 { 64 {
65 buf = buf_; 65 buf = buf_;
66 addType = addType_; 66 addType = addType_;
@@ -105,7 +105,7 @@ pure @safe:
105 //throw new ParseException( msg ); 105 //throw new ParseException( msg );
106 debug(info) printf( "error: %.*s\n", cast(int) msg.length, msg.ptr ); 106 debug(info) printf( "error: %.*s\n", cast(int) msg.length, msg.ptr );
107 throw __ctfe ? new ParseException(msg) 107 throw __ctfe ? new ParseException(msg)
108 : cast(ParseException) cast(void*) typeid(ParseException).initializer; 108 : cast(ParseException) __traits(initSymbol, ParseException).ptr;
109 109
110 } 110 }
111 111
@@ -116,7 +116,7 @@ pure @safe:
116 116
117 //throw new OverflowException( msg ); 117 //throw new OverflowException( msg );
118 debug(info) printf( "overflow: %.*s\n", cast(int) msg.length, msg.ptr ); 118 debug(info) printf( "overflow: %.*s\n", cast(int) msg.length, msg.ptr );
119 throw cast(OverflowException) cast(void*) typeid(OverflowException).initializer; 119 throw cast(OverflowException) __traits(initSymbol, OverflowException).ptr;
120 } 120 }
121 121
122 122
diff --git a/libphobos/libdruntime/core/internal/array/construction.d b/libphobos/libdruntime/core/internal/array/construction.d
index 9c8223767e1..ae71f513129 100644
--- a/libphobos/libdruntime/core/internal/array/construction.d
+++ b/libphobos/libdruntime/core/internal/array/construction.d
@@ -14,16 +14,27 @@ import core.internal.traits : Unqual;
14/** 14/**
15 * Does array initialization (not assignment) from another array of the same element type. 15 * Does array initialization (not assignment) from another array of the same element type.
16 * Params: 16 * Params:
17 * to = what array to initialize
17 * from = what data the array should be initialized with 18 * from = what data the array should be initialized with
19 * makeWeaklyPure = unused; its purpose is to prevent the function from becoming
20 * strongly pure and risk being optimised out
18 * Returns: 21 * Returns:
19 * The created and initialized array `to` 22 * The created and initialized array `to`
20 * Bugs: 23 * Bugs:
21 * This function template was ported from a much older runtime hook that bypassed safety, 24 * This function template was ported from a much older runtime hook that bypassed safety,
22 * purity, and throwabilty checks. To prevent breaking existing code, this function template 25 * purity, and throwabilty checks. To prevent breaking existing code, this function template
23 * is temporarily declared `@trusted` until the implementation can be brought up to modern D expectations. 26 * is temporarily declared `@trusted` until the implementation can be brought up to modern D expectations.
27 *
28 * The third parameter is never used, but is necessary in order for the
29 * function be treated as weakly pure, instead of strongly pure.
30 * This is needed because constructions such as the one below can be ignored by
31 * the compiler if `_d_arrayctor` is believed to be pure, because purity would
32 * mean the call to `_d_arrayctor` has no effects (no side effects and the
33 * return value is ignored), despite it actually modifying the contents of `a`.
34 * const S[2] b;
35 * const S[2] a = b; // this would get lowered to _d_arrayctor(a, b)
24 */ 36 */
25Tarr1 _d_arrayctor(Tarr1 : T1[], Tarr2 : T2[], T1, T2)(scope Tarr2 from) @trusted 37Tarr _d_arrayctor(Tarr : T[], T)(return scope Tarr to, scope Tarr from, char* makeWeaklyPure = null) @trusted
26 if (is(Unqual!T1 == Unqual!T2))
27{ 38{
28 pragma(inline, false); 39 pragma(inline, false);
29 import core.internal.traits : hasElaborateCopyConstructor; 40 import core.internal.traits : hasElaborateCopyConstructor;
@@ -32,14 +43,12 @@ Tarr1 _d_arrayctor(Tarr1 : T1[], Tarr2 : T2[], T1, T2)(scope Tarr2 from) @truste
32 import core.stdc.stdint : uintptr_t; 43 import core.stdc.stdint : uintptr_t;
33 debug(PRINTF) import core.stdc.stdio : printf; 44 debug(PRINTF) import core.stdc.stdio : printf;
34 45
35 debug(PRINTF) printf("_d_arrayctor(to = %p,%d, from = %p,%d) size = %d\n", from.ptr, from.length, to.ptr, to.length, T1.tsize); 46 debug(PRINTF) printf("_d_arrayctor(from = %p,%d) size = %d\n", from.ptr, from.length, T.sizeof);
36 47
37 Tarr1 to = void; 48 void[] vFrom = (cast(void*) from.ptr)[0..from.length];
49 void[] vTo = (cast(void*) to.ptr)[0..to.length];
38 50
39 void[] vFrom = (cast(void*)from.ptr)[0..from.length]; 51 // Force `enforceRawArraysConformable` to remain weakly `pure`
40 void[] vTo = (cast(void*)to.ptr)[0..to.length];
41
42 // Force `enforceRawArraysConformable` to be `pure`
43 void enforceRawArraysConformable(const char[] action, const size_t elementSize, 52 void enforceRawArraysConformable(const char[] action, const size_t elementSize,
44 const void[] a1, const void[] a2) @trusted 53 const void[] a1, const void[] a2) @trusted
45 { 54 {
@@ -50,9 +59,9 @@ Tarr1 _d_arrayctor(Tarr1 : T1[], Tarr2 : T2[], T1, T2)(scope Tarr2 from) @truste
50 (cast(Type)&enforceRawArraysConformableNogc)(action, elementSize, a1, a2, false); 59 (cast(Type)&enforceRawArraysConformableNogc)(action, elementSize, a1, a2, false);
51 } 60 }
52 61
53 enforceRawArraysConformable("initialization", T1.sizeof, vFrom, vTo); 62 enforceRawArraysConformable("initialization", T.sizeof, vFrom, vTo);
54 63
55 static if (hasElaborateCopyConstructor!T1) 64 static if (hasElaborateCopyConstructor!T)
56 { 65 {
57 size_t i; 66 size_t i;
58 try 67 try
@@ -66,7 +75,7 @@ Tarr1 _d_arrayctor(Tarr1 : T1[], Tarr2 : T2[], T1, T2)(scope Tarr2 from) @truste
66 */ 75 */
67 while (i--) 76 while (i--)
68 { 77 {
69 auto elem = cast(Unqual!T1*)&to[i]; 78 auto elem = cast(Unqual!T*) &to[i];
70 destroy(*elem); 79 destroy(*elem);
71 } 80 }
72 81
@@ -76,7 +85,7 @@ Tarr1 _d_arrayctor(Tarr1 : T1[], Tarr2 : T2[], T1, T2)(scope Tarr2 from) @truste
76 else 85 else
77 { 86 {
78 // blit all elements at once 87 // blit all elements at once
79 memcpy(cast(void*) to.ptr, from.ptr, to.length * T1.sizeof); 88 memcpy(cast(void*) to.ptr, from.ptr, to.length * T.sizeof);
80 } 89 }
81 90
82 return to; 91 return to;
@@ -94,7 +103,7 @@ Tarr1 _d_arrayctor(Tarr1 : T1[], Tarr2 : T2[], T1, T2)(scope Tarr2 from) @truste
94 103
95 S[4] arr1; 104 S[4] arr1;
96 S[4] arr2 = [S(0), S(1), S(2), S(3)]; 105 S[4] arr2 = [S(0), S(1), S(2), S(3)];
97 arr1 = _d_arrayctor!(typeof(arr1))(arr2[]); 106 _d_arrayctor(arr1[], arr2[]);
98 107
99 assert(counter == 4); 108 assert(counter == 4);
100 assert(arr1 == arr2); 109 assert(arr1 == arr2);
@@ -117,7 +126,7 @@ Tarr1 _d_arrayctor(Tarr1 : T1[], Tarr2 : T2[], T1, T2)(scope Tarr2 from) @truste
117 126
118 S[4] arr1; 127 S[4] arr1;
119 S[4] arr2 = [S(0), S(1), S(2), S(3)]; 128 S[4] arr2 = [S(0), S(1), S(2), S(3)];
120 arr1 = _d_arrayctor!(typeof(arr1))(arr2[]); 129 _d_arrayctor(arr1[], arr2[]);
121 130
122 assert(counter == 4); 131 assert(counter == 4);
123 assert(arr1 == arr2); 132 assert(arr1 == arr2);
@@ -143,7 +152,7 @@ Tarr1 _d_arrayctor(Tarr1 : T1[], Tarr2 : T2[], T1, T2)(scope Tarr2 from) @truste
143 { 152 {
144 Throw[4] a; 153 Throw[4] a;
145 Throw[4] b = [Throw(1), Throw(2), Throw(3), Throw(4)]; 154 Throw[4] b = [Throw(1), Throw(2), Throw(3), Throw(4)];
146 a = _d_arrayctor!(typeof(a))(b[]); 155 _d_arrayctor(a[], b[]);
147 } 156 }
148 catch (Exception) 157 catch (Exception)
149 { 158 {
@@ -168,7 +177,7 @@ Tarr1 _d_arrayctor(Tarr1 : T1[], Tarr2 : T2[], T1, T2)(scope Tarr2 from) @truste
168 { 177 {
169 NoThrow[4] a; 178 NoThrow[4] a;
170 NoThrow[4] b = [NoThrow(1), NoThrow(2), NoThrow(3), NoThrow(4)]; 179 NoThrow[4] b = [NoThrow(1), NoThrow(2), NoThrow(3), NoThrow(4)];
171 a = _d_arrayctor!(typeof(a))(b[]); 180 _d_arrayctor(a[], b[]);
172 } 181 }
173 catch (Exception) 182 catch (Exception)
174 { 183 {
@@ -274,7 +283,7 @@ void _d_arraysetctor(Tarr : T[], T)(scope Tarr p, scope ref T value) @trusted
274 { 283 {
275 Throw[4] a; 284 Throw[4] a;
276 Throw[4] b = [Throw(1), Throw(2), Throw(3), Throw(4)]; 285 Throw[4] b = [Throw(1), Throw(2), Throw(3), Throw(4)];
277 a = _d_arrayctor!(typeof(a))(b[]); 286 _d_arrayctor(a[], b[]);
278 } 287 }
279 catch (Exception) 288 catch (Exception)
280 { 289 {
diff --git a/libphobos/libdruntime/core/internal/convert.d b/libphobos/libdruntime/core/internal/convert.d
index 2789d2913a7..a876fcc537f 100644
--- a/libphobos/libdruntime/core/internal/convert.d
+++ b/libphobos/libdruntime/core/internal/convert.d
@@ -801,7 +801,7 @@ const(ubyte)[] toUbyte(T)(const ref T val) if (is(T == delegate) || is(T : V*, V
801} 801}
802 802
803@trusted pure nothrow @nogc 803@trusted pure nothrow @nogc
804const(ubyte)[] toUbyte(T)(const ref return scope T val) if (is(T == struct) || is(T == union)) 804const(ubyte)[] toUbyte(T)(const return ref scope T val) if (is(T == struct) || is(T == union))
805{ 805{
806 if (__ctfe) 806 if (__ctfe)
807 { 807 {
@@ -826,7 +826,11 @@ const(ubyte)[] toUbyte(T)(const ref return scope T val) if (is(T == struct) || i
826 } 826 }
827 else 827 else
828 { 828 {
829 return (cast(const(ubyte)*)&val)[0 .. T.sizeof]; 829 // We're escaping a reference to `val` here because we cannot express
830 // ref return + scope, it's currently seen as ref + return scope
831 // https://issues.dlang.org/show_bug.cgi?id=22541
832 // Once fixed, the @system lambda should be removed
833 return (() @system => (cast(const(ubyte)*)&val)[0 .. T.sizeof])();
830 } 834 }
831} 835}
832 836
diff --git a/libphobos/libdruntime/core/internal/lifetime.d b/libphobos/libdruntime/core/internal/lifetime.d
index 7e9b5f2ad48..a7446debae6 100644
--- a/libphobos/libdruntime/core/internal/lifetime.d
+++ b/libphobos/libdruntime/core/internal/lifetime.d
@@ -89,44 +89,35 @@ Emplaces T.init.
89In contrast to `emplaceRef(chunk)`, there are no checks for disabled default 89In contrast to `emplaceRef(chunk)`, there are no checks for disabled default
90constructors etc. 90constructors etc.
91+/ 91+/
92template emplaceInitializer(T) 92void emplaceInitializer(T)(scope ref T chunk) nothrow pure @trusted
93if (!is(T == const) && !is(T == immutable) && !is(T == inout)) 93if (!is(T == const) && !is(T == immutable) && !is(T == inout))
94{ 94{
95 import core.internal.traits : hasElaborateAssign, Unqual; 95 import core.internal.traits : hasElaborateAssign;
96 96
97 // Avoid stack allocation by hacking to get to the struct/union init symbol. 97 static if (__traits(isZeroInit, T))
98 static if (is(T == struct) || is(T == union))
99 { 98 {
100 pragma(mangle, "_D" ~ Unqual!T.mangleof[1..$] ~ "6__initZ") 99 import core.stdc.string : memset;
101 __gshared extern immutable T initializer; 100 memset(cast(void*) &chunk, 0, T.sizeof);
102 } 101 }
103 102 else static if (__traits(isScalar, T) ||
104 void emplaceInitializer(scope ref T chunk) nothrow pure @trusted 103 T.sizeof <= 16 && !hasElaborateAssign!T && __traits(compiles, (){ T chunk; chunk = T.init; }))
105 { 104 {
106 static if (__traits(isZeroInit, T)) 105 chunk = T.init;
107 { 106 }
108 import core.stdc.string : memset; 107 else static if (__traits(isStaticArray, T))
109 memset(cast(void*) &chunk, 0, T.sizeof); 108 {
110 } 109 // For static arrays there is no initializer symbol created. Instead, we emplace elements one-by-one.
111 else static if (__traits(isScalar, T) || 110 foreach (i; 0 .. T.length)
112 T.sizeof <= 16 && !hasElaborateAssign!T && __traits(compiles, (){ T chunk; chunk = T.init; }))
113 {
114 chunk = T.init;
115 }
116 else static if (__traits(isStaticArray, T))
117 {
118 // For static arrays there is no initializer symbol created. Instead, we emplace elements one-by-one.
119 foreach (i; 0 .. T.length)
120 {
121 emplaceInitializer(chunk[i]);
122 }
123 }
124 else
125 { 111 {
126 import core.stdc.string : memcpy; 112 emplaceInitializer(chunk[i]);
127 memcpy(cast(void*)&chunk, &initializer, T.sizeof);
128 } 113 }
129 } 114 }
115 else
116 {
117 import core.stdc.string : memcpy;
118 const initializer = __traits(initSymbol, T);
119 memcpy(cast(void*)&chunk, initializer.ptr, initializer.length);
120 }
130} 121}
131 122
132@safe unittest 123@safe unittest
diff --git a/libphobos/libdruntime/core/internal/string.d b/libphobos/libdruntime/core/internal/string.d
index 529fee49436..64a9cc92ffb 100644
--- a/libphobos/libdruntime/core/internal/string.d
+++ b/libphobos/libdruntime/core/internal/string.d
@@ -119,7 +119,7 @@ char[] signedToTempString(uint radix = 10)(long value, return scope char[] buf)
119 if (neg) 119 if (neg)
120 { 120 {
121 // about to do a slice without a bounds check 121 // about to do a slice without a bounds check
122 auto trustedSlice(return char[] r) @trusted { assert(r.ptr > buf.ptr); return (r.ptr-1)[0..r.length+1]; } 122 auto trustedSlice(return scope char[] r) @trusted { assert(r.ptr > buf.ptr); return (r.ptr-1)[0..r.length+1]; }
123 r = trustedSlice(r); 123 r = trustedSlice(r);
124 r[0] = '-'; 124 r[0] = '-';
125 } 125 }
diff --git a/libphobos/libdruntime/core/internal/utf.d b/libphobos/libdruntime/core/internal/utf.d
index ca0f7f599a6..27bf7f2b905 100644
--- a/libphobos/libdruntime/core/internal/utf.d
+++ b/libphobos/libdruntime/core/internal/utf.d
@@ -583,7 +583,7 @@ void validate(S)(const scope S s)
583/* =================== Conversion to UTF8 ======================= */ 583/* =================== Conversion to UTF8 ======================= */
584 584
585@safe pure nothrow @nogc 585@safe pure nothrow @nogc
586char[] toUTF8(return char[] buf, dchar c) 586char[] toUTF8(return scope char[] buf, dchar c)
587 in 587 in
588 { 588 {
589 assert(isValidDchar(c)); 589 assert(isValidDchar(c));
@@ -623,7 +623,7 @@ char[] toUTF8(return char[] buf, dchar c)
623 * Encodes string s into UTF-8 and returns the encoded string. 623 * Encodes string s into UTF-8 and returns the encoded string.
624 */ 624 */
625@safe pure nothrow 625@safe pure nothrow
626string toUTF8(return string s) 626string toUTF8(return scope string s)
627 in 627 in
628 { 628 {
629 validate(s); 629 validate(s);
@@ -692,7 +692,7 @@ string toUTF8(const scope dchar[] s)
692/* =================== Conversion to UTF16 ======================= */ 692/* =================== Conversion to UTF16 ======================= */
693 693
694@safe pure nothrow @nogc 694@safe pure nothrow @nogc
695wchar[] toUTF16(return wchar[] buf, dchar c) 695wchar[] toUTF16(return scope wchar[] buf, dchar c)
696 in 696 in
697 { 697 {
698 assert(isValidDchar(c)); 698 assert(isValidDchar(c));
@@ -784,7 +784,7 @@ wptr toUTF16z(const scope char[] s)
784 784
785/** ditto */ 785/** ditto */
786@safe pure nothrow 786@safe pure nothrow
787wstring toUTF16(return wstring s) 787wstring toUTF16(return scope wstring s)
788 in 788 in
789 { 789 {
790 validate(s); 790 validate(s);
@@ -864,7 +864,7 @@ dstring toUTF32(const scope wchar[] s)
864 864
865/** ditto */ 865/** ditto */
866@safe pure nothrow 866@safe pure nothrow
867dstring toUTF32(return dstring s) 867dstring toUTF32(return scope dstring s)
868 in 868 in
869 { 869 {
870 validate(s); 870 validate(s);
diff --git a/libphobos/libdruntime/core/lifetime.d b/libphobos/libdruntime/core/lifetime.d
index d93b891226c..b45e95f4226 100644
--- a/libphobos/libdruntime/core/lifetime.d
+++ b/libphobos/libdruntime/core/lifetime.d
@@ -103,8 +103,8 @@ T emplace(T, Args...)(T chunk, auto ref Args args)
103 " is abstract and it can't be emplaced"); 103 " is abstract and it can't be emplaced");
104 104
105 // Initialize the object in its pre-ctor state 105 // Initialize the object in its pre-ctor state
106 enum classSize = __traits(classInstanceSize, T); 106 const initializer = __traits(initSymbol, T);
107 (() @trusted => (cast(void*) chunk)[0 .. classSize] = typeid(T).initializer[])(); 107 (() @trusted { (cast(void*) chunk)[0 .. initializer.length] = initializer[]; })();
108 108
109 static if (isInnerClass!T) 109 static if (isInnerClass!T)
110 { 110 {
@@ -224,6 +224,31 @@ T emplace(T, Args...)(void[] chunk, auto ref Args args)
224 assert(c.i == 5); 224 assert(c.i == 5);
225} 225}
226 226
227///
228@betterC
229@nogc pure nothrow @system unittest
230{
231 // works with -betterC too:
232
233 static extern (C++) class C
234 {
235 @nogc pure nothrow @safe:
236 int i = 3;
237 this(int i)
238 {
239 assert(this.i == 3);
240 this.i = i;
241 }
242 int virtualGetI() { return i; }
243 }
244
245 import core.internal.traits : classInstanceAlignment;
246
247 align(classInstanceAlignment!C) byte[__traits(classInstanceSize, C)] buffer;
248 C c = emplace!C(buffer[], 42);
249 assert(c.virtualGetI() == 42);
250}
251
227@system unittest 252@system unittest
228{ 253{
229 class Outer 254 class Outer
@@ -1921,7 +1946,7 @@ private void moveImpl(T)(scope ref T target, return scope ref T source)
1921 1946
1922 static if (is(T == struct)) 1947 static if (is(T == struct))
1923 { 1948 {
1924 // Unsafe when compiling without -dip1000 1949 // Unsafe when compiling without -preview=dip1000
1925 if ((() @trusted => &source == &target)()) return; 1950 if ((() @trusted => &source == &target)()) return;
1926 // Destroy target before overwriting it 1951 // Destroy target before overwriting it
1927 static if (hasElaborateDestructor!T) target.__xdtor(); 1952 static if (hasElaborateDestructor!T) target.__xdtor();
@@ -2099,7 +2124,7 @@ private void moveEmplaceImpl(T)(scope ref T target, return scope ref T source)
2099 2124
2100 static if (is(T == struct)) 2125 static if (is(T == struct))
2101 { 2126 {
2102 // Unsafe when compiling without -dip1000 2127 // Unsafe when compiling without -preview=dip1000
2103 assert((() @trusted => &source !is &target)(), "source and target must not be identical"); 2128 assert((() @trusted => &source !is &target)(), "source and target must not be identical");
2104 2129
2105 static if (hasElaborateAssign!T || !isAssignable!T) 2130 static if (hasElaborateAssign!T || !isAssignable!T)
@@ -2123,12 +2148,7 @@ private void moveEmplaceImpl(T)(scope ref T target, return scope ref T source)
2123 static if (__traits(isZeroInit, T)) 2148 static if (__traits(isZeroInit, T))
2124 () @trusted { memset(&source, 0, sz); }(); 2149 () @trusted { memset(&source, 0, sz); }();
2125 else 2150 else
2126 { 2151 () @trusted { memcpy(&source, __traits(initSymbol, T).ptr, sz); }();
2127 import core.internal.lifetime : emplaceInitializer;
2128 ubyte[T.sizeof] init = void;
2129 emplaceInitializer(*(() @trusted { return cast(T*)init.ptr; }()));
2130 () @trusted { memcpy(&source, init.ptr, sz); }();
2131 }
2132 } 2152 }
2133 } 2153 }
2134 else static if (__traits(isStaticArray, T)) 2154 else static if (__traits(isStaticArray, T))
@@ -2201,3 +2221,74 @@ pure nothrow @nogc @system unittest
2201 static assert(!__traits(compiles, f(ncarray))); 2221 static assert(!__traits(compiles, f(ncarray)));
2202 f(move(ncarray)); 2222 f(move(ncarray));
2203} 2223}
2224
2225/**
2226 * This is called for a delete statement where the value
2227 * being deleted is a pointer to a struct with a destructor
2228 * but doesn't have an overloaded delete operator.
2229 *
2230 * Params:
2231 * p = pointer to the value to be deleted
2232 */
2233void _d_delstruct(T)(ref T *p)
2234{
2235 if (p)
2236 {
2237 debug(PRINTF) printf("_d_delstruct(%p)\n", p);
2238
2239 import core.memory : GC;
2240
2241 destroy(*p);
2242 GC.free(p);
2243 p = null;
2244 }
2245}
2246
2247@system unittest
2248{
2249 int dtors = 0;
2250 struct S { ~this() { ++dtors; } }
2251
2252 S *s = new S();
2253 _d_delstruct(s);
2254
2255 assert(s == null);
2256 assert(dtors == 1);
2257}
2258
2259@system unittest
2260{
2261 int innerDtors = 0;
2262 int outerDtors = 0;
2263
2264 struct Inner { ~this() { ++innerDtors; } }
2265 struct Outer
2266 {
2267 Inner *i1;
2268 Inner *i2;
2269
2270 this(int x)
2271 {
2272 i1 = new Inner();
2273 i2 = new Inner();
2274 }
2275
2276 ~this()
2277 {
2278 ++outerDtors;
2279
2280 _d_delstruct(i1);
2281 assert(i1 == null);
2282
2283 _d_delstruct(i2);
2284 assert(i2 == null);
2285 }
2286 }
2287
2288 Outer *o = new Outer(0);
2289 _d_delstruct(o);
2290
2291 assert(o == null);
2292 assert(innerDtors == 2);
2293 assert(outerDtors == 1);
2294}
diff --git a/libphobos/libdruntime/core/memory.d b/libphobos/libdruntime/core/memory.d
index 3770c13337c..c4df0f2d0dd 100644
--- a/libphobos/libdruntime/core/memory.d
+++ b/libphobos/libdruntime/core/memory.d
@@ -270,7 +270,7 @@ extern(C):
270 * reentrant, and must be called once for every call to disable before 270 * reentrant, and must be called once for every call to disable before
271 * automatic collections are enabled. 271 * automatic collections are enabled.
272 */ 272 */
273 pragma(mangle, "gc_enable") static void enable() nothrow; /* FIXME pure */ 273 pragma(mangle, "gc_enable") static void enable() nothrow pure;
274 274
275 275
276 /** 276 /**
@@ -280,7 +280,7 @@ extern(C):
280 * such as during an out of memory condition. This function is reentrant, 280 * such as during an out of memory condition. This function is reentrant,
281 * but enable must be called once for each call to disable. 281 * but enable must be called once for each call to disable.
282 */ 282 */
283 pragma(mangle, "gc_disable") static void disable() nothrow; /* FIXME pure */ 283 pragma(mangle, "gc_disable") static void disable() nothrow pure;
284 284
285 285
286 /** 286 /**
@@ -290,14 +290,14 @@ extern(C):
290 * and then to reclaim free space. This action may need to suspend all 290 * and then to reclaim free space. This action may need to suspend all
291 * running threads for at least part of the collection process. 291 * running threads for at least part of the collection process.
292 */ 292 */
293 pragma(mangle, "gc_collect") static void collect() nothrow; /* FIXME pure */ 293 pragma(mangle, "gc_collect") static void collect() nothrow pure;
294 294
295 /** 295 /**
296 * Indicates that the managed memory space be minimized by returning free 296 * Indicates that the managed memory space be minimized by returning free
297 * physical memory to the operating system. The amount of free memory 297 * physical memory to the operating system. The amount of free memory
298 * returned depends on the allocator design and on program behavior. 298 * returned depends on the allocator design and on program behavior.
299 */ 299 */
300 pragma(mangle, "gc_minimize") static void minimize() nothrow; /* FIXME pure */ 300 pragma(mangle, "gc_minimize") static void minimize() nothrow pure;
301 301
302extern(D): 302extern(D):
303 303
@@ -551,7 +551,7 @@ extern(C):
551 * Throws: 551 * Throws:
552 * `OutOfMemoryError` on allocation failure. 552 * `OutOfMemoryError` on allocation failure.
553 */ 553 */
554 pragma(mangle, "gc_realloc") static void* realloc(return void* p, size_t sz, uint ba = 0, const TypeInfo ti = null) pure nothrow; 554 pragma(mangle, "gc_realloc") static void* realloc(return scope void* p, size_t sz, uint ba = 0, const TypeInfo ti = null) pure nothrow;
555 555
556 // https://issues.dlang.org/show_bug.cgi?id=13111 556 // https://issues.dlang.org/show_bug.cgi?id=13111
557 /// 557 ///
@@ -635,7 +635,7 @@ extern(C):
635 * Returns: 635 * Returns:
636 * The actual number of bytes reserved or zero on error. 636 * The actual number of bytes reserved or zero on error.
637 */ 637 */
638 pragma(mangle, "gc_reserve") static size_t reserve(size_t sz) nothrow; /* FIXME pure */ 638 pragma(mangle, "gc_reserve") static size_t reserve(size_t sz) nothrow pure;
639 639
640 640
641 /** 641 /**
@@ -807,7 +807,7 @@ extern(C):
807 * } 807 * }
808 * --- 808 * ---
809 */ 809 */
810 pragma(mangle, "gc_addRoot") static void addRoot(const void* p) nothrow @nogc; /* FIXME pure */ 810 pragma(mangle, "gc_addRoot") static void addRoot(const void* p) nothrow @nogc pure;
811 811
812 812
813 /** 813 /**
@@ -818,7 +818,7 @@ extern(C):
818 * Params: 818 * Params:
819 * p = A pointer into a GC-managed memory block or null. 819 * p = A pointer into a GC-managed memory block or null.
820 */ 820 */
821 pragma(mangle, "gc_removeRoot") static void removeRoot(const void* p) nothrow @nogc; /* FIXME pure */ 821 pragma(mangle, "gc_removeRoot") static void removeRoot(const void* p) nothrow @nogc pure;
822 822
823 823
824 /** 824 /**
@@ -849,7 +849,8 @@ extern(C):
849 * // rawMemory will be recognized on collection. 849 * // rawMemory will be recognized on collection.
850 * --- 850 * ---
851 */ 851 */
852 pragma(mangle, "gc_addRange") static void addRange(const void* p, size_t sz, const TypeInfo ti = null) @nogc nothrow; /* FIXME pure */ 852 pragma(mangle, "gc_addRange")
853 static void addRange(const void* p, size_t sz, const TypeInfo ti = null) @nogc nothrow pure;
853 854
854 855
855 /** 856 /**
@@ -861,7 +862,7 @@ extern(C):
861 * Params: 862 * Params:
862 * p = A pointer to a valid memory address or to null. 863 * p = A pointer to a valid memory address or to null.
863 */ 864 */
864 pragma(mangle, "gc_removeRange") static void removeRange(const void* p) nothrow @nogc; /* FIXME pure */ 865 pragma(mangle, "gc_removeRange") static void removeRange(const void* p) nothrow @nogc pure;
865 866
866 867
867 /** 868 /**
diff --git a/libphobos/libdruntime/core/stdc/stdlib.d b/libphobos/libdruntime/core/stdc/stdlib.d
index 2f11a663eb5..92f8f705540 100644
--- a/libphobos/libdruntime/core/stdc/stdlib.d
+++ b/libphobos/libdruntime/core/stdc/stdlib.d
@@ -26,6 +26,10 @@ else version (TVOS)
26else version (WatchOS) 26else version (WatchOS)
27 version = Darwin; 27 version = Darwin;
28 28
29version (CRuntime_Glibc)
30 version = AlignedAllocSupported;
31else {}
32
29extern (C): 33extern (C):
30@system: 34@system:
31 35
@@ -166,6 +170,12 @@ void* realloc(void* ptr, size_t size);
166/// 170///
167void free(void* ptr); 171void free(void* ptr);
168 172
173/// since C11
174version (AlignedAllocSupported)
175{
176 void* aligned_alloc(size_t alignment, size_t size);
177}
178
169/// 179///
170noreturn abort() @safe; 180noreturn abort() @safe;
171/// 181///
diff --git a/libphobos/libdruntime/core/stdc/string.d b/libphobos/libdruntime/core/stdc/string.d
index a26811ca623..f15ef851909 100644
--- a/libphobos/libdruntime/core/stdc/string.d
+++ b/libphobos/libdruntime/core/stdc/string.d
@@ -35,31 +35,31 @@ nothrow:
35@nogc: 35@nogc:
36 36
37/// 37///
38inout(void)* memchr(return inout void* s, int c, size_t n) pure; 38inout(void)* memchr(return scope inout void* s, int c, size_t n) pure;
39/// 39///
40int memcmp(scope const void* s1, scope const void* s2, size_t n) pure; 40int memcmp(scope const void* s1, scope const void* s2, size_t n) pure;
41/// 41///
42void* memcpy(return void* s1, scope const void* s2, size_t n) pure; 42void* memcpy(return scope void* s1, scope const void* s2, size_t n) pure;
43version (Windows) 43version (Windows)
44{ 44{
45 /// 45 ///
46 int memicmp(scope const char* s1, scope const char* s2, size_t n); 46 int memicmp(scope const char* s1, scope const char* s2, size_t n);
47} 47}
48/// 48///
49void* memmove(return void* s1, scope const void* s2, size_t n) pure; 49void* memmove(return scope void* s1, scope const void* s2, size_t n) pure;
50/// 50///
51void* memset(return void* s, int c, size_t n) pure; 51void* memset(return scope void* s, int c, size_t n) pure;
52 52
53/// 53///
54char* strcat(return char* s1, scope const char* s2) pure; 54char* strcat(return scope char* s1, scope const char* s2) pure;
55/// 55///
56inout(char)* strchr(return inout(char)* s, int c) pure; 56inout(char)* strchr(return scope inout(char)* s, int c) pure;
57/// 57///
58int strcmp(scope const char* s1, scope const char* s2) pure; 58int strcmp(scope const char* s1, scope const char* s2) pure;
59/// 59///
60int strcoll(scope const char* s1, scope const char* s2); 60int strcoll(scope const char* s1, scope const char* s2);
61/// 61///
62char* strcpy(return char* s1, scope const char* s2) pure; 62char* strcpy(return scope char* s1, scope const char* s2) pure;
63/// 63///
64size_t strcspn(scope const char* s1, scope const char* s2) pure; 64size_t strcspn(scope const char* s1, scope const char* s2) pure;
65/// 65///
@@ -70,7 +70,7 @@ char* strerror(int errnum);
70version (ReturnStrerrorR) 70version (ReturnStrerrorR)
71{ 71{
72 /// 72 ///
73 const(char)* strerror_r(int errnum, return char* buf, size_t buflen); 73 const(char)* strerror_r(int errnum, return scope char* buf, size_t buflen);
74} 74}
75// This one is 75// This one is
76else 76else
@@ -80,20 +80,20 @@ else
80/// 80///
81size_t strlen(scope const char* s) pure; 81size_t strlen(scope const char* s) pure;
82/// 82///
83char* strncat(return char* s1, scope const char* s2, size_t n) pure; 83char* strncat(return scope char* s1, scope const char* s2, size_t n) pure;
84/// 84///
85int strncmp(scope const char* s1, scope const char* s2, size_t n) pure; 85int strncmp(scope const char* s1, scope const char* s2, size_t n) pure;
86/// 86///
87char* strncpy(return char* s1, scope const char* s2, size_t n) pure; 87char* strncpy(return scope char* s1, scope const char* s2, size_t n) pure;
88/// 88///
89inout(char)* strpbrk(return inout(char)* s1, scope const char* s2) pure; 89inout(char)* strpbrk(return scope inout(char)* s1, scope const char* s2) pure;
90/// 90///
91inout(char)* strrchr(return inout(char)* s, int c) pure; 91inout(char)* strrchr(return scope inout(char)* s, int c) pure;
92/// 92///
93size_t strspn(scope const char* s1, scope const char* s2) pure; 93size_t strspn(scope const char* s1, scope const char* s2) pure;
94/// 94///
95inout(char)* strstr(return inout(char)* s1, scope const char* s2) pure; 95inout(char)* strstr(return scope inout(char)* s1, scope const char* s2) pure;
96/// 96///
97char* strtok(return char* s1, scope const char* s2); 97char* strtok(return scope char* s1, scope const char* s2);
98/// 98///
99size_t strxfrm(scope char* s1, scope const char* s2, size_t n); 99size_t strxfrm(scope char* s1, scope const char* s2, size_t n);
diff --git a/libphobos/libdruntime/core/stdc/wchar_.d b/libphobos/libdruntime/core/stdc/wchar_.d
index 6da5618ada6..e8fb94b11e6 100644
--- a/libphobos/libdruntime/core/stdc/wchar_.d
+++ b/libphobos/libdruntime/core/stdc/wchar_.d
@@ -213,13 +213,13 @@ c_ulong wcstoul(const scope wchar_t* nptr, wchar_t** endptr, int base);
213ulong wcstoull(const scope wchar_t* nptr, wchar_t** endptr, int base); 213ulong wcstoull(const scope wchar_t* nptr, wchar_t** endptr, int base);
214 214
215/// 215///
216pure wchar_t* wcscpy(return wchar_t* s1, scope const wchar_t* s2); 216pure wchar_t* wcscpy(return scope wchar_t* s1, scope const wchar_t* s2);
217/// 217///
218pure wchar_t* wcsncpy(return wchar_t* s1, scope const wchar_t* s2, size_t n); 218pure wchar_t* wcsncpy(return scope wchar_t* s1, scope const wchar_t* s2, size_t n);
219/// 219///
220pure wchar_t* wcscat(return wchar_t* s1, scope const wchar_t* s2); 220pure wchar_t* wcscat(return scope wchar_t* s1, scope const wchar_t* s2);
221/// 221///
222pure wchar_t* wcsncat(return wchar_t* s1, scope const wchar_t* s2, size_t n); 222pure wchar_t* wcsncat(return scope wchar_t* s1, scope const wchar_t* s2, size_t n);
223/// 223///
224pure int wcscmp(scope const wchar_t* s1, scope const wchar_t* s2); 224pure int wcscmp(scope const wchar_t* s1, scope const wchar_t* s2);
225/// 225///
@@ -229,32 +229,32 @@ pure int wcsncmp(scope const wchar_t* s1, scope const wchar_t* s2, size_t n);
229/// 229///
230size_t wcsxfrm(scope wchar_t* s1, scope const wchar_t* s2, size_t n); 230size_t wcsxfrm(scope wchar_t* s1, scope const wchar_t* s2, size_t n);
231/// 231///
232pure inout(wchar_t)* wcschr(return inout(wchar_t)* s, wchar_t c); 232pure inout(wchar_t)* wcschr(return scope inout(wchar_t)* s, wchar_t c);
233/// 233///
234pure size_t wcscspn(scope const wchar_t* s1, scope const wchar_t* s2); 234pure size_t wcscspn(scope const wchar_t* s1, scope const wchar_t* s2);
235/// 235///
236pure inout(wchar_t)* wcspbrk(return inout(wchar_t)* s1, scope const wchar_t* s2); 236pure inout(wchar_t)* wcspbrk(return scope inout(wchar_t)* s1, scope const wchar_t* s2);
237/// 237///
238pure inout(wchar_t)* wcsrchr(return inout(wchar_t)* s, wchar_t c); 238pure inout(wchar_t)* wcsrchr(return scope inout(wchar_t)* s, wchar_t c);
239/// 239///
240pure size_t wcsspn(scope const wchar_t* s1, scope const wchar_t* s2); 240pure size_t wcsspn(scope const wchar_t* s1, scope const wchar_t* s2);
241/// 241///
242pure inout(wchar_t)* wcsstr(return inout(wchar_t)* s1, scope const wchar_t* s2); 242pure inout(wchar_t)* wcsstr(return scope inout(wchar_t)* s1, scope const wchar_t* s2);
243/// 243///
244wchar_t* wcstok(return wchar_t* s1, scope const wchar_t* s2, wchar_t** ptr); 244wchar_t* wcstok(return scope wchar_t* s1, scope const wchar_t* s2, wchar_t** ptr);
245/// 245///
246pure size_t wcslen(scope const wchar_t* s); 246pure size_t wcslen(scope const wchar_t* s);
247 247
248/// 248///
249pure inout(wchar_t)* wmemchr(return inout wchar_t* s, wchar_t c, size_t n); 249pure inout(wchar_t)* wmemchr(return scope inout wchar_t* s, wchar_t c, size_t n);
250/// 250///
251pure int wmemcmp(scope const wchar_t* s1, scope const wchar_t* s2, size_t n); 251pure int wmemcmp(scope const wchar_t* s1, scope const wchar_t* s2, size_t n);
252/// 252///
253pure wchar_t* wmemcpy(return wchar_t* s1, scope const wchar_t* s2, size_t n); 253pure wchar_t* wmemcpy(return scope wchar_t* s1, scope const wchar_t* s2, size_t n);
254/// 254///
255pure wchar_t* wmemmove(return wchar_t* s1, scope const wchar_t* s2, size_t n); 255pure wchar_t* wmemmove(return scope wchar_t* s1, scope const wchar_t* s2, size_t n);
256/// 256///
257pure wchar_t* wmemset(return wchar_t* s, wchar_t c, size_t n); 257pure wchar_t* wmemset(return scope wchar_t* s, wchar_t c, size_t n);
258 258
259/// 259///
260size_t wcsftime(wchar_t* s, size_t maxsize, const scope wchar_t* format, const scope tm* timeptr); 260size_t wcsftime(wchar_t* s, size_t maxsize, const scope wchar_t* format, const scope tm* timeptr);
diff --git a/libphobos/libdruntime/core/stdcpp/exception.d b/libphobos/libdruntime/core/stdcpp/exception.d
index f920057cd06..d65cd8d1832 100644
--- a/libphobos/libdruntime/core/stdcpp/exception.d
+++ b/libphobos/libdruntime/core/stdcpp/exception.d
@@ -19,6 +19,8 @@ version (CppRuntime_Gcc)
19 version = GenericBaseException; 19 version = GenericBaseException;
20version (CppRuntime_Clang) 20version (CppRuntime_Clang)
21 version = GenericBaseException; 21 version = GenericBaseException;
22version (CppRuntime_Sun)
23 version = GenericBaseException;
22 24
23extern (C++, "std"): 25extern (C++, "std"):
24@nogc: 26@nogc:
diff --git a/libphobos/libdruntime/core/sync/mutex.d b/libphobos/libdruntime/core/sync/mutex.d
index b153ab9aef0..b848a147460 100644
--- a/libphobos/libdruntime/core/sync/mutex.d
+++ b/libphobos/libdruntime/core/sync/mutex.d
@@ -189,7 +189,7 @@ class Mutex :
189 if (pthread_mutex_lock(&m_hndl) == 0) 189 if (pthread_mutex_lock(&m_hndl) == 0)
190 return; 190 return;
191 191
192 SyncError syncErr = cast(SyncError) cast(void*) typeid(SyncError).initializer; 192 SyncError syncErr = cast(SyncError) __traits(initSymbol, SyncError).ptr;
193 syncErr.msg = "Unable to lock mutex."; 193 syncErr.msg = "Unable to lock mutex.";
194 throw syncErr; 194 throw syncErr;
195 } 195 }
@@ -227,7 +227,7 @@ class Mutex :
227 if (pthread_mutex_unlock(&m_hndl) == 0) 227 if (pthread_mutex_unlock(&m_hndl) == 0)
228 return; 228 return;
229 229
230 SyncError syncErr = cast(SyncError) cast(void*) typeid(SyncError).initializer; 230 SyncError syncErr = cast(SyncError) __traits(initSymbol, SyncError).ptr;
231 syncErr.msg = "Unable to unlock mutex."; 231 syncErr.msg = "Unable to unlock mutex.";
232 throw syncErr; 232 throw syncErr;
233 } 233 }
diff --git a/libphobos/libdruntime/core/sys/bionic/string.d b/libphobos/libdruntime/core/sys/bionic/string.d
index cbee06c4efe..10a5610ac44 100644
--- a/libphobos/libdruntime/core/sys/bionic/string.d
+++ b/libphobos/libdruntime/core/sys/bionic/string.d
@@ -14,4 +14,4 @@ extern (C):
14nothrow: 14nothrow:
15@nogc: 15@nogc:
16 16
17pure void* memmem(return const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 17pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen);
diff --git a/libphobos/libdruntime/core/sys/darwin/mach/nlist.d b/libphobos/libdruntime/core/sys/darwin/mach/nlist.d
index 11e5ced26b7..4d400f207c7 100644
--- a/libphobos/libdruntime/core/sys/darwin/mach/nlist.d
+++ b/libphobos/libdruntime/core/sys/darwin/mach/nlist.d
@@ -222,7 +222,7 @@ enum
222 */ 222 */
223ubyte GET_LIBRARY_ORDINAL(uint n_desc) @safe { return ((n_desc) >> 8) & 0xff; } 223ubyte GET_LIBRARY_ORDINAL(uint n_desc) @safe { return ((n_desc) >> 8) & 0xff; }
224/// Ditto 224/// Ditto
225ref ushort SET_LIBRARY_ORDINAL(return scope ref ushort n_desc, uint ordinal) @safe 225ref ushort SET_LIBRARY_ORDINAL(return ref ushort n_desc, uint ordinal) @safe
226{ 226{
227 return n_desc = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8)); 227 return n_desc = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8));
228} 228}
diff --git a/libphobos/libdruntime/core/sys/darwin/string.d b/libphobos/libdruntime/core/sys/darwin/string.d
index bd65fde27bc..ac988b58f0d 100644
--- a/libphobos/libdruntime/core/sys/darwin/string.d
+++ b/libphobos/libdruntime/core/sys/darwin/string.d
@@ -27,5 +27,5 @@ nothrow:
27static if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) 27static if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL)
28{ 28{
29 // ^ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 29 // ^ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
30 pure void* memmem(return const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 30 pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen);
31} 31}
diff --git a/libphobos/libdruntime/core/sys/dragonflybsd/string.d b/libphobos/libdruntime/core/sys/dragonflybsd/string.d
index b64178f6562..4b8422748b6 100644
--- a/libphobos/libdruntime/core/sys/dragonflybsd/string.d
+++ b/libphobos/libdruntime/core/sys/dragonflybsd/string.d
@@ -17,6 +17,6 @@ nothrow:
17 17
18static if (__BSD_VISIBLE) 18static if (__BSD_VISIBLE)
19{ 19{
20 pure void* memmem(return const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 20 pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen);
21} 21}
22 22
diff --git a/libphobos/libdruntime/core/sys/freebsd/string.d b/libphobos/libdruntime/core/sys/freebsd/string.d
index 3602ea8e86b..459e9115878 100644
--- a/libphobos/libdruntime/core/sys/freebsd/string.d
+++ b/libphobos/libdruntime/core/sys/freebsd/string.d
@@ -17,5 +17,5 @@ nothrow:
17 17
18static if (__BSD_VISIBLE) 18static if (__BSD_VISIBLE)
19{ 19{
20 pure void* memmem(return const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 20 pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen);
21} 21}
diff --git a/libphobos/libdruntime/core/sys/linux/string.d b/libphobos/libdruntime/core/sys/linux/string.d
index 1b2c8d86a4a..e3c94cf6a8a 100644
--- a/libphobos/libdruntime/core/sys/linux/string.d
+++ b/libphobos/libdruntime/core/sys/linux/string.d
@@ -18,5 +18,5 @@ nothrow:
18 18
19static if (__USE_GNU) 19static if (__USE_GNU)
20{ 20{
21 pure void* memmem(return const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 21 pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen);
22} 22}
diff --git a/libphobos/libdruntime/core/sys/linux/syscalls.d b/libphobos/libdruntime/core/sys/linux/syscalls.d
deleted file mode 100644
index 8c653719317..00000000000
--- a/libphobos/libdruntime/core/sys/linux/syscalls.d
+++ /dev/null
@@ -1,745 +0,0 @@
1module core.sys.linux.syscalls;
2
3version (linux):
4extern (C):
5@system:
6nothrow:
7@nogc:
8
9import core.stdc.config : c_long;
10
11version (CoreDdoc)
12{
13 /// Linux system call number from Linux's asm/unistd.h
14 enum SystemCall : c_long;
15}
16else version (X86_64)
17{
18 // https://github.com/torvalds/linux/blob/v4.14/arch/sh/include/uapi/asm/unistd_64.h
19 // https://github.com/torvalds/linux/blob/v4.14/arch/x86/entry/syscalls/syscall_64.tbl
20 enum SystemCall : c_long
21 {
22 read = 0,
23 write = 1,
24 open = 2,
25 close = 3,
26 stat = 4,
27 fstat = 5,
28 lstat = 6,
29 poll = 7,
30 lseek = 8,
31 mmap = 9,
32 mprotect = 10,
33 munmap = 11,
34 brk = 12,
35 rt_sigaction = 13,
36 rt_sigprocmask = 14,
37 rt_sigreturn = 15,
38 ioctl = 16,
39 pread64 = 17,
40 pwrite64 = 18,
41 readv = 19,
42 writev = 20,
43 access = 21,
44 pipe = 22,
45 select = 23,
46 sched_yield = 24,
47 mremap = 25,
48 msync = 26,
49 mincore = 27,
50 madvise = 28,
51 shmget = 29,
52 shmat = 30,
53 shmctl = 31,
54 dup = 32,
55 dup2 = 33,
56 pause = 34,
57 nanosleep = 35,
58 getitimer = 36,
59 alarm = 37,
60 setitimer = 38,
61 getpid = 39,
62 sendfile = 40,
63 socket = 41,
64 connect = 42,
65 accept = 43,
66 sendto = 44,
67 recvfrom = 45,
68 sendmsg = 46,
69 recvmsg = 47,
70 shutdown = 48,
71 bind = 49,
72 listen = 50,
73 getsockname = 51,
74 getpeername = 52,
75 socketpair = 53,
76 setsockopt = 54,
77 getsockopt = 55,
78 clone = 56,
79 fork = 57,
80 vfork = 58,
81 execve = 59,
82 exit = 60,
83 wait4 = 61,
84 kill = 62,
85 uname = 63,
86 semget = 64,
87 semop = 65,
88 semctl = 66,
89 shmdt = 67,
90 msgget = 68,
91 msgsnd = 69,
92 msgrcv = 70,
93 msgctl = 71,
94 fcntl = 72,
95 flock = 73,
96 fsync = 74,
97 fdatasync = 75,
98 truncate = 76,
99 ftruncate = 77,
100 getdents = 78,
101 getcwd = 79,
102 chdir = 80,
103 fchdir = 81,
104 rename = 82,
105 mkdir = 83,
106 rmdir = 84,
107 creat = 85,
108 link = 86,
109 unlink = 87,
110 symlink = 88,
111 readlink = 89,
112 chmod = 90,
113 fchmod = 91,
114 chown = 92,
115 fchown = 93,
116 lchown = 94,
117 umask = 95,
118 gettimeofday = 96,
119 getrlimit = 97,
120 getrusage = 98,
121 sysinfo = 99,
122 times = 100,
123 ptrace = 101,
124 getuid = 102,
125 syslog = 103,
126 getgid = 104,
127 setuid = 105,
128 setgid = 106,
129 geteuid = 107,
130 getegid = 108,
131 setpgid = 109,
132 getppid = 110,
133 getpgrp = 111,
134 setsid = 112,
135 setreuid = 113,
136 setregid = 114,
137 getgroups = 115,
138 setgroups = 116,
139 setresuid = 117,
140 getresuid = 118,
141 setresgid = 119,
142 getresgid = 120,
143 getpgid = 121,
144 setfsuid = 122,
145 setfsgid = 123,
146 getsid = 124,
147 capget = 125,
148 capset = 126,
149 rt_sigpending = 127,
150 rt_sigtimedwait = 128,
151 rt_sigqueueinfo = 129,
152 rt_sigsuspend = 130,
153 sigaltstack = 131,
154 utime = 132,
155 mknod = 133,
156 uselib = 134,
157 personality = 135,
158 ustat = 136,
159 statfs = 137,
160 fstatfs = 138,
161 sysfs = 139,
162 getpriority = 140,
163 setpriority = 141,
164 sched_setparam = 142,
165 sched_getparam = 143,
166 sched_setscheduler = 144,
167 sched_getscheduler = 145,
168 sched_get_priority_max = 146,
169 sched_get_priority_min = 147,
170 sched_rr_get_interval = 148,
171 mlock = 149,
172 munlock = 150,
173 mlockall = 151,
174 munlockall = 152,
175 vhangup = 153,
176 modify_ldt = 154,
177 pivot_root = 155,
178 _sysctl = 156,
179 prctl = 157,
180 arch_prctl = 158,
181 adjtimex = 159,
182 setrlimit = 160,
183 chroot = 161,
184 sync = 162,
185 acct = 163,
186 settimeofday = 164,
187 mount = 165,
188 umount2 = 166,
189 swapon = 167,
190 swapoff = 168,
191 reboot = 169,
192 sethostname = 170,
193 setdomainname = 171,
194 iopl = 172,
195 ioperm = 173,
196 create_module = 174,
197 init_module = 175,
198 delete_module = 176,
199 get_kernel_syms = 177,
200 query_module = 178,
201 quotactl = 179,
202 nfsservctl = 180,
203 getpmsg = 181,
204 putpmsg = 182,
205 afs_syscall = 183,
206 tuxcall = 184,
207 security = 185,
208 gettid = 186,
209 readahead = 187,
210 setxattr = 188,
211 lsetxattr = 189,
212 fsetxattr = 190,
213 getxattr = 191,
214 lgetxattr = 192,
215 fgetxattr = 193,
216 listxattr = 194,
217 llistxattr = 195,
218 flistxattr = 196,
219 removexattr = 197,
220 lremovexattr = 198,
221 fremovexattr = 199,
222 tkill = 200,
223 time = 201,
224 futex = 202,
225 sched_setaffinity = 203,
226 sched_getaffinity = 204,
227 set_thread_area = 205,
228 io_setup = 206,
229 io_destroy = 207,
230 io_getevents = 208,
231 io_submit = 209,
232 io_cancel = 210,
233 get_thread_area = 211,
234 lookup_dcookie = 212,
235 epoll_create = 213,
236 epoll_ctl_old = 214,
237 epoll_wait_old = 215,
238 remap_file_pages = 216,
239 getdents64 = 217,
240 set_tid_address = 218,
241 restart_syscall = 219,
242 semtimedop = 220,
243 fadvise64 = 221,
244 timer_create = 222,
245 timer_settime = 223,
246 timer_gettime = 224,
247 timer_getoverrun = 225,
248 timer_delete = 226,
249 clock_settime = 227,
250 clock_gettime = 228,
251 clock_getres = 229,
252 clock_nanosleep = 230,
253 exit_group = 231,
254 epoll_wait = 232,
255 epoll_ctl = 233,
256 tgkill = 234,
257 utimes = 235,
258 vserver = 236,
259 mbind = 237,
260 set_mempolicy = 238,
261 get_mempolicy = 239,
262 mq_open = 240,
263 mq_unlink = 241,
264 mq_timedsend = 242,
265 mq_timedreceive = 243,
266 mq_notify = 244,
267 mq_getsetattr = 245,
268 kexec_load = 246,
269 waitid = 247,
270 add_key = 248,
271 request_key = 249,
272 keyctl = 250,
273 ioprio_set = 251,
274 ioprio_get = 252,
275 inotify_init = 253,
276 inotify_add_watch = 254,
277 inotify_rm_watch = 255,
278 migrate_pages = 256,
279 openat = 257,
280 mkdirat = 258,
281 mknodat = 259,
282 fchownat = 260,
283 futimesat = 261,
284 newfstatat = 262,
285 unlinkat = 263,
286 renameat = 264,
287 linkat = 265,
288 symlinkat = 266,
289 readlinkat = 267,
290 fchmodat = 268,
291 faccessat = 269,
292 pselect6 = 270,
293 ppoll = 271,
294 unshare = 272,
295 set_robust_list = 273,
296 get_robust_list = 274,
297 splice = 275,
298 tee = 276,
299 sync_file_range = 277,
300 vmsplice = 278,
301 move_pages = 279,
302 utimensat = 280,
303 epoll_pwait = 281,
304 signalfd = 282,
305 timerfd_create = 283,
306 eventfd = 284,
307 fallocate = 285,
308 timerfd_settime = 286,
309 timerfd_gettime = 287,
310 accept4 = 288,
311 signalfd4 = 289,
312 eventfd2 = 290,
313 epoll_create1 = 291,
314 dup3 = 292,
315 pipe2 = 293,
316 inotify_init1 = 294,
317 preadv = 295,
318 pwritev = 296,
319 rt_tgsigqueueinfo = 297,
320 perf_event_open = 298,
321 recvmmsg = 299,
322 fanotify_init = 300,
323 fanotify_mark = 301,
324 prlimit64 = 302,
325 name_to_handle_at = 303,
326 open_by_handle_at = 304,
327 clock_adjtime = 305,
328 syncfs = 306,
329 sendmmsg = 307,
330 setns = 308,
331 getcpu = 309,
332 process_vm_readv = 310,
333 process_vm_writev = 311,
334 kcmp = 312,
335 finit_module = 313,
336 sched_setattr = 314,
337 sched_getattr = 315,
338 renameat2 = 316,
339 seccomp = 317,
340 getrandom = 318,
341 memfd_create = 319,
342 kexec_file_load = 320,
343 bpf = 321,
344 execveat = 322,
345 userfaultfd = 323,
346 membarrier = 324,
347 mlock2 = 325,
348 copy_file_range = 326,
349 preadv2 = 327,
350 pwritev2 = 328,
351 pkey_mprotect = 329,
352 pkey_alloc = 330,
353 pkey_free = 331,
354 statx = 332,
355 }
356}
357else version (X86)
358{
359 // https://github.com/torvalds/linux/blob/master/arch/x86/entry/syscalls/syscall_32.tbl
360 // https://github.com/torvalds/linux/blob/v4.14/arch/sh/include/uapi/asm/unistd_32.h
361 enum SystemCall : c_long
362 {
363 restart_syscall = 0,
364 exit = 1,
365 fork = 2,
366 read = 3,
367 write = 4,
368 open = 5,
369 close = 6,
370 waitpid = 7,
371 creat = 8,
372 link = 9,
373 unlink = 10,
374 execve = 11,
375 chdir = 12,
376 time = 13,
377 mknod = 14,
378 chmod = 15,
379 lchown = 16,
380 break_ = 17,
381 oldstat = 18,
382 lseek = 19,
383 getpid = 20,
384 mount = 21,
385 umount = 22,
386 setuid = 23,
387 getuid = 24,
388 stime = 25,
389 ptrace = 26,
390 alarm = 27,
391 oldfstat = 28,
392 pause = 29,
393 utime = 30,
394 stty = 31,
395 gtty = 32,
396 access = 33,
397 nice = 34,
398 ftime = 35,
399 sync = 36,
400 kill = 37,
401 rename = 38,
402 mkdir = 39,
403 rmdir = 40,
404 dup = 41,
405 pipe = 42,
406 times = 43,
407 prof = 44,
408 brk = 45,
409 setgid = 46,
410 getgid = 47,
411 signal = 48,
412 geteuid = 49,
413 getegid = 50,
414 acct = 51,
415 umount2 = 52,
416 lock = 53,
417 ioctl = 54,
418 fcntl = 55,
419 mpx = 56,
420 setpgid = 57,
421 ulimit = 58,
422 oldolduname = 59,
423 umask = 60,
424 chroot = 61,
425 ustat = 62,
426 dup2 = 63,
427 getppid = 64,
428 getpgrp = 65,
429 setsid = 66,
430 sigaction = 67,
431 sgetmask = 68,
432 ssetmask = 69,
433 setreuid = 70,
434 setregid = 71,
435 sigsuspend = 72,
436 sigpending = 73,
437 sethostname = 74,
438 setrlimit = 75,
439 getrlimit = 76,
440 getrusage = 77,
441 gettimeofday = 78,
442 settimeofday = 79,
443 getgroups = 80,
444 setgroups = 81,
445 select = 82,
446 symlink = 83,
447 oldlstat = 84,
448 readlink = 85,
449 uselib = 86,
450 swapon = 87,
451 reboot = 88,
452 readdir = 89,
453 mmap = 90,
454 munmap = 91,
455 truncate = 92,
456 ftruncate = 93,
457 fchmod = 94,
458 fchown = 95,
459 getpriority = 96,
460 setpriority = 97,
461 profil = 98,
462 statfs = 99,
463 fstatfs = 100,
464 ioperm = 101,
465 socketcall = 102,
466 syslog = 103,
467 setitimer = 104,
468 getitimer = 105,
469 stat = 106,
470 lstat = 107,
471 fstat = 108,
472 olduname = 109,
473 iopl = 110,
474 vhangup = 111,
475 idle = 112,
476 vm86old = 113,
477 wait4 = 114,
478 swapoff = 115,
479 sysinfo = 116,
480 ipc = 117,
481 fsync = 118,
482 sigreturn = 119,
483 clone = 120,
484 setdomainname = 121,
485 uname = 122,
486 modify_ldt = 123,
487 adjtimex = 124,
488 mprotect = 125,
489 sigprocmask = 126,
490 create_module = 127,
491 init_module = 128,
492 delete_module = 129,
493 get_kernel_syms = 130,
494 quotactl = 131,
495 getpgid = 132,
496 fchdir = 133,
497 bdflush = 134,
498 sysfs = 135,
499 personality = 136,
500 afs_syscall = 137,
501 setfsuid = 138,
502 setfsgid = 139,
503 _llseek = 140,
504 getdents = 141,
505 _newselect = 142,
506 flock = 143,
507 msync = 144,
508 readv = 145,
509 writev = 146,
510 getsid = 147,
511 fdatasync = 148,
512 _sysctl = 149,
513 mlock = 150,
514 munlock = 151,
515 mlockall = 152,
516 munlockall = 153,
517 sched_setparam = 154,
518 sched_getparam = 155,
519 sched_setscheduler = 156,
520 sched_getscheduler = 157,
521 sched_yield = 158,
522 sched_get_priority_max = 159,
523 sched_get_priority_min = 160,
524 sched_rr_get_interval = 161,
525 nanosleep = 162,
526 mremap = 163,
527 setresuid = 164,
528 getresuid = 165,
529 vm86 = 166,
530 query_module = 167,
531 poll = 168,
532 nfsservctl = 169,
533 setresgid = 170,
534 getresgid = 171,
535 prctl = 172,
536 rt_sigreturn = 173,
537 rt_sigaction = 174,
538 rt_sigprocmask = 175,
539 rt_sigpending = 176,
540 rt_sigtimedwait = 177,
541 rt_sigqueueinfo = 178,
542 rt_sigsuspend = 179,
543 pread64 = 180,
544 pwrite64 = 181,
545 chown = 182,
546 getcwd = 183,
547 capget = 184,
548 capset = 185,
549 sigaltstack = 186,
550 sendfile = 187,
551 getpmsg = 188,
552 putpmsg = 189,
553 vfork = 190,
554 ugetrlimit = 191,
555 mmap2 = 192,
556 truncate64 = 193,
557 ftruncate64 = 194,
558 stat64 = 195,
559 lstat64 = 196,
560 fstat64 = 197,
561 lchown32 = 198,
562 getuid32 = 199,
563 getgid32 = 200,
564 geteuid32 = 201,
565 getegid32 = 202,
566 setreuid32 = 203,
567 setregid32 = 204,
568 getgroups32 = 205,
569 setgroups32 = 206,
570 fchown32 = 207,
571 setresuid32 = 208,
572 getresuid32 = 209,
573 setresgid32 = 210,
574 getresgid32 = 211,
575 chown32 = 212,
576 setuid32 = 213,
577 setgid32 = 214,
578 setfsuid32 = 215,
579 setfsgid32 = 216,
580 pivot_root = 217,
581 mincore = 218,
582 madvise = 219,
583 getdents64 = 220,
584 fcntl64 = 221,
585 gettid = 224,
586 readahead = 225,
587 setxattr = 226,
588 lsetxattr = 227,
589 fsetxattr = 228,
590 getxattr = 229,
591 lgetxattr = 230,
592 fgetxattr = 231,
593 listxattr = 232,
594 llistxattr = 233,
595 flistxattr = 234,
596 removexattr = 235,
597 lremovexattr = 236,
598 fremovexattr = 237,
599 tkill = 238,
600 sendfile64 = 239,
601 futex = 240,
602 sched_setaffinity = 241,
603 sched_getaffinity = 242,
604 set_thread_area = 243,
605 get_thread_area = 244,
606 io_setup = 245,
607 io_destroy = 246,
608 io_getevents = 247,
609 io_submit = 248,
610 io_cancel = 249,
611 fadvise64 = 250,
612 exit_group = 252,
613 lookup_dcookie = 253,
614 epoll_create = 254,
615 epoll_ctl = 255,
616 epoll_wait = 256,
617 remap_file_pages = 257,
618 set_tid_address = 258,
619 timer_create = 259,
620 timer_settime = 260,
621 timer_gettime = 261,
622 timer_getoverrun = 262,
623 timer_delete = 263,
624 clock_settime = 264,
625 clock_gettime = 265,
626 clock_getres = 266,
627 clock_nanosleep = 267,
628 statfs64 = 268,
629 fstatfs64 = 269,
630 tgkill = 270,
631 utimes = 271,
632 fadvise64_64 = 272,
633 vserver = 273,
634 mbind = 274,
635 get_mempolicy = 275,
636 set_mempolicy = 276,
637 mq_open = 277,
638 mq_unlink = 278,
639 mq_timedsend = 279,
640 mq_timedreceive = 280,
641 mq_notify = 281,
642 mq_getsetattr = 282,
643 kexec_load = 283,
644 waitid = 284,
645 add_key = 286,
646 request_key = 287,
647 keyctl = 288,
648 ioprio_set = 289,
649 ioprio_get = 290,
650 inotify_init = 291,
651 inotify_add_watch = 292,
652 inotify_rm_watch = 293,
653 migrate_pages = 294,
654 openat = 295,
655 mkdirat = 296,
656 mknodat = 297,
657 fchownat = 298,
658 futimesat = 299,
659 fstatat64 = 300,
660 unlinkat = 301,
661 renameat = 302,
662 linkat = 303,
663 symlinkat = 304,
664 readlinkat = 305,
665 fchmodat = 306,
666 faccessat = 307,
667 pselect6 = 308,
668 ppoll = 309,
669 unshare = 310,
670 set_robust_list = 311,
671 get_robust_list = 312,
672 splice = 313,
673 sync_file_range = 314,
674 tee = 315,
675 vmsplice = 316,
676 move_pages = 317,
677 getcpu = 318,
678 epoll_pwait = 319,
679 utimensat = 320,
680 signalfd = 321,
681 timerfd_create = 322,
682 eventfd = 323,
683 fallocate = 324,
684 timerfd_settime = 325,
685 timerfd_gettime = 326,
686 signalfd4 = 327,
687 eventfd2 = 328,
688 epoll_create1 = 329,
689 dup3 = 330,
690 pipe2 = 331,
691 inotify_init1 = 332,
692 preadv = 333,
693 pwritev = 334,
694 rt_tgsigqueueinfo = 335,
695 perf_event_open = 336,
696 recvmmsg = 337,
697 fanotify_init = 338,
698 fanotify_mark = 339,
699 prlimit64 = 340,
700 name_to_handle_at = 341,
701 open_by_handle_at = 342,
702 clock_adjtime = 343,
703 syncfs = 344,
704 sendmmsg = 345,
705 setns = 346,
706 process_vm_readv = 347,
707 process_vm_writev = 348,
708 kcmp = 349,
709 finit_module = 350,
710 sched_setattr = 351,
711 sched_getattr = 352,
712 renameat2 = 353,
713 seccomp = 354,
714 getrandom = 355,
715 memfd_create = 356,
716 bpf = 357,
717 execveat = 358,
718 socket = 359,
719 socketpair = 360,
720 bind = 361,
721 connect = 362,
722 listen = 363,
723 accept4 = 364,
724 getsockopt = 365,
725 setsockopt = 366,
726 getsockname = 367,
727 getpeername = 368,
728 sendto = 369,
729 sendmsg = 370,
730 recvfrom = 371,
731 recvmsg = 372,
732 shutdown = 373,
733 userfaultfd = 374,
734 membarrier = 375,
735 mlock2 = 376,
736 copy_file_range = 377,
737 preadv2 = 378,
738 pwritev2 = 379,
739 pkey_mprotect = 380,
740 pkey_alloc = 381,
741 pkey_free = 382,
742 statx = 383,
743 arch_prctl = 384,
744 }
745}
diff --git a/libphobos/libdruntime/core/sys/linux/unistd.d b/libphobos/libdruntime/core/sys/linux/unistd.d
index 1ef16c12689..48457467005 100644
--- a/libphobos/libdruntime/core/sys/linux/unistd.d
+++ b/libphobos/libdruntime/core/sys/linux/unistd.d
@@ -1,20 +1,16 @@
1module core.sys.linux.unistd; 1module core.sys.linux.unistd;
2 2
3public import core.sys.posix.unistd;
4
3version (linux): 5version (linux):
4extern (C): 6extern(C):
5nothrow: 7nothrow:
6@system: 8@system:
7@nogc:
8
9public import core.sys.posix.unistd;
10public import core.sys.linux.syscalls : SystemCall;
11import core.stdc.config : c_long;
12 9
13// Additional seek constants for sparse file handling 10// Additional seek constants for sparse file handling
14// from Linux's unistd.h, stdio.h, and linux/fs.h 11// from Linux's unistd.h, stdio.h, and linux/fs.h
15// (see http://man7.org/linux/man-pages/man2/lseek.2.html) 12// (see http://man7.org/linux/man-pages/man2/lseek.2.html)
16enum 13enum {
17{
18 /// Offset is relative to the next location containing data 14 /// Offset is relative to the next location containing data
19 SEEK_DATA = 3, 15 SEEK_DATA = 3,
20 /// Offset is relative to the next hole (or EOF if file is not sparse) 16 /// Offset is relative to the next hole (or EOF if file is not sparse)
@@ -26,17 +22,3 @@ char* getpass(const(char)* prompt);
26 22
27// Exit all threads in a process 23// Exit all threads in a process
28void exit_group(int status); 24void exit_group(int status);
29
30/**
31Invoke system call specified by number, passing it the remaining arguments.
32This is completely system-dependent, and not often useful.
33
34In Unix, `syscall' sets `errno' for all errors and most calls return -1
35for errors; in many systems you cannot pass arguments or get return
36values for all system calls (`pipe', `fork', and `getppid' typically
37among them).
38
39In Mach, all system calls take normal arguments and always return an
40error code (zero for success).
41*/
42c_long syscall(SystemCall number, ...) @nogc nothrow;
diff --git a/libphobos/libdruntime/core/sys/netbsd/string.d b/libphobos/libdruntime/core/sys/netbsd/string.d
index ab9ced80cf1..f1281da275b 100644
--- a/libphobos/libdruntime/core/sys/netbsd/string.d
+++ b/libphobos/libdruntime/core/sys/netbsd/string.d
@@ -17,5 +17,5 @@ nothrow:
17 17
18static if (_NETBSD_SOURCE) 18static if (_NETBSD_SOURCE)
19{ 19{
20 pure void* memmem(return const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 20 pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen);
21} 21}
diff --git a/libphobos/libdruntime/core/sys/openbsd/string.d b/libphobos/libdruntime/core/sys/openbsd/string.d
index 131e67727e8..4480c94ac37 100644
--- a/libphobos/libdruntime/core/sys/openbsd/string.d
+++ b/libphobos/libdruntime/core/sys/openbsd/string.d
@@ -18,7 +18,7 @@ nothrow:
18static if (__BSD_VISIBLE) 18static if (__BSD_VISIBLE)
19{ 19{
20 void explicit_bzero(void*, size_t); 20 void explicit_bzero(void*, size_t);
21 pure void* memmem(return const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 21 pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen);
22 void* memrchr(scope const void*, int, size_t); 22 void* memrchr(scope const void*, int, size_t);
23 size_t strlcat(char*, scope const char*, size_t); 23 size_t strlcat(char*, scope const char*, size_t);
24 size_t strlcpy(char*, scope const char*, size_t); 24 size_t strlcpy(char*, scope const char*, size_t);
diff --git a/libphobos/libdruntime/core/sys/posix/signal.d b/libphobos/libdruntime/core/sys/posix/signal.d
index 0dce8c53f31..32e51561562 100644
--- a/libphobos/libdruntime/core/sys/posix/signal.d
+++ b/libphobos/libdruntime/core/sys/posix/signal.d
@@ -513,15 +513,21 @@ else version (DragonFlyBSD)
513} 513}
514else version (Solaris) 514else version (Solaris)
515{ 515{
516 //SIGABRT (defined in core.stdc.signal)
516 enum SIGALRM = 14; 517 enum SIGALRM = 14;
517 enum SIGBUS = 10; 518 enum SIGBUS = 10;
518 enum SIGCHLD = 18; 519 enum SIGCHLD = 18;
519 enum SIGCONT = 25; 520 enum SIGCONT = 25;
521 //SIGFPE (defined in core.stdc.signal)
520 enum SIGHUP = 1; 522 enum SIGHUP = 1;
523 //SIGILL (defined in core.stdc.signal)
524 //SIGINT (defined in core.stdc.signal)
521 enum SIGKILL = 9; 525 enum SIGKILL = 9;
522 enum SIGPIPE = 13; 526 enum SIGPIPE = 13;
523 enum SIGQUIT = 3; 527 enum SIGQUIT = 3;
528 //SIGSEGV (defined in core.stdc.signal)
524 enum SIGSTOP = 23; 529 enum SIGSTOP = 23;
530 //SIGTERM (defined in core.stdc.signal)
525 enum SIGTSTP = 24; 531 enum SIGTSTP = 24;
526 enum SIGTTIN = 26; 532 enum SIGTTIN = 26;
527 enum SIGTTOU = 27; 533 enum SIGTTOU = 27;
@@ -1339,6 +1345,10 @@ else version (Solaris)
1339 uint[4] __bits; 1345 uint[4] __bits;
1340 } 1346 }
1341 1347
1348 enum SIG_BLOCK = 1;
1349 enum SIG_UNBLOCK = 2;
1350 enum SIG_SETMASK = 3;
1351
1342 struct siginfo_t 1352 struct siginfo_t
1343 { 1353 {
1344 int si_signo; 1354 int si_signo;
@@ -1427,6 +1437,18 @@ else version (Solaris)
1427 ___data __data; 1437 ___data __data;
1428 } 1438 }
1429 1439
1440 enum SI_NOINFO = 32767;
1441 enum SI_DTRACE = 2050;
1442 enum SI_RCTL = 2049;
1443 enum SI_USER = 0;
1444 enum SI_LWP = -1;
1445 enum SI_QUEUE = -2;
1446 enum SI_TIMER = -3;
1447 enum SI_ASYNCIO = -4;
1448 enum SI_MESGQ = -5;
1449
1450 enum SIGIO = SIGPOLL;
1451
1430 int kill(pid_t, int); 1452 int kill(pid_t, int);
1431 int sigaction(int, const scope sigaction_t*, sigaction_t*); 1453 int sigaction(int, const scope sigaction_t*, sigaction_t*);
1432 int sigaddset(sigset_t*, int); 1454 int sigaddset(sigset_t*, int);
@@ -2833,9 +2855,9 @@ else version (Solaris)
2833 enum SIGPROF = 29; 2855 enum SIGPROF = 29;
2834 enum SIGSYS = 12; 2856 enum SIGSYS = 12;
2835 enum SIGTRAP = 5; 2857 enum SIGTRAP = 5;
2836 enum SIGVTALRM = 31; 2858 enum SIGVTALRM = 28;
2837 enum SIGXCPU = 30; 2859 enum SIGXCPU = 30;
2838 enum SIGXFSZ = 25; 2860 enum SIGXFSZ = 31;
2839 2861
2840 enum 2862 enum
2841 { 2863 {
diff --git a/libphobos/libdruntime/core/sys/posix/string.d b/libphobos/libdruntime/core/sys/posix/string.d
index b9e1c1c88c2..79d25624e2a 100644
--- a/libphobos/libdruntime/core/sys/posix/string.d
+++ b/libphobos/libdruntime/core/sys/posix/string.d
@@ -31,11 +31,11 @@ public import core.sys.posix.locale : locale_t;
31public import core.stdc.string; 31public import core.stdc.string;
32 32
33/// Copy string until character found 33/// Copy string until character found
34void* memccpy(return void* dst, scope const void* src, int c, size_t n) pure; 34void* memccpy(return scope void* dst, scope const void* src, int c, size_t n) pure;
35/// Copy string (including terminating '\0') 35/// Copy string (including terminating '\0')
36char* stpcpy(return char* dst, scope const char* src) pure; 36char* stpcpy(return scope char* dst, scope const char* src) pure;
37/// Ditto 37/// Ditto
38char* stpncpy(return char* dst, const char* src, size_t len) pure; 38char* stpncpy(return scope char* dst, const char* src, size_t len) pure;
39/// Compare strings according to current collation 39/// Compare strings according to current collation
40int strcoll_l(scope const char* s1, scope const char* s2, locale_t locale); 40int strcoll_l(scope const char* s1, scope const char* s2, locale_t locale);
41/// 41///
@@ -47,6 +47,6 @@ size_t strnlen(scope const char* str, size_t maxlen) pure;
47/// System signal messages 47/// System signal messages
48const(char)* strsignal(int); 48const(char)* strsignal(int);
49/// Isolate sequential tokens in a null-terminated string 49/// Isolate sequential tokens in a null-terminated string
50char* strtok_r(return char* str, scope const char* sep, char** context) pure; 50char* strtok_r(return scope char* str, scope const char* sep, char** context) pure;
51/// Transform a string under locale 51/// Transform a string under locale
52size_t strxfrm_l(char* s1, scope const char* s2, size_t n, locale_t locale); 52size_t strxfrm_l(char* s1, scope const char* s2, size_t n, locale_t locale);
diff --git a/libphobos/libdruntime/core/sys/posix/sys/socket.d b/libphobos/libdruntime/core/sys/posix/sys/socket.d
index de51c6a4746..6e0cfd3ac3d 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/socket.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/socket.d
@@ -217,7 +217,7 @@ version (CRuntime_Glibc)
217 } 217 }
218 else 218 else
219 { 219 {
220 extern (D) inout(ubyte)* CMSG_DATA( return inout(cmsghdr)* cmsg ) pure nothrow @nogc { return cast(ubyte*)( cmsg + 1 ); } 220 extern (D) inout(ubyte)* CMSG_DATA( return scope inout(cmsghdr)* cmsg ) pure nothrow @nogc { return cast(ubyte*)( cmsg + 1 ); }
221 } 221 }
222 222
223 private inout(cmsghdr)* __cmsg_nxthdr(inout(msghdr)*, inout(cmsghdr)*) pure nothrow @nogc; 223 private inout(cmsghdr)* __cmsg_nxthdr(inout(msghdr)*, inout(cmsghdr)*) pure nothrow @nogc;
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/elf.d b/libphobos/libdruntime/core/sys/solaris/sys/elf.d
index 7da26317d35..7a46d520cc3 100644
--- a/libphobos/libdruntime/core/sys/solaris/sys/elf.d
+++ b/libphobos/libdruntime/core/sys/solaris/sys/elf.d
@@ -393,7 +393,7 @@ enum SHF_LINK_ORDER = 0x80;
393enum SHF_OS_NONCONFORMING = 0x100; 393enum SHF_OS_NONCONFORMING = 0x100;
394enum SHF_GROUP = 0x200; 394enum SHF_GROUP = 0x200;
395enum SHF_TLS = 0x400; 395enum SHF_TLS = 0x400;
396 396enum SHF_COMPRESSED = 0x800;
397enum SHF_MASKOS = 0x0ff00000; 397enum SHF_MASKOS = 0x0ff00000;
398 398
399enum SHF_MASKPROC = 0xf0000000; 399enum SHF_MASKPROC = 0xf0000000;
@@ -656,3 +656,6 @@ enum NT_ZONENAME = 21;
656enum NT_FDINFO = 22; 656enum NT_FDINFO = 22;
657enum NT_SPYMASTER = 23; 657enum NT_SPYMASTER = 23;
658enum NT_NUM = 23; 658enum NT_NUM = 23;
659
660enum SHF_ORDERED = 0x40000000;
661enum SHF_EXCLUDE = 0x80000000;
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/elf_386.d b/libphobos/libdruntime/core/sys/solaris/sys/elf_386.d
index 0c8198513d0..9927b64aec9 100644
--- a/libphobos/libdruntime/core/sys/solaris/sys/elf_386.d
+++ b/libphobos/libdruntime/core/sys/solaris/sys/elf_386.d
@@ -52,9 +52,6 @@ enum R_386_NUM = 39;
52 52
53enum ELF_386_MAXPGSZ = 0x10000; 53enum ELF_386_MAXPGSZ = 0x10000;
54 54
55enum SHF_ORDERED = 0x40000000;
56enum SHF_EXCLUDE = 0x80000000;
57
58enum SHN_BEFORE = 0xff00; 55enum SHN_BEFORE = 0xff00;
59enum SHN_AFTER = 0xff01; 56enum SHN_AFTER = 0xff01;
60 57
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/elf_SPARC.d b/libphobos/libdruntime/core/sys/solaris/sys/elf_SPARC.d
index 81d02347598..e43bd405b8a 100644
--- a/libphobos/libdruntime/core/sys/solaris/sys/elf_SPARC.d
+++ b/libphobos/libdruntime/core/sys/solaris/sys/elf_SPARC.d
@@ -118,9 +118,6 @@ enum ELF_SPARCV9_MAXPGSZ = 0x100000;
118 118
119enum SHT_SPARC_GOTDATA = 0x70000000; 119enum SHT_SPARC_GOTDATA = 0x70000000;
120 120
121enum SHF_ORDERED = 0x40000000;
122enum SHF_EXCLUDE = 0x80000000;
123
124enum SHN_BEFORE = 0xff00; 121enum SHN_BEFORE = 0xff00;
125enum SHN_AFTER = 0xff01; 122enum SHN_AFTER = 0xff01;
126 123
diff --git a/libphobos/libdruntime/core/sys/windows/dbghelp.d b/libphobos/libdruntime/core/sys/windows/dbghelp.d
index 9848fb99115..96698e8f0f9 100644
--- a/libphobos/libdruntime/core/sys/windows/dbghelp.d
+++ b/libphobos/libdruntime/core/sys/windows/dbghelp.d
@@ -39,7 +39,8 @@ extern(Windows)
39 alias BOOL function(HANDLE hProcess, DWORD64 Address, DWORD64 *Displacement, IMAGEHLP_SYMBOLA64 *Symbol) SymGetSymFromAddr64Func; 39 alias BOOL function(HANDLE hProcess, DWORD64 Address, DWORD64 *Displacement, IMAGEHLP_SYMBOLA64 *Symbol) SymGetSymFromAddr64Func;
40 alias DWORD function(PCSTR DecoratedName, PSTR UnDecoratedName, DWORD UndecoratedLength, DWORD Flags) UnDecorateSymbolNameFunc; 40 alias DWORD function(PCSTR DecoratedName, PSTR UnDecoratedName, DWORD UndecoratedLength, DWORD Flags) UnDecorateSymbolNameFunc;
41 alias DWORD64 function(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll) SymLoadModule64Func; 41 alias DWORD64 function(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll) SymLoadModule64Func;
42 alias BOOL function(HANDLE HProcess, PTSTR SearchPath, DWORD SearchPathLength) SymGetSearchPathFunc; 42 alias BOOL function(HANDLE hProcess, PSTR SearchPath, DWORD SearchPathLength) SymGetSearchPathFunc;
43 alias BOOL function(HANDLE hProcess, PCSTR SearchPath) SymSetSearchPathFunc;
43 alias BOOL function(HANDLE hProcess, DWORD64 Address) SymUnloadModule64Func; 44 alias BOOL function(HANDLE hProcess, DWORD64 Address) SymUnloadModule64Func;
44 alias BOOL function(HANDLE hProcess, ULONG ActionCode, ulong CallbackContext, ulong UserContext) PSYMBOL_REGISTERED_CALLBACK64; 45 alias BOOL function(HANDLE hProcess, ULONG ActionCode, ulong CallbackContext, ulong UserContext) PSYMBOL_REGISTERED_CALLBACK64;
45 alias BOOL function(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ulong UserContext) SymRegisterCallback64Func; 46 alias BOOL function(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ulong UserContext) SymRegisterCallback64Func;
@@ -61,6 +62,7 @@ struct DbgHelp
61 UnDecorateSymbolNameFunc UnDecorateSymbolName; 62 UnDecorateSymbolNameFunc UnDecorateSymbolName;
62 SymLoadModule64Func SymLoadModule64; 63 SymLoadModule64Func SymLoadModule64;
63 SymGetSearchPathFunc SymGetSearchPath; 64 SymGetSearchPathFunc SymGetSearchPath;
65 SymSetSearchPathFunc SymSetSearchPath;
64 SymUnloadModule64Func SymUnloadModule64; 66 SymUnloadModule64Func SymUnloadModule64;
65 SymRegisterCallback64Func SymRegisterCallback64; 67 SymRegisterCallback64Func SymRegisterCallback64;
66 ImagehlpApiVersionFunc ImagehlpApiVersion; 68 ImagehlpApiVersionFunc ImagehlpApiVersion;
@@ -84,6 +86,7 @@ struct DbgHelp
84 sm_inst.UnDecorateSymbolName = cast(UnDecorateSymbolNameFunc) GetProcAddress(sm_hndl,"UnDecorateSymbolName"); 86 sm_inst.UnDecorateSymbolName = cast(UnDecorateSymbolNameFunc) GetProcAddress(sm_hndl,"UnDecorateSymbolName");
85 sm_inst.SymLoadModule64 = cast(SymLoadModule64Func) GetProcAddress(sm_hndl,"SymLoadModule64"); 87 sm_inst.SymLoadModule64 = cast(SymLoadModule64Func) GetProcAddress(sm_hndl,"SymLoadModule64");
86 sm_inst.SymGetSearchPath = cast(SymGetSearchPathFunc) GetProcAddress(sm_hndl,"SymGetSearchPath"); 88 sm_inst.SymGetSearchPath = cast(SymGetSearchPathFunc) GetProcAddress(sm_hndl,"SymGetSearchPath");
89 sm_inst.SymSetSearchPath = cast(SymSetSearchPathFunc) GetProcAddress(sm_hndl,"SymSetSearchPath");
87 sm_inst.SymUnloadModule64 = cast(SymUnloadModule64Func) GetProcAddress(sm_hndl,"SymUnloadModule64"); 90 sm_inst.SymUnloadModule64 = cast(SymUnloadModule64Func) GetProcAddress(sm_hndl,"SymUnloadModule64");
88 sm_inst.SymRegisterCallback64 = cast(SymRegisterCallback64Func) GetProcAddress(sm_hndl, "SymRegisterCallback64"); 91 sm_inst.SymRegisterCallback64 = cast(SymRegisterCallback64Func) GetProcAddress(sm_hndl, "SymRegisterCallback64");
89 sm_inst.ImagehlpApiVersion = cast(ImagehlpApiVersionFunc) GetProcAddress(sm_hndl, "ImagehlpApiVersion"); 92 sm_inst.ImagehlpApiVersion = cast(ImagehlpApiVersionFunc) GetProcAddress(sm_hndl, "ImagehlpApiVersion");
@@ -91,7 +94,8 @@ struct DbgHelp
91 sm_inst.SymSetOptions && sm_inst.SymFunctionTableAccess64 && sm_inst.SymGetLineFromAddr64 && 94 sm_inst.SymSetOptions && sm_inst.SymFunctionTableAccess64 && sm_inst.SymGetLineFromAddr64 &&
92 sm_inst.SymGetModuleBase64 && sm_inst.SymGetModuleInfo64 && sm_inst.SymGetSymFromAddr64 && 95 sm_inst.SymGetModuleBase64 && sm_inst.SymGetModuleInfo64 && sm_inst.SymGetSymFromAddr64 &&
93 sm_inst.UnDecorateSymbolName && sm_inst.SymLoadModule64 && sm_inst.SymGetSearchPath && 96 sm_inst.UnDecorateSymbolName && sm_inst.SymLoadModule64 && sm_inst.SymGetSearchPath &&
94 sm_inst.SymUnloadModule64 && sm_inst.SymRegisterCallback64 && sm_inst.ImagehlpApiVersion); 97 sm_inst.SymSetSearchPath && sm_inst.SymUnloadModule64 && sm_inst.SymRegisterCallback64 &&
98 sm_inst.ImagehlpApiVersion);
95 99
96 return &sm_inst; 100 return &sm_inst;
97 } 101 }
diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d
index b7dde9387af..fe4d24fafce 100644
--- a/libphobos/libdruntime/core/thread/osthread.d
+++ b/libphobos/libdruntime/core/thread/osthread.d
@@ -719,7 +719,7 @@ class Thread : ThreadBase
719 // the effective maximum. 719 // the effective maximum.
720 720
721 // maxupri 721 // maxupri
722 result.PRIORITY_MIN = -clinfo[0]; 722 result.PRIORITY_MIN = -cast(int)(clinfo[0]);
723 // by definition 723 // by definition
724 result.PRIORITY_DEFAULT = 0; 724 result.PRIORITY_DEFAULT = 0;
725 } 725 }
@@ -2196,8 +2196,7 @@ extern (C) void thread_init() @nogc
2196 status = sem_init( &suspendCount, 0, 0 ); 2196 status = sem_init( &suspendCount, 0, 0 );
2197 assert( status == 0 ); 2197 assert( status == 0 );
2198 } 2198 }
2199 if (typeid(Thread).initializer.ptr) 2199 _mainThreadStore[] = __traits(initSymbol, Thread)[];
2200 _mainThreadStore[] = typeid(Thread).initializer[];
2201 Thread.sm_main = attachThread((cast(Thread)_mainThreadStore.ptr).__ctor()); 2200 Thread.sm_main = attachThread((cast(Thread)_mainThreadStore.ptr).__ctor());
2202} 2201}
2203 2202
diff --git a/libphobos/libdruntime/core/thread/threadbase.d b/libphobos/libdruntime/core/thread/threadbase.d
index 4592bf1d975..9cee4d8d77d 100644
--- a/libphobos/libdruntime/core/thread/threadbase.d
+++ b/libphobos/libdruntime/core/thread/threadbase.d
@@ -771,10 +771,7 @@ package void thread_term_tpl(ThreadT, MainThreadStore)(ref MainThreadStore _main
771 // destruct manually as object.destroy is not @nogc 771 // destruct manually as object.destroy is not @nogc
772 (cast(ThreadT) cast(void*) ThreadBase.sm_main).__dtor(); 772 (cast(ThreadT) cast(void*) ThreadBase.sm_main).__dtor();
773 _d_monitordelete_nogc(ThreadBase.sm_main); 773 _d_monitordelete_nogc(ThreadBase.sm_main);
774 if (typeid(ThreadT).initializer.ptr) 774 _mainThreadStore[] = __traits(initSymbol, ThreadT)[];
775 _mainThreadStore[] = typeid(ThreadT).initializer[];
776 else
777 (cast(ubyte[])_mainThreadStore)[] = 0;
778 ThreadBase.sm_main = null; 775 ThreadBase.sm_main = null;
779 776
780 assert(ThreadBase.sm_tbeg && ThreadBase.sm_tlen == 1); 777 assert(ThreadBase.sm_tbeg && ThreadBase.sm_tlen == 1);
diff --git a/libphobos/libdruntime/object.d b/libphobos/libdruntime/object.d
index a079e0e73e9..fee19ae65f0 100644
--- a/libphobos/libdruntime/object.d
+++ b/libphobos/libdruntime/object.d
@@ -3485,7 +3485,7 @@ enum immutable(void)* rtinfoHasPointers = cast(void*)1;
3485 3485
3486// Helper functions 3486// Helper functions
3487 3487
3488private inout(TypeInfo) getElement(return inout TypeInfo value) @trusted pure nothrow 3488private inout(TypeInfo) getElement(return scope inout TypeInfo value) @trusted pure nothrow
3489{ 3489{
3490 TypeInfo element = cast() value; 3490 TypeInfo element = cast() value;
3491 for (;;) 3491 for (;;)
@@ -4215,8 +4215,8 @@ void destroy(bool initialize = true, T)(T obj) if (is(T == class))
4215 4215
4216 static if (initialize) 4216 static if (initialize)
4217 { 4217 {
4218 enum classSize = __traits(classInstanceSize, T); 4218 const initializer = __traits(initSymbol, T);
4219 (cast(void*)obj)[0 .. classSize] = typeid(T).initializer[]; 4219 (cast(void*)obj)[0 .. initializer.length] = initializer[];
4220 } 4220 }
4221 } 4221 }
4222 else 4222 else
@@ -4651,6 +4651,8 @@ public import core.internal.array.construction : _d_arrayctor;
4651public import core.internal.array.construction : _d_arraysetctor; 4651public import core.internal.array.construction : _d_arraysetctor;
4652public import core.internal.array.capacity: _d_arraysetlengthTImpl; 4652public import core.internal.array.capacity: _d_arraysetlengthTImpl;
4653 4653
4654public import core.lifetime : _d_delstruct;
4655
4654public import core.internal.dassert: _d_assert_fail; 4656public import core.internal.dassert: _d_assert_fail;
4655 4657
4656public import core.internal.destruction: __ArrayDtor; 4658public import core.internal.destruction: __ArrayDtor;
diff --git a/libphobos/libdruntime/rt/aaA.d b/libphobos/libdruntime/rt/aaA.d
index 6ff93f76da4..0c38622a879 100644
--- a/libphobos/libdruntime/rt/aaA.d
+++ b/libphobos/libdruntime/rt/aaA.d
@@ -287,7 +287,7 @@ TypeInfo_Struct fakeEntryTI(ref Impl aa, const TypeInfo keyti, const TypeInfo va
287 void* p = GC.malloc(sizeti + (2 + rtisize) * (void*).sizeof); 287 void* p = GC.malloc(sizeti + (2 + rtisize) * (void*).sizeof);
288 import core.stdc.string : memcpy; 288 import core.stdc.string : memcpy;
289 289
290 memcpy(p, typeid(TypeInfo_Struct).initializer().ptr, sizeti); 290 memcpy(p, __traits(initSymbol, TypeInfo_Struct).ptr, sizeti);
291 291
292 auto ti = cast(TypeInfo_Struct) p; 292 auto ti = cast(TypeInfo_Struct) p;
293 auto extra = cast(TypeInfo*)(p + sizeti); 293 auto extra = cast(TypeInfo*)(p + sizeti);
@@ -853,7 +853,7 @@ struct Range
853 853
854extern (C) pure nothrow @nogc @safe 854extern (C) pure nothrow @nogc @safe
855{ 855{
856 Range _aaRange(return AA aa) 856 Range _aaRange(return scope AA aa)
857 { 857 {
858 if (!aa) 858 if (!aa)
859 return Range(); 859 return Range();
diff --git a/libphobos/libdruntime/rt/cast_.d b/libphobos/libdruntime/rt/cast_.d
index dcb4438c700..1604510b427 100644
--- a/libphobos/libdruntime/rt/cast_.d
+++ b/libphobos/libdruntime/rt/cast_.d
@@ -36,7 +36,7 @@ extern (D) private bool areClassInfosEqual(scope const ClassInfo a, scope const
36 * If it is null, return null. 36 * If it is null, return null.
37 * Else, undefined crash 37 * Else, undefined crash
38 */ 38 */
39Object _d_toObject(return void* p) 39Object _d_toObject(return scope void* p)
40{ 40{
41 if (!p) 41 if (!p)
42 return null; 42 return null;
diff --git a/libphobos/libdruntime/rt/config.d b/libphobos/libdruntime/rt/config.d
index f7682f31b63..a6605f4d603 100644
--- a/libphobos/libdruntime/rt/config.d
+++ b/libphobos/libdruntime/rt/config.d
@@ -101,6 +101,9 @@ string rt_cmdlineOption(string opt, scope rt_configCallBack dg) @nogc nothrow
101 { 101 {
102 foreach (a; rt_args) 102 foreach (a; rt_args)
103 { 103 {
104 if (a == "--")
105 break;
106
104 if (a.length >= opt.length + 7 && a[0..6] == "--DRT-" && 107 if (a.length >= opt.length + 7 && a[0..6] == "--DRT-" &&
105 a[6 .. 6 + opt.length] == opt && a[6 + opt.length] == '=') 108 a[6 .. 6 + opt.length] == opt && a[6 + opt.length] == '=')
106 { 109 {
diff --git a/libphobos/libdruntime/rt/lifetime.d b/libphobos/libdruntime/rt/lifetime.d
index f1a9d873860..1f7a81de80f 100644
--- a/libphobos/libdruntime/rt/lifetime.d
+++ b/libphobos/libdruntime/rt/lifetime.d
@@ -181,7 +181,7 @@ extern (C) void _d_delstruct(void** p, TypeInfo_Struct inf) @weak
181} 181}
182 182
183// strip const/immutable/shared/inout from type info 183// strip const/immutable/shared/inout from type info
184inout(TypeInfo) unqualify(return inout(TypeInfo) cti) pure nothrow @nogc 184inout(TypeInfo) unqualify(return scope inout(TypeInfo) cti) pure nothrow @nogc
185{ 185{
186 TypeInfo ti = cast() cti; 186 TypeInfo ti = cast() cti;
187 while (ti) 187 while (ti)
@@ -381,7 +381,7 @@ size_t __arrayAllocLength(ref BlkInfo info, const TypeInfo tinext) pure nothrow
381/** 381/**
382 get the start of the array for the given block 382 get the start of the array for the given block
383 */ 383 */
384void *__arrayStart(return BlkInfo info) nothrow pure 384void *__arrayStart(return scope BlkInfo info) nothrow pure
385{ 385{
386 return info.base + ((info.size & BIGLENGTHMASK) ? LARGEPREFIX : 0); 386 return info.base + ((info.size & BIGLENGTHMASK) ? LARGEPREFIX : 0);
387} 387}
diff --git a/libphobos/libdruntime/rt/monitor_.d b/libphobos/libdruntime/rt/monitor_.d
index 6bfce635c72..763f4392822 100644
--- a/libphobos/libdruntime/rt/monitor_.d
+++ b/libphobos/libdruntime/rt/monitor_.d
@@ -264,7 +264,7 @@ struct Monitor
264 264
265private: 265private:
266 266
267@property ref shared(Monitor*) monitor(return Object h) pure nothrow @nogc 267@property ref shared(Monitor*) monitor(return scope Object h) pure nothrow @nogc
268{ 268{
269 return *cast(shared Monitor**)&h.__monitor; 269 return *cast(shared Monitor**)&h.__monitor;
270} 270}
diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE
index 29bcf33c01f..68fefcb1ae4 100644
--- a/libphobos/src/MERGE
+++ b/libphobos/src/MERGE
@@ -1,4 +1,4 @@
1574bf883b790340fb753d6542ec48a3ba3e6cb82 112329adb67fb43891d6e4e543e7257bc34db0aa7
2 2
3The first line of this file holds the git revision number of the last 3The first line of this file holds the git revision number of the last
4merge done from the dlang/phobos repository. 4merge done from the dlang/phobos repository.
diff --git a/libphobos/src/std/algorithm/iteration.d b/libphobos/src/std/algorithm/iteration.d
index 9e728e4622f..af665c41197 100644
--- a/libphobos/src/std/algorithm/iteration.d
+++ b/libphobos/src/std/algorithm/iteration.d
@@ -3595,7 +3595,6 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR)
3595 assert(res.equal("cba")); 3595 assert(res.equal("cba"));
3596} 3596}
3597 3597
3598
3599/// Ditto 3598/// Ditto
3600auto joiner(RoR)(RoR r) 3599auto joiner(RoR)(RoR r)
3601if (isInputRange!RoR && isInputRange!(ElementType!RoR)) 3600if (isInputRange!RoR && isInputRange!(ElementType!RoR))
@@ -3621,14 +3620,32 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR))
3621 _currentBack = typeof(_currentBack).init; 3620 _currentBack = typeof(_currentBack).init;
3622 } 3621 }
3623 3622
3623 void replaceCurrent(typeof(_current) current) @trusted
3624 {
3625 import core.lifetime : move;
3626
3627 current.move(_current);
3628 }
3629
3630 static if (isBidirectional)
3631 {
3632 void replaceCurrentBack(typeof(_currentBack) currentBack) @trusted
3633 {
3634 import core.lifetime : move;
3635
3636 currentBack.move(_currentBack);
3637 }
3638 }
3639
3624 public: 3640 public:
3625 this(RoR r) 3641 this(RoR r)
3626 { 3642 {
3627 _items = r; 3643 _items = r;
3644 // field _current must be initialized in constructor, because it is nested struct
3645 _current = typeof(_current).init;
3628 3646
3629 static if (isBidirectional && hasNested!Result) 3647 static if (isBidirectional && hasNested!Result)
3630 _currentBack = typeof(_currentBack).init; 3648 _currentBack = typeof(_currentBack).init;
3631 // field _current must be initialized in constructor, because it is nested struct
3632 mixin(popFrontEmptyElements); 3649 mixin(popFrontEmptyElements);
3633 static if (isBidirectional) 3650 static if (isBidirectional)
3634 mixin(popBackEmptyElements); 3651 mixin(popBackEmptyElements);
@@ -3673,13 +3690,13 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR))
3673 // consumed when a .save'd copy of ourselves is iterated over. So 3690 // consumed when a .save'd copy of ourselves is iterated over. So
3674 // we need to .save each subrange we traverse. 3691 // we need to .save each subrange we traverse.
3675 static if (isForwardRange!RoR && isForwardRange!(ElementType!RoR)) 3692 static if (isForwardRange!RoR && isForwardRange!(ElementType!RoR))
3676 _current = _items.front.save; 3693 replaceCurrent(_items.front.save);
3677 else 3694 else
3678 _current = _items.front; 3695 replaceCurrent(_items.front);
3679 } 3696 }
3680 else 3697 else
3681 { 3698 {
3682 _current = typeof(_current).init; 3699 replaceCurrent(typeof(_current).init);
3683 } 3700 }
3684 }; 3701 };
3685 3702
@@ -3696,9 +3713,9 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR))
3696 static if (isBidirectional) 3713 static if (isBidirectional)
3697 { 3714 {
3698 static if (is(typeof(null) : typeof(_currentBack))) 3715 static if (is(typeof(null) : typeof(_currentBack)))
3699 r._currentBack = _currentBack is null ? null : _currentBack.save; 3716 r.replaceCurrentBack(_currentBack is null ? null : _currentBack.save);
3700 else 3717 else
3701 r._currentBack = _currentBack.save; 3718 r.replaceCurrentBack(_currentBack.save);
3702 r.reachedFinalElement = reachedFinalElement; 3719 r.reachedFinalElement = reachedFinalElement;
3703 } 3720 }
3704 return r; 3721 return r;
@@ -3784,22 +3801,22 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR))
3784 static if (isForwardRange!RoR && isForwardRange!(ElementType!RoR)) 3801 static if (isForwardRange!RoR && isForwardRange!(ElementType!RoR))
3785 { 3802 {
3786 if (reachedFinalElement) 3803 if (reachedFinalElement)
3787 _current = _items.back.save; 3804 replaceCurrent(_items.back.save);
3788 else 3805 else
3789 _currentBack = _items.back.save; 3806 replaceCurrentBack(_items.back.save);
3790 } 3807 }
3791 else 3808 else
3792 { 3809 {
3793 if (reachedFinalElement) 3810 if (reachedFinalElement)
3794 _current = _items.back; 3811 replaceCurrent(_items.back);
3795 else 3812 else
3796 _currentBack = _items.back; 3813 replaceCurrentBack(_items.back);
3797 } 3814 }
3798 } 3815 }
3799 else 3816 else
3800 { 3817 {
3801 _current = typeof(_current).init; 3818 replaceCurrent(typeof(_current).init);
3802 _currentBack = typeof(_currentBack).init; 3819 replaceCurrentBack(typeof(_currentBack).init);
3803 } 3820 }
3804 }; 3821 };
3805 3822
@@ -4232,6 +4249,15 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR))
4232 assert([[0]].joiner.save.back == 0); 4249 assert([[0]].joiner.save.back == 0);
4233} 4250}
4234 4251
4252// https://issues.dlang.org/show_bug.cgi?id=22561
4253@safe pure unittest
4254{
4255 import std.range : only;
4256
4257 static immutable struct S { int[] array; }
4258 assert([only(S(null))].joiner.front == S(null));
4259}
4260
4235/++ 4261/++
4236Implements the homonym function (also known as `accumulate`, $(D 4262Implements the homonym function (also known as `accumulate`, $(D
4237compress), `inject`, or `foldl`) present in various programming 4263compress), `inject`, or `foldl`) present in various programming
diff --git a/libphobos/src/std/algorithm/mutation.d b/libphobos/src/std/algorithm/mutation.d
index 07cbb9b9823..22b7b98c229 100644
--- a/libphobos/src/std/algorithm/mutation.d
+++ b/libphobos/src/std/algorithm/mutation.d
@@ -886,31 +886,13 @@ if (isInputRange!Range && hasLvalueElements!Range && hasAssignableElements!Range
886 static if (hasElaborateAssign!T) 886 static if (hasElaborateAssign!T)
887 { 887 {
888 import std.algorithm.internal : addressOf; 888 import std.algorithm.internal : addressOf;
889 //Elaborate opAssign. Must go the memcpy road. 889 //Elaborate opAssign. Must go the memcpy/memset road.
890 //We avoid calling emplace here, because our goal is to initialize to
891 //the static state of T.init,
892 //So we want to avoid any un-necassarilly CC'ing of T.init
893 static if (!__traits(isZeroInit, T)) 890 static if (!__traits(isZeroInit, T))
894 { 891 {
895 auto p = typeid(T).initializer();
896 for ( ; !range.empty ; range.popFront() ) 892 for ( ; !range.empty ; range.popFront() )
897 { 893 {
898 static if (__traits(isStaticArray, T)) 894 import core.internal.lifetime : emplaceInitializer;
899 { 895 emplaceInitializer(range.front);
900 // static array initializer only contains initialization
901 // for one element of the static array.
902 auto elemp = cast(void *) addressOf(range.front);
903 auto endp = elemp + T.sizeof;
904 while (elemp < endp)
905 {
906 memcpy(elemp, p.ptr, p.length);
907 elemp += p.length;
908 }
909 }
910 else
911 {
912 memcpy(addressOf(range.front), p.ptr, T.sizeof);
913 }
914 } 896 }
915 } 897 }
916 else 898 else
@@ -1456,10 +1438,7 @@ private void moveEmplaceImpl(T)(ref scope T target, ref return scope T source)
1456 static if (__traits(isZeroInit, T)) 1438 static if (__traits(isZeroInit, T))
1457 () @trusted { memset(&source, 0, sz); }(); 1439 () @trusted { memset(&source, 0, sz); }();
1458 else 1440 else
1459 { 1441 () @trusted { memcpy(&source, __traits(initSymbol, T).ptr, sz); }();
1460 auto init = typeid(T).initializer();
1461 () @trusted { memcpy(&source, init.ptr, sz); }();
1462 }
1463 } 1442 }
1464 } 1443 }
1465 else static if (isStaticArray!T) 1444 else static if (isStaticArray!T)
diff --git a/libphobos/src/std/algorithm/sorting.d b/libphobos/src/std/algorithm/sorting.d
index f2877ccbdf4..ee68b234b15 100644
--- a/libphobos/src/std/algorithm/sorting.d
+++ b/libphobos/src/std/algorithm/sorting.d
@@ -3121,14 +3121,14 @@ if (isRandomAccessRange!R && hasLength!R && hasSwappableElements!R &&
3121 else 3121 else
3122 static assert(false, "`transform` returns an unsortable qualified type: " ~ TB.stringof); 3122 static assert(false, "`transform` returns an unsortable qualified type: " ~ TB.stringof);
3123 3123
3124 static trustedMalloc(size_t len) @trusted 3124 static trustedMalloc()(size_t len) @trusted
3125 { 3125 {
3126 import core.checkedint : mulu; 3126 import core.checkedint : mulu;
3127 import core.stdc.stdlib : malloc; 3127 import core.memory : pureMalloc;
3128 bool overflow; 3128 bool overflow;
3129 const nbytes = mulu(len, T.sizeof, overflow); 3129 const nbytes = mulu(len, T.sizeof, overflow);
3130 if (overflow) assert(false, "multiplication overflowed"); 3130 if (overflow) assert(false, "multiplication overflowed");
3131 T[] result = (cast(T*) malloc(nbytes))[0 .. len]; 3131 T[] result = (cast(T*) pureMalloc(nbytes))[0 .. len];
3132 static if (hasIndirections!T) 3132 static if (hasIndirections!T)
3133 { 3133 {
3134 import core.memory : GC; 3134 import core.memory : GC;
@@ -3145,15 +3145,15 @@ if (isRandomAccessRange!R && hasLength!R && hasSwappableElements!R &&
3145 { 3145 {
3146 foreach (i; 0 .. length) collectException(destroy(xform1[i])); 3146 foreach (i; 0 .. length) collectException(destroy(xform1[i]));
3147 } 3147 }
3148 static void trustedFree(T[] p) @trusted 3148 static void trustedFree()(T[] p) @trusted
3149 { 3149 {
3150 import core.stdc.stdlib : free; 3150 import core.memory : pureFree;
3151 static if (hasIndirections!T) 3151 static if (hasIndirections!T)
3152 { 3152 {
3153 import core.memory : GC; 3153 import core.memory : GC;
3154 GC.removeRange(p.ptr); 3154 GC.removeRange(p.ptr);
3155 } 3155 }
3156 free(p.ptr); 3156 pureFree(p.ptr);
3157 } 3157 }
3158 trustedFree(xform1); 3158 trustedFree(xform1);
3159 } 3159 }
@@ -3186,7 +3186,7 @@ if (isRandomAccessRange!R && hasLength!R && hasSwappableElements!R)
3186} 3186}
3187 3187
3188/// 3188///
3189@safe unittest 3189@safe pure unittest
3190{ 3190{
3191 import std.algorithm.iteration : map; 3191 import std.algorithm.iteration : map;
3192 import std.numeric : entropy; 3192 import std.numeric : entropy;
@@ -3207,7 +3207,7 @@ if (isRandomAccessRange!R && hasLength!R && hasSwappableElements!R)
3207 assert(isSorted!("a > b")(map!(entropy)(arr))); 3207 assert(isSorted!("a > b")(map!(entropy)(arr)));
3208} 3208}
3209 3209
3210@safe unittest 3210@safe pure unittest
3211{ 3211{
3212 import std.algorithm.iteration : map; 3212 import std.algorithm.iteration : map;
3213 import std.numeric : entropy; 3213 import std.numeric : entropy;
@@ -3228,7 +3228,7 @@ if (isRandomAccessRange!R && hasLength!R && hasSwappableElements!R)
3228 assert(isSorted!("a < b")(map!(entropy)(arr))); 3228 assert(isSorted!("a < b")(map!(entropy)(arr)));
3229} 3229}
3230 3230
3231@safe unittest 3231@safe pure unittest
3232{ 3232{
3233 // binary transform function 3233 // binary transform function
3234 string[] strings = [ "one", "two", "three" ]; 3234 string[] strings = [ "one", "two", "three" ];
@@ -3237,7 +3237,7 @@ if (isRandomAccessRange!R && hasLength!R && hasSwappableElements!R)
3237} 3237}
3238 3238
3239// https://issues.dlang.org/show_bug.cgi?id=4909 3239// https://issues.dlang.org/show_bug.cgi?id=4909
3240@safe unittest 3240@safe pure unittest
3241{ 3241{
3242 import std.typecons : Tuple; 3242 import std.typecons : Tuple;
3243 Tuple!(char)[] chars; 3243 Tuple!(char)[] chars;
@@ -3245,7 +3245,7 @@ if (isRandomAccessRange!R && hasLength!R && hasSwappableElements!R)
3245} 3245}
3246 3246
3247// https://issues.dlang.org/show_bug.cgi?id=5924 3247// https://issues.dlang.org/show_bug.cgi?id=5924
3248@safe unittest 3248@safe pure unittest
3249{ 3249{
3250 import std.typecons : Tuple; 3250 import std.typecons : Tuple;
3251 Tuple!(char)[] chars; 3251 Tuple!(char)[] chars;
@@ -3253,7 +3253,7 @@ if (isRandomAccessRange!R && hasLength!R && hasSwappableElements!R)
3253} 3253}
3254 3254
3255// https://issues.dlang.org/show_bug.cgi?id=13965 3255// https://issues.dlang.org/show_bug.cgi?id=13965
3256@safe unittest 3256@safe pure unittest
3257{ 3257{
3258 import std.typecons : Tuple; 3258 import std.typecons : Tuple;
3259 Tuple!(char)[] chars; 3259 Tuple!(char)[] chars;
@@ -3261,7 +3261,7 @@ if (isRandomAccessRange!R && hasLength!R && hasSwappableElements!R)
3261} 3261}
3262 3262
3263// https://issues.dlang.org/show_bug.cgi?id=13965 3263// https://issues.dlang.org/show_bug.cgi?id=13965
3264@safe unittest 3264@safe pure unittest
3265{ 3265{
3266 import std.algorithm.iteration : map; 3266 import std.algorithm.iteration : map;
3267 import std.numeric : entropy; 3267 import std.numeric : entropy;
diff --git a/libphobos/src/std/concurrency.d b/libphobos/src/std/concurrency.d
index a9830af61a2..fb383ae3f2e 100644
--- a/libphobos/src/std/concurrency.d
+++ b/libphobos/src/std/concurrency.d
@@ -2149,14 +2149,16 @@ private
2149 2149
2150 if (msg.convertsTo!(Args)) 2150 if (msg.convertsTo!(Args))
2151 { 2151 {
2152 static if (is(ReturnType!(t) == bool)) 2152 alias RT = ReturnType!(t);
2153 static if (is(RT == bool))
2153 { 2154 {
2154 return msg.map(op); 2155 return msg.map(op);
2155 } 2156 }
2156 else 2157 else
2157 { 2158 {
2158 msg.map(op); 2159 msg.map(op);
2159 return true; 2160 static if (!is(immutable RT == immutable noreturn))
2161 return true;
2160 } 2162 }
2161 } 2163 }
2162 } 2164 }
@@ -2745,7 +2747,8 @@ auto ref initOnce(alias var)(lazy typeof(var) init, shared Mutex mutex)
2745 if (!atomicLoad!(MemoryOrder.raw)(flag)) 2747 if (!atomicLoad!(MemoryOrder.raw)(flag))
2746 { 2748 {
2747 var = init; 2749 var = init;
2748 atomicStore!(MemoryOrder.rel)(flag, true); 2750 static if (!is(immutable typeof(var) == immutable noreturn))
2751 atomicStore!(MemoryOrder.rel)(flag, true);
2749 } 2752 }
2750 } 2753 }
2751 } 2754 }
@@ -2827,3 +2830,26 @@ auto ref initOnce(alias var)(lazy typeof(var) init, Mutex mutex)
2827 immutable expected = Aggregate(42, [1, 2, 3, 4, 5]); 2830 immutable expected = Aggregate(42, [1, 2, 3, 4, 5]);
2828 assert(result1 == expected); 2831 assert(result1 == expected);
2829} 2832}
2833
2834// Noreturn support
2835@system unittest
2836{
2837 static noreturn foo(int) { throw new Exception(""); }
2838
2839 if (false) spawn(&foo, 1);
2840 if (false) spawnLinked(&foo, 1);
2841
2842 if (false) receive(&foo);
2843 if (false) receiveTimeout(Duration.init, &foo);
2844
2845 // Wrapped in __traits(compiles) to skip codegen which crashes dmd's backend
2846 static assert(__traits(compiles, receiveOnly!noreturn() ));
2847 static assert(__traits(compiles, send(Tid.init, noreturn.init) ));
2848 static assert(__traits(compiles, prioritySend(Tid.init, noreturn.init) ));
2849 static assert(__traits(compiles, yield(noreturn.init) ));
2850
2851 static assert(__traits(compiles, {
2852 __gshared noreturn n;
2853 initOnce!n(noreturn.init);
2854 }));
2855}
diff --git a/libphobos/src/std/container/dlist.d b/libphobos/src/std/container/dlist.d
index cc3e2e85dbc..32d56ecc733 100644
--- a/libphobos/src/std/container/dlist.d
+++ b/libphobos/src/std/container/dlist.d
@@ -196,6 +196,12 @@ struct DList(T)
196 196
197 T _payload = T.init; 197 T _payload = T.init;
198 198
199 this (BaseNode _base, T _payload)
200 {
201 this._base = _base;
202 this._payload = _payload;
203 }
204
199 inout(BaseNode)* asBaseNode() inout @trusted 205 inout(BaseNode)* asBaseNode() inout @trusted
200 { 206 {
201 return &_base; 207 return &_base;
diff --git a/libphobos/src/std/container/rbtree.d b/libphobos/src/std/container/rbtree.d
index f8e70fc0882..0b0a0b2f59f 100644
--- a/libphobos/src/std/container/rbtree.d
+++ b/libphobos/src/std/container/rbtree.d
@@ -887,7 +887,7 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
887 * Returns: 887 * Returns:
888 * true if node was added 888 * true if node was added
889 */ 889 */
890 private bool _add(return Elem n) 890 private bool _add(return scope Elem n)
891 { 891 {
892 Node result; 892 Node result;
893 static if (!allowDuplicates) 893 static if (!allowDuplicates)
diff --git a/libphobos/src/std/datetime/interval.d b/libphobos/src/std/datetime/interval.d
index 741088a72dc..ba2a21056c7 100644
--- a/libphobos/src/std/datetime/interval.d
+++ b/libphobos/src/std/datetime/interval.d
@@ -8349,7 +8349,7 @@ private:
8349 } 8349 }
8350 8350
8351 { 8351 {
8352 SysTime stFunc(scope const SysTime st) { return cast(SysTime) st; } 8352 SysTime stFunc(scope const SysTime st) { return SysTime.init; }
8353 auto interval = Interval!SysTime(SysTime(DateTime(2010, 7, 4, 12, 1, 7)), 8353 auto interval = Interval!SysTime(SysTime(DateTime(2010, 7, 4, 12, 1, 7)),
8354 SysTime(DateTime(2012, 1, 7, 14, 0, 0))); 8354 SysTime(DateTime(2012, 1, 7, 14, 0, 0)));
8355 auto ir = IntervalRange!(SysTime, Direction.fwd)(interval, &stFunc); 8355 auto ir = IntervalRange!(SysTime, Direction.fwd)(interval, &stFunc);
@@ -8794,7 +8794,7 @@ private:
8794 } 8794 }
8795 8795
8796 { 8796 {
8797 SysTime stFunc(scope const SysTime st) { return cast(SysTime) st; } 8797 SysTime stFunc(scope const SysTime st) { return SysTime.init; }
8798 auto posInfInterval = PosInfInterval!SysTime(SysTime(DateTime(2010, 7, 4, 12, 1, 7))); 8798 auto posInfInterval = PosInfInterval!SysTime(SysTime(DateTime(2010, 7, 4, 12, 1, 7)));
8799 auto ir = PosInfIntervalRange!SysTime(posInfInterval, &stFunc); 8799 auto ir = PosInfIntervalRange!SysTime(posInfInterval, &stFunc);
8800 } 8800 }
@@ -9076,7 +9076,7 @@ private:
9076 } 9076 }
9077 9077
9078 { 9078 {
9079 SysTime stFunc(scope const SysTime st) { return cast(SysTime)(st); } 9079 SysTime stFunc(scope const SysTime st) { return SysTime.init; }
9080 auto negInfInterval = NegInfInterval!SysTime(SysTime(DateTime(2012, 1, 7, 14, 0, 0))); 9080 auto negInfInterval = NegInfInterval!SysTime(SysTime(DateTime(2012, 1, 7, 14, 0, 0)));
9081 auto ir = NegInfIntervalRange!(SysTime)(negInfInterval, &stFunc); 9081 auto ir = NegInfIntervalRange!(SysTime)(negInfInterval, &stFunc);
9082 } 9082 }
diff --git a/libphobos/src/std/datetime/systime.d b/libphobos/src/std/datetime/systime.d
index 4da1281f98a..9b2a8443fdd 100644
--- a/libphobos/src/std/datetime/systime.d
+++ b/libphobos/src/std/datetime/systime.d
@@ -503,7 +503,7 @@ public:
503 given $(REF DateTime,std,datetime,date) is assumed to 503 given $(REF DateTime,std,datetime,date) is assumed to
504 be in the given time zone. 504 be in the given time zone.
505 +/ 505 +/
506 this(DateTime dateTime, immutable TimeZone tz = null) @safe nothrow 506 this(DateTime dateTime, return scope immutable TimeZone tz = null) return scope @safe nothrow
507 { 507 {
508 try 508 try
509 this(dateTime, Duration.zero, tz); 509 this(dateTime, Duration.zero, tz);
@@ -554,7 +554,7 @@ public:
554 $(REF DateTimeException,std,datetime,date) if `fracSecs` is negative or if it's 554 $(REF DateTimeException,std,datetime,date) if `fracSecs` is negative or if it's
555 greater than or equal to one second. 555 greater than or equal to one second.
556 +/ 556 +/
557 this(DateTime dateTime, Duration fracSecs, immutable TimeZone tz = null) @safe 557 this(DateTime dateTime, Duration fracSecs, return scope immutable TimeZone tz = null) return scope @safe
558 { 558 {
559 enforce(fracSecs >= Duration.zero, new DateTimeException("A SysTime cannot have negative fractional seconds.")); 559 enforce(fracSecs >= Duration.zero, new DateTimeException("A SysTime cannot have negative fractional seconds."));
560 enforce(fracSecs < seconds(1), new DateTimeException("Fractional seconds must be less than one second.")); 560 enforce(fracSecs < seconds(1), new DateTimeException("Fractional seconds must be less than one second."));
@@ -611,7 +611,7 @@ public:
611 given $(REF Date,std,datetime,date) is assumed to be in the 611 given $(REF Date,std,datetime,date) is assumed to be in the
612 given time zone. 612 given time zone.
613 +/ 613 +/
614 this(Date date, immutable TimeZone tz = null) @safe nothrow 614 this(Date date, return scope immutable TimeZone tz = null) return scope @safe nothrow
615 { 615 {
616 _timezone = tz is null ? LocalTime() : tz; 616 _timezone = tz is null ? LocalTime() : tz;
617 617
@@ -664,7 +664,7 @@ public:
664 $(LREF SysTime). If null, 664 $(LREF SysTime). If null,
665 $(REF LocalTime,std,datetime,timezone) will be used. 665 $(REF LocalTime,std,datetime,timezone) will be used.
666 +/ 666 +/
667 this(long stdTime, immutable TimeZone tz = null) @safe pure nothrow 667 this(long stdTime, return scope immutable TimeZone tz = null) return scope @safe pure nothrow
668 { 668 {
669 _stdTime = stdTime; 669 _stdTime = stdTime;
670 _timezone = tz is null ? LocalTime() : tz; 670 _timezone = tz is null ? LocalTime() : tz;
@@ -693,7 +693,7 @@ public:
693 693
694 Returns: The `this` of this `SysTime`. 694 Returns: The `this` of this `SysTime`.
695 +/ 695 +/
696 ref SysTime opAssign()(auto ref const(SysTime) rhs) return @safe pure nothrow scope 696 ref SysTime opAssign()(auto ref const(SysTime) rhs) return scope @safe pure nothrow
697 { 697 {
698 _stdTime = rhs._stdTime; 698 _stdTime = rhs._stdTime;
699 _timezone = rhs._timezone; 699 _timezone = rhs._timezone;
@@ -710,6 +710,7 @@ public:
710 st = other; 710 st = other;
711 assert(st == other); 711 assert(st == other);
712 712
713 version (none) // https://issues.dlang.org/show_bug.cgi?id=21175
713 static void testScope(scope ref SysTime left, const scope SysTime right) @safe 714 static void testScope(scope ref SysTime left, const scope SysTime right) @safe
714 { 715 {
715 left = right; 716 left = right;
@@ -2184,7 +2185,7 @@ public:
2184 hours - adjust the time to this $(LREF SysTime)'s time zone before 2185 hours - adjust the time to this $(LREF SysTime)'s time zone before
2185 returning. 2186 returning.
2186 +/ 2187 +/
2187 @property immutable(TimeZone) timezone() @safe const pure nothrow scope 2188 @property immutable(TimeZone) timezone() @safe const pure nothrow return scope
2188 { 2189 {
2189 return _timezone; 2190 return _timezone;
2190 } 2191 }
@@ -2238,7 +2239,7 @@ public:
2238 /++ 2239 /++
2239 Returns whether DST is in effect for this $(LREF SysTime). 2240 Returns whether DST is in effect for this $(LREF SysTime).
2240 +/ 2241 +/
2241 @property bool dstInEffect() @safe const nothrow scope 2242 @property bool dstInEffect() @safe const nothrow return scope
2242 { 2243 {
2243 return _timezone.dstInEffect(_stdTime); 2244 return _timezone.dstInEffect(_stdTime);
2244 } 2245 }
@@ -2261,7 +2262,7 @@ public:
2261 Returns what the offset from UTC is for this $(LREF SysTime). 2262 Returns what the offset from UTC is for this $(LREF SysTime).
2262 It includes the DST offset in effect at that time (if any). 2263 It includes the DST offset in effect at that time (if any).
2263 +/ 2264 +/
2264 @property Duration utcOffset() @safe const nothrow scope 2265 @property Duration utcOffset() @safe const nothrow return scope
2265 { 2266 {
2266 return _timezone.utcOffsetAt(_stdTime); 2267 return _timezone.utcOffsetAt(_stdTime);
2267 } 2268 }
@@ -9586,13 +9587,13 @@ private:
9586 9587
9587 @property override bool hasDST() @safe const nothrow @nogc { return false; } 9588 @property override bool hasDST() @safe const nothrow @nogc { return false; }
9588 9589
9589 override bool dstInEffect(long stdTime) @safe const nothrow @nogc { return false; } 9590 override bool dstInEffect(long stdTime) @safe const scope nothrow @nogc { return false; }
9590 9591
9591 override long utcToTZ(long stdTime) @safe const nothrow @nogc { return 0; } 9592 override long utcToTZ(long stdTime) @safe const scope nothrow @nogc { return 0; }
9592 9593
9593 override long tzToUTC(long adjTime) @safe const nothrow @nogc { return 0; } 9594 override long tzToUTC(long adjTime) @safe const scope nothrow @nogc { return 0; }
9594 9595
9595 override Duration utcOffsetAt(long stdTime) @safe const nothrow @nogc { return Duration.zero; } 9596 override Duration utcOffsetAt(long stdTime) @safe const scope nothrow @nogc { return Duration.zero; }
9596 9597
9597 private: 9598 private:
9598 9599
@@ -9628,7 +9629,7 @@ private:
9628 return _timezoneStorage is null ? InitTimeZone() : _timezoneStorage; 9629 return _timezoneStorage is null ? InitTimeZone() : _timezoneStorage;
9629 } 9630 }
9630 9631
9631 pragma(inline, true) @property void _timezone(immutable TimeZone tz) @safe pure nothrow @nogc scope 9632 pragma(inline, true) @property void _timezone(return scope immutable TimeZone tz) @safe pure nothrow @nogc scope
9632 { 9633 {
9633 _timezoneStorage = tz; 9634 _timezoneStorage = tz;
9634 } 9635 }
diff --git a/libphobos/src/std/datetime/timezone.d b/libphobos/src/std/datetime/timezone.d
index 052758097a9..a55411b02d5 100644
--- a/libphobos/src/std/datetime/timezone.d
+++ b/libphobos/src/std/datetime/timezone.d
@@ -100,7 +100,7 @@ public:
100 However, on Windows, it may be the unabbreviated name (e.g. Pacific 100 However, on Windows, it may be the unabbreviated name (e.g. Pacific
101 Standard Time). Regardless, it is not the same as name. 101 Standard Time). Regardless, it is not the same as name.
102 +/ 102 +/
103 @property string stdName() @safe const nothrow 103 @property string stdName() @safe const scope nothrow
104 { 104 {
105 return _stdName; 105 return _stdName;
106 } 106 }
@@ -113,7 +113,7 @@ public:
113 However, on Windows, it may be the unabbreviated name (e.g. Pacific 113 However, on Windows, it may be the unabbreviated name (e.g. Pacific
114 Daylight Time). Regardless, it is not the same as name. 114 Daylight Time). Regardless, it is not the same as name.
115 +/ 115 +/
116 @property string dstName() @safe const nothrow 116 @property string dstName() @safe const scope nothrow
117 { 117 {
118 return _dstName; 118 return _dstName;
119 } 119 }
@@ -137,7 +137,7 @@ public:
137 stdTime = The UTC time that needs to be checked for DST in this time 137 stdTime = The UTC time that needs to be checked for DST in this time
138 zone. 138 zone.
139 +/ 139 +/
140 abstract bool dstInEffect(long stdTime) @safe const nothrow; 140 abstract bool dstInEffect(long stdTime) @safe const scope nothrow;
141 141
142 142
143 /++ 143 /++
@@ -148,7 +148,7 @@ public:
148 stdTime = The UTC time that needs to be adjusted to this time zone's 148 stdTime = The UTC time that needs to be adjusted to this time zone's
149 time. 149 time.
150 +/ 150 +/
151 abstract long utcToTZ(long stdTime) @safe const nothrow; 151 abstract long utcToTZ(long stdTime) @safe const scope nothrow;
152 152
153 153
154 /++ 154 /++
@@ -159,7 +159,7 @@ public:
159 adjTime = The time in this time zone that needs to be adjusted to 159 adjTime = The time in this time zone that needs to be adjusted to
160 UTC time. 160 UTC time.
161 +/ 161 +/
162 abstract long tzToUTC(long adjTime) @safe const nothrow; 162 abstract long tzToUTC(long adjTime) @safe const scope nothrow;
163 163
164 164
165 /++ 165 /++
@@ -170,7 +170,7 @@ public:
170 stdTime = The UTC time for which to get the offset from UTC for this 170 stdTime = The UTC time for which to get the offset from UTC for this
171 time zone. 171 time zone.
172 +/ 172 +/
173 Duration utcOffsetAt(long stdTime) @safe const nothrow 173 Duration utcOffsetAt(long stdTime) @safe const scope nothrow
174 { 174 {
175 return dur!"hnsecs"(utcToTZ(stdTime) - stdTime); 175 return dur!"hnsecs"(utcToTZ(stdTime) - stdTime);
176 } 176 }
@@ -580,7 +580,7 @@ public:
580 dynamically rather than it being fixed like it would be with most time 580 dynamically rather than it being fixed like it would be with most time
581 zones. 581 zones.
582 +/ 582 +/
583 @property override string stdName() @trusted const nothrow 583 @property override string stdName() @trusted const scope nothrow
584 { 584 {
585 version (Posix) 585 version (Posix)
586 { 586 {
@@ -665,7 +665,7 @@ public:
665 dynamically rather than it being fixed like it would be with most time 665 dynamically rather than it being fixed like it would be with most time
666 zones. 666 zones.
667 +/ 667 +/
668 @property override string dstName() @trusted const nothrow 668 @property override string dstName() @trusted const scope nothrow
669 { 669 {
670 version (Posix) 670 version (Posix)
671 { 671 {
@@ -809,7 +809,7 @@ public:
809 stdTime = The UTC time that needs to be checked for DST in this time 809 stdTime = The UTC time that needs to be checked for DST in this time
810 zone. 810 zone.
811 +/ 811 +/
812 override bool dstInEffect(long stdTime) @trusted const nothrow 812 override bool dstInEffect(long stdTime) @trusted const scope nothrow
813 { 813 {
814 import core.stdc.time : tm; 814 import core.stdc.time : tm;
815 815
@@ -863,7 +863,7 @@ public:
863 See_Also: 863 See_Also:
864 `TimeZone.utcToTZ` 864 `TimeZone.utcToTZ`
865 +/ 865 +/
866 override long utcToTZ(long stdTime) @trusted const nothrow 866 override long utcToTZ(long stdTime) @trusted const scope nothrow
867 { 867 {
868 version (Solaris) 868 version (Solaris)
869 return stdTime + convert!("seconds", "hnsecs")(tm_gmtoff(stdTime)); 869 return stdTime + convert!("seconds", "hnsecs")(tm_gmtoff(stdTime));
@@ -904,7 +904,7 @@ public:
904 adjTime = The time in this time zone that needs to be adjusted to 904 adjTime = The time in this time zone that needs to be adjusted to
905 UTC time. 905 UTC time.
906 +/ 906 +/
907 override long tzToUTC(long adjTime) @trusted const nothrow 907 override long tzToUTC(long adjTime) @trusted const scope nothrow
908 { 908 {
909 version (Posix) 909 version (Posix)
910 { 910 {
@@ -1159,7 +1159,7 @@ public:
1159 /++ 1159 /++
1160 Always returns false. 1160 Always returns false.
1161 +/ 1161 +/
1162 override bool dstInEffect(long stdTime) @safe const nothrow 1162 override bool dstInEffect(long stdTime) @safe const scope nothrow
1163 { 1163 {
1164 return false; 1164 return false;
1165 } 1165 }
@@ -1175,7 +1175,7 @@ public:
1175 See_Also: 1175 See_Also:
1176 `TimeZone.utcToTZ` 1176 `TimeZone.utcToTZ`
1177 +/ 1177 +/
1178 override long utcToTZ(long stdTime) @safe const nothrow 1178 override long utcToTZ(long stdTime) @safe const scope nothrow
1179 { 1179 {
1180 return stdTime; 1180 return stdTime;
1181 } 1181 }
@@ -1208,7 +1208,7 @@ public:
1208 adjTime = The time in this time zone that needs to be adjusted to 1208 adjTime = The time in this time zone that needs to be adjusted to
1209 UTC time. 1209 UTC time.
1210 +/ 1210 +/
1211 override long tzToUTC(long adjTime) @safe const nothrow 1211 override long tzToUTC(long adjTime) @safe const scope nothrow
1212 { 1212 {
1213 return adjTime; 1213 return adjTime;
1214 } 1214 }
@@ -1238,7 +1238,7 @@ public:
1238 stdTime = The UTC time for which to get the offset from UTC for this 1238 stdTime = The UTC time for which to get the offset from UTC for this
1239 time zone. 1239 time zone.
1240 +/ 1240 +/
1241 override Duration utcOffsetAt(long stdTime) @safe const nothrow 1241 override Duration utcOffsetAt(long stdTime) @safe const scope nothrow
1242 { 1242 {
1243 return dur!"hnsecs"(0); 1243 return dur!"hnsecs"(0);
1244 } 1244 }
@@ -1285,7 +1285,7 @@ public:
1285 /++ 1285 /++
1286 Always returns false. 1286 Always returns false.
1287 +/ 1287 +/
1288 override bool dstInEffect(long stdTime) @safe const nothrow 1288 override bool dstInEffect(long stdTime) @safe const scope nothrow
1289 { 1289 {
1290 return false; 1290 return false;
1291 } 1291 }
@@ -1299,7 +1299,7 @@ public:
1299 stdTime = The UTC time that needs to be adjusted to this time zone's 1299 stdTime = The UTC time that needs to be adjusted to this time zone's
1300 time. 1300 time.
1301 +/ 1301 +/
1302 override long utcToTZ(long stdTime) @safe const nothrow 1302 override long utcToTZ(long stdTime) @safe const scope nothrow
1303 { 1303 {
1304 return stdTime + _utcOffset.total!"hnsecs"; 1304 return stdTime + _utcOffset.total!"hnsecs";
1305 } 1305 }
@@ -1326,7 +1326,7 @@ public:
1326 adjTime = The time in this time zone that needs to be adjusted to 1326 adjTime = The time in this time zone that needs to be adjusted to
1327 UTC time. 1327 UTC time.
1328 +/ 1328 +/
1329 override long tzToUTC(long adjTime) @safe const nothrow 1329 override long tzToUTC(long adjTime) @safe const scope nothrow
1330 { 1330 {
1331 return adjTime - _utcOffset.total!"hnsecs"; 1331 return adjTime - _utcOffset.total!"hnsecs";
1332 } 1332 }
@@ -1352,7 +1352,7 @@ public:
1352 stdTime = The UTC time for which to get the offset from UTC for this 1352 stdTime = The UTC time for which to get the offset from UTC for this
1353 time zone. 1353 time zone.
1354 +/ 1354 +/
1355 override Duration utcOffsetAt(long stdTime) @safe const nothrow 1355 override Duration utcOffsetAt(long stdTime) @safe const scope nothrow
1356 { 1356 {
1357 return _utcOffset; 1357 return _utcOffset;
1358 } 1358 }
@@ -1919,7 +1919,7 @@ public:
1919 stdTime = The UTC time that needs to be checked for DST in this time 1919 stdTime = The UTC time that needs to be checked for DST in this time
1920 zone. 1920 zone.
1921 +/ 1921 +/
1922 override bool dstInEffect(long stdTime) @safe const nothrow 1922 override bool dstInEffect(long stdTime) @safe const scope nothrow
1923 { 1923 {
1924 assert(!_transitions.empty); 1924 assert(!_transitions.empty);
1925 1925
@@ -1943,7 +1943,7 @@ public:
1943 stdTime = The UTC time that needs to be adjusted to this time zone's 1943 stdTime = The UTC time that needs to be adjusted to this time zone's
1944 time. 1944 time.
1945 +/ 1945 +/
1946 override long utcToTZ(long stdTime) @safe const nothrow 1946 override long utcToTZ(long stdTime) @safe const scope nothrow
1947 { 1947 {
1948 assert(!_transitions.empty); 1948 assert(!_transitions.empty);
1949 1949
@@ -1968,7 +1968,7 @@ public:
1968 adjTime = The time in this time zone that needs to be adjusted to 1968 adjTime = The time in this time zone that needs to be adjusted to
1969 UTC time. 1969 UTC time.
1970 +/ 1970 +/
1971 override long tzToUTC(long adjTime) @safe const nothrow 1971 override long tzToUTC(long adjTime) @safe const scope nothrow
1972 { 1972 {
1973 assert(!_transitions.empty, "UTC offset's not available"); 1973 assert(!_transitions.empty, "UTC offset's not available");
1974 1974
@@ -2691,7 +2691,7 @@ private:
2691 } 2691 }
2692 2692
2693 2693
2694 int calculateLeapSeconds(long stdTime) @safe const pure nothrow 2694 int calculateLeapSeconds(long stdTime) @safe const scope pure nothrow
2695 { 2695 {
2696 if (_leapSeconds.empty) 2696 if (_leapSeconds.empty)
2697 return 0; 2697 return 0;
@@ -2864,7 +2864,7 @@ version (StdDdoc)
2864 current dates but will still return true for `hasDST` because the 2864 current dates but will still return true for `hasDST` because the
2865 time zone did at some point have DST. 2865 time zone did at some point have DST.
2866 +/ 2866 +/
2867 @property override bool hasDST() @safe const nothrow; 2867 @property override bool hasDST() @safe const scope nothrow;
2868 2868
2869 2869
2870 /++ 2870 /++
@@ -2876,7 +2876,7 @@ version (StdDdoc)
2876 stdTime = The UTC time that needs to be checked for DST in this 2876 stdTime = The UTC time that needs to be checked for DST in this
2877 time zone. 2877 time zone.
2878 +/ 2878 +/
2879 override bool dstInEffect(long stdTime) @safe const nothrow; 2879 override bool dstInEffect(long stdTime) @safe const scope nothrow;
2880 2880
2881 2881
2882 /++ 2882 /++
@@ -2888,7 +2888,7 @@ version (StdDdoc)
2888 stdTime = The UTC time that needs to be adjusted to this time 2888 stdTime = The UTC time that needs to be adjusted to this time
2889 zone's time. 2889 zone's time.
2890 +/ 2890 +/
2891 override long utcToTZ(long stdTime) @safe const nothrow; 2891 override long utcToTZ(long stdTime) @safe const scope nothrow;
2892 2892
2893 2893
2894 /++ 2894 /++
@@ -2900,7 +2900,7 @@ version (StdDdoc)
2900 adjTime = The time in this time zone that needs to be adjusted 2900 adjTime = The time in this time zone that needs to be adjusted
2901 to UTC time. 2901 to UTC time.
2902 +/ 2902 +/
2903 override long tzToUTC(long adjTime) @safe const nothrow; 2903 override long tzToUTC(long adjTime) @safe const scope nothrow;
2904 2904
2905 2905
2906 /++ 2906 /++
@@ -2945,9 +2945,9 @@ version (StdDdoc)
2945 else 2945 else
2946 alias TIME_ZONE_INFORMATION = void*; 2946 alias TIME_ZONE_INFORMATION = void*;
2947 2947
2948 static bool _dstInEffect(const TIME_ZONE_INFORMATION* tzInfo, long stdTime) nothrow; 2948 static bool _dstInEffect(const scope TIME_ZONE_INFORMATION* tzInfo, long stdTime) nothrow;
2949 static long _utcToTZ(const TIME_ZONE_INFORMATION* tzInfo, long stdTime, bool hasDST) nothrow; 2949 static long _utcToTZ(const scope TIME_ZONE_INFORMATION* tzInfo, long stdTime, bool hasDST) nothrow;
2950 static long _tzToUTC(const TIME_ZONE_INFORMATION* tzInfo, long adjTime, bool hasDST) nothrow; 2950 static long _tzToUTC(const scope TIME_ZONE_INFORMATION* tzInfo, long adjTime, bool hasDST) nothrow;
2951 2951
2952 this() immutable pure 2952 this() immutable pure
2953 { 2953 {
@@ -2967,25 +2967,25 @@ else version (Windows)
2967 2967
2968 public: 2968 public:
2969 2969
2970 @property override bool hasDST() @safe const nothrow 2970 @property override bool hasDST() @safe const scope nothrow
2971 { 2971 {
2972 return _tzInfo.DaylightDate.wMonth != 0; 2972 return _tzInfo.DaylightDate.wMonth != 0;
2973 } 2973 }
2974 2974
2975 2975
2976 override bool dstInEffect(long stdTime) @safe const nothrow 2976 override bool dstInEffect(long stdTime) @safe const scope nothrow
2977 { 2977 {
2978 return _dstInEffect(&_tzInfo, stdTime); 2978 return _dstInEffect(&_tzInfo, stdTime);
2979 } 2979 }
2980 2980
2981 2981
2982 override long utcToTZ(long stdTime) @safe const nothrow 2982 override long utcToTZ(long stdTime) @safe const scope nothrow
2983 { 2983 {
2984 return _utcToTZ(&_tzInfo, stdTime, hasDST); 2984 return _utcToTZ(&_tzInfo, stdTime, hasDST);
2985 } 2985 }
2986 2986
2987 2987
2988 override long tzToUTC(long adjTime) @safe const nothrow 2988 override long tzToUTC(long adjTime) @safe const scope nothrow
2989 { 2989 {
2990 return _tzToUTC(&_tzInfo, adjTime, hasDST); 2990 return _tzToUTC(&_tzInfo, adjTime, hasDST);
2991 } 2991 }
@@ -3071,7 +3071,7 @@ else version (Windows)
3071 3071
3072 private: 3072 private:
3073 3073
3074 static bool _dstInEffect(const TIME_ZONE_INFORMATION* tzInfo, long stdTime) @trusted nothrow 3074 static bool _dstInEffect(const scope TIME_ZONE_INFORMATION* tzInfo, long stdTime) @trusted nothrow
3075 { 3075 {
3076 try 3076 try
3077 { 3077 {
@@ -3155,7 +3155,7 @@ else version (Windows)
3155 } 3155 }
3156 3156
3157 3157
3158 static long _utcToTZ(const TIME_ZONE_INFORMATION* tzInfo, long stdTime, bool hasDST) @safe nothrow 3158 static long _utcToTZ(const scope TIME_ZONE_INFORMATION* tzInfo, long stdTime, bool hasDST) @safe nothrow
3159 { 3159 {
3160 if (hasDST && WindowsTimeZone._dstInEffect(tzInfo, stdTime)) 3160 if (hasDST && WindowsTimeZone._dstInEffect(tzInfo, stdTime))
3161 return stdTime - convert!("minutes", "hnsecs")(tzInfo.Bias + tzInfo.DaylightBias); 3161 return stdTime - convert!("minutes", "hnsecs")(tzInfo.Bias + tzInfo.DaylightBias);
@@ -3164,7 +3164,7 @@ else version (Windows)
3164 } 3164 }
3165 3165
3166 3166
3167 static long _tzToUTC(const TIME_ZONE_INFORMATION* tzInfo, long adjTime, bool hasDST) @trusted nothrow 3167 static long _tzToUTC(const scope TIME_ZONE_INFORMATION* tzInfo, long adjTime, bool hasDST) @trusted nothrow
3168 { 3168 {
3169 if (hasDST) 3169 if (hasDST)
3170 { 3170 {
diff --git a/libphobos/src/std/file.d b/libphobos/src/std/file.d
index 1bfed64eae5..315e054cbab 100644
--- a/libphobos/src/std/file.d
+++ b/libphobos/src/std/file.d
@@ -1124,7 +1124,7 @@ version (Windows) private ulong makeUlong(DWORD dwLow, DWORD dwHigh) @safe pure
1124} 1124}
1125 1125
1126version (Posix) private extern (C) pragma(mangle, stat.mangleof) 1126version (Posix) private extern (C) pragma(mangle, stat.mangleof)
1127int trustedStat(const(FSChar)* namez, ref stat_t buf) @nogc nothrow @trusted; 1127int trustedStat(scope const(FSChar)* namez, ref stat_t buf) @nogc nothrow @trusted;
1128 1128
1129/** 1129/**
1130Get size of file `name` in bytes. 1130Get size of file `name` in bytes.
@@ -1928,7 +1928,7 @@ if (isConvertibleToString!R)
1928 assert(!f.exists); 1928 assert(!f.exists);
1929} 1929}
1930 1930
1931private bool existsImpl(const(FSChar)* namez) @trusted nothrow @nogc 1931private bool existsImpl(scope const(FSChar)* namez) @trusted nothrow @nogc
1932{ 1932{
1933 version (Windows) 1933 version (Windows)
1934 { 1934 {
@@ -2010,7 +2010,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
2010 version (Windows) 2010 version (Windows)
2011 { 2011 {
2012 auto namez = name.tempCString!FSChar(); 2012 auto namez = name.tempCString!FSChar();
2013 static auto trustedGetFileAttributesW(const(FSChar)* namez) @trusted 2013 static auto trustedGetFileAttributesW(scope const(FSChar)* namez) @trusted
2014 { 2014 {
2015 return GetFileAttributesW(namez); 2015 return GetFileAttributesW(namez);
2016 } 2016 }
@@ -2220,7 +2220,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
2220 version (Windows) 2220 version (Windows)
2221 { 2221 {
2222 auto namez = name.tempCString!FSChar(); 2222 auto namez = name.tempCString!FSChar();
2223 static auto trustedSetFileAttributesW(const(FSChar)* namez, uint dwFileAttributes) @trusted 2223 static auto trustedSetFileAttributesW(scope const(FSChar)* namez, uint dwFileAttributes) @trusted
2224 { 2224 {
2225 return SetFileAttributesW(namez, dwFileAttributes); 2225 return SetFileAttributesW(namez, dwFileAttributes);
2226 } 2226 }
@@ -2233,7 +2233,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
2233 else version (Posix) 2233 else version (Posix)
2234 { 2234 {
2235 auto namez = name.tempCString!FSChar(); 2235 auto namez = name.tempCString!FSChar();
2236 static auto trustedChmod(const(FSChar)* namez, mode_t mode) @trusted 2236 static auto trustedChmod(scope const(FSChar)* namez, mode_t mode) @trusted
2237 { 2237 {
2238 return chmod(namez, mode); 2238 return chmod(namez, mode);
2239 } 2239 }
@@ -2868,14 +2868,14 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
2868 2868
2869 version (Windows) 2869 version (Windows)
2870 { 2870 {
2871 static auto trustedChdir(const(FSChar)* pathz) @trusted 2871 static auto trustedChdir(scope const(FSChar)* pathz) @trusted
2872 { 2872 {
2873 return SetCurrentDirectoryW(pathz); 2873 return SetCurrentDirectoryW(pathz);
2874 } 2874 }
2875 } 2875 }
2876 else version (Posix) 2876 else version (Posix)
2877 { 2877 {
2878 static auto trustedChdir(const(FSChar)* pathz) @trusted 2878 static auto trustedChdir(scope const(FSChar)* pathz) @trusted
2879 { 2879 {
2880 return core.sys.posix.unistd.chdir(pathz) == 0; 2880 return core.sys.posix.unistd.chdir(pathz) == 0;
2881 } 2881 }
@@ -2939,7 +2939,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
2939 2939
2940 version (Windows) 2940 version (Windows)
2941 { 2941 {
2942 static auto trustedCreateDirectoryW(const(FSChar)* pathz) @trusted 2942 static auto trustedCreateDirectoryW(scope const(FSChar)* pathz) @trusted
2943 { 2943 {
2944 return CreateDirectoryW(pathz, null); 2944 return CreateDirectoryW(pathz, null);
2945 } 2945 }
@@ -2953,7 +2953,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
2953 { 2953 {
2954 import std.conv : octal; 2954 import std.conv : octal;
2955 2955
2956 static auto trustedMkdir(const(FSChar)* pathz, mode_t mode) @trusted 2956 static auto trustedMkdir(scope const(FSChar)* pathz, mode_t mode) @trusted
2957 { 2957 {
2958 return core.sys.posix.sys.stat.mkdir(pathz, mode); 2958 return core.sys.posix.sys.stat.mkdir(pathz, mode);
2959 } 2959 }
@@ -3143,14 +3143,14 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
3143 3143
3144 version (Windows) 3144 version (Windows)
3145 { 3145 {
3146 static auto trustedRmdir(const(FSChar)* pathz) @trusted 3146 static auto trustedRmdir(scope const(FSChar)* pathz) @trusted
3147 { 3147 {
3148 return RemoveDirectoryW(pathz); 3148 return RemoveDirectoryW(pathz);
3149 } 3149 }
3150 } 3150 }
3151 else version (Posix) 3151 else version (Posix)
3152 { 3152 {
3153 static auto trustedRmdir(const(FSChar)* pathz) @trusted 3153 static auto trustedRmdir(scope const(FSChar)* pathz) @trusted
3154 { 3154 {
3155 return core.sys.posix.unistd.rmdir(pathz) == 0; 3155 return core.sys.posix.unistd.rmdir(pathz) == 0;
3156 } 3156 }
@@ -3859,17 +3859,17 @@ else version (Windows)
3859 return _size; 3859 return _size;
3860 } 3860 }
3861 3861
3862 @property SysTime timeCreated() const pure nothrow scope 3862 @property SysTime timeCreated() const pure nothrow return scope
3863 { 3863 {
3864 return cast(SysTime)_timeCreated; 3864 return cast(SysTime)_timeCreated;
3865 } 3865 }
3866 3866
3867 @property SysTime timeLastAccessed() const pure nothrow scope 3867 @property SysTime timeLastAccessed() const pure nothrow return scope
3868 { 3868 {
3869 return cast(SysTime)_timeLastAccessed; 3869 return cast(SysTime)_timeLastAccessed;
3870 } 3870 }
3871 3871
3872 @property SysTime timeLastModified() const pure nothrow scope 3872 @property SysTime timeLastModified() const pure nothrow return scope
3873 { 3873 {
3874 return cast(SysTime)_timeLastModified; 3874 return cast(SysTime)_timeLastModified;
3875 } 3875 }
diff --git a/libphobos/src/std/internal/cstring.d b/libphobos/src/std/internal/cstring.d
index a61ee81cc45..b21f58d602e 100644
--- a/libphobos/src/std/internal/cstring.d
+++ b/libphobos/src/std/internal/cstring.d
@@ -227,7 +227,7 @@ private struct TempCStringBuffer(To = char)
227 @disable this(this); 227 @disable this(this);
228 alias ptr this; /// implicitly covert to raw pointer 228 alias ptr this; /// implicitly covert to raw pointer
229 229
230 @property inout(To)* buffPtr() inout 230 @property inout(To)* buffPtr() return inout
231 { 231 {
232 return _ptr == useStack ? _buff.ptr : _ptr; 232 return _ptr == useStack ? _buff.ptr : _ptr;
233 } 233 }
diff --git a/libphobos/src/std/internal/math/biguintcore.d b/libphobos/src/std/internal/math/biguintcore.d
index 79446756fa6..6a93e0a16b0 100644
--- a/libphobos/src/std/internal/math/biguintcore.d
+++ b/libphobos/src/std/internal/math/biguintcore.d
@@ -879,7 +879,7 @@ public:
879 } 879 }
880 880
881 // return x / y 881 // return x / y
882 static BigUint divInt(T)(scope return BigUint x, T y_) pure nothrow @safe 882 static BigUint divInt(T)(return scope BigUint x, T y_) pure nothrow @safe
883 if ( is(immutable T == immutable uint) ) 883 if ( is(immutable T == immutable uint) )
884 { 884 {
885 uint y = y_; 885 uint y = y_;
@@ -942,7 +942,7 @@ public:
942 } 942 }
943 943
944 // return x / y 944 // return x / y
945 static BigUint div(scope return BigUint x, scope BigUint y) pure nothrow @safe 945 static BigUint div(return scope BigUint x, scope BigUint y) pure nothrow @safe
946 { 946 {
947 if (y.data.length > x.data.length) 947 if (y.data.length > x.data.length)
948 return BigUint(ZERO); 948 return BigUint(ZERO);
@@ -954,7 +954,7 @@ public:
954 } 954 }
955 955
956 // return x % y 956 // return x % y
957 static BigUint mod(scope return BigUint x, scope BigUint y) pure nothrow @safe 957 static BigUint mod(return scope BigUint x, scope BigUint y) pure nothrow @safe
958 { 958 {
959 if (y.data.length > x.data.length) return x; 959 if (y.data.length > x.data.length) return x;
960 if (y.data.length == 1) 960 if (y.data.length == 1)
@@ -1020,7 +1020,7 @@ public:
1020 * exponentiation is used. 1020 * exponentiation is used.
1021 * Memory allocation is minimized: at most one temporary BigUint is used. 1021 * Memory allocation is minimized: at most one temporary BigUint is used.
1022 */ 1022 */
1023 static BigUint pow(scope return BigUint x, ulong y) pure nothrow @safe 1023 static BigUint pow(return scope BigUint x, ulong y) pure nothrow @safe
1024 { 1024 {
1025 // Deal with the degenerate cases first. 1025 // Deal with the degenerate cases first.
1026 if (y == 0) return BigUint(ONE); 1026 if (y == 0) return BigUint(ONE);
@@ -1259,7 +1259,7 @@ public:
1259} 1259}
1260 1260
1261// Remove leading zeros from x, to restore the BigUint invariant 1261// Remove leading zeros from x, to restore the BigUint invariant
1262inout(BigDigit) [] removeLeadingZeros(scope return inout(BigDigit) [] x) pure nothrow @safe 1262inout(BigDigit) [] removeLeadingZeros(return scope inout(BigDigit) [] x) pure nothrow @safe
1263{ 1263{
1264 size_t k = x.length; 1264 size_t k = x.length;
1265 while (k>1 && x[k - 1]==0) --k; 1265 while (k>1 && x[k - 1]==0) --k;
@@ -1916,7 +1916,7 @@ pure @safe unittest
1916// every 8 digits. 1916// every 8 digits.
1917// buff.length must be data.length*8 if separator is zero, 1917// buff.length must be data.length*8 if separator is zero,
1918// or data.length*9 if separator is non-zero. It will be completely filled. 1918// or data.length*9 if separator is non-zero. It will be completely filled.
1919char [] biguintToHex(scope return char [] buff, const scope BigDigit [] data, char separator=0, 1919char [] biguintToHex(return scope char [] buff, const scope BigDigit [] data, char separator=0,
1920 LetterCase letterCase = LetterCase.upper) pure nothrow @safe 1920 LetterCase letterCase = LetterCase.upper) pure nothrow @safe
1921{ 1921{
1922 int x=0; 1922 int x=0;
diff --git a/libphobos/src/std/json.d b/libphobos/src/std/json.d
index af7aa383d8e..ea22d635766 100644
--- a/libphobos/src/std/json.d
+++ b/libphobos/src/std/json.d
@@ -159,7 +159,7 @@ struct JSONValue
159 return store.str; 159 return store.str;
160 } 160 }
161 /// ditto 161 /// ditto
162 @property string str(return string v) pure nothrow @nogc @trusted return // TODO make @safe 162 @property string str(return scope string v) pure nothrow @nogc @trusted return // TODO make @safe
163 { 163 {
164 assign(v); 164 assign(v);
165 return v; 165 return v;
@@ -282,7 +282,7 @@ struct JSONValue
282 return store.object; 282 return store.object;
283 } 283 }
284 /// ditto 284 /// ditto
285 @property JSONValue[string] object(return JSONValue[string] v) pure nothrow @nogc @trusted // TODO make @safe 285 @property JSONValue[string] object(return scope JSONValue[string] v) pure nothrow @nogc @trusted // TODO make @safe
286 { 286 {
287 assign(v); 287 assign(v);
288 return v; 288 return v;
@@ -321,14 +321,14 @@ struct JSONValue
321 (*a)[0] = "world"; // segmentation fault 321 (*a)[0] = "world"; // segmentation fault
322 --- 322 ---
323 */ 323 */
324 @property ref inout(JSONValue[]) array() inout pure @system 324 @property ref inout(JSONValue[]) array() return scope inout pure @system
325 { 325 {
326 enforce!JSONException(type == JSONType.array, 326 enforce!JSONException(type == JSONType.array,
327 "JSONValue is not an array"); 327 "JSONValue is not an array");
328 return store.array; 328 return store.array;
329 } 329 }
330 /// ditto 330 /// ditto
331 @property JSONValue[] array(return JSONValue[] v) pure nothrow @nogc @trusted scope // TODO make @safe 331 @property JSONValue[] array(return scope JSONValue[] v) pure nothrow @nogc @trusted scope // TODO make @safe
332 { 332 {
333 assign(v); 333 assign(v);
334 return v; 334 return v;
@@ -635,7 +635,7 @@ struct JSONValue
635 * Hash syntax for json objects. 635 * Hash syntax for json objects.
636 * Throws: `JSONException` if `type` is not `JSONType.object`. 636 * Throws: `JSONException` if `type` is not `JSONType.object`.
637 */ 637 */
638 ref inout(JSONValue) opIndex(return string k) inout pure @safe 638 ref inout(JSONValue) opIndex(return scope string k) inout pure @safe
639 { 639 {
640 auto o = this.objectNoRef; 640 auto o = this.objectNoRef;
641 return *enforce!JSONException(k in o, 641 return *enforce!JSONException(k in o,
diff --git a/libphobos/src/std/net/isemail.d b/libphobos/src/std/net/isemail.d
index f2a8ff3025d..12a29fe44c9 100644
--- a/libphobos/src/std/net/isemail.d
+++ b/libphobos/src/std/net/isemail.d
@@ -1893,7 +1893,7 @@ Note that only the first item of "matchAll" was ever used in practice
1893so we can return `const(Char)[]` instead of `const(Char)[][]` using a 1893so we can return `const(Char)[]` instead of `const(Char)[][]` using a
1894zero-length string to indicate no match. 1894zero-length string to indicate no match.
1895+/ 1895+/
1896const(Char)[] matchIPSuffix(Char)(return const(Char)[] s) @nogc nothrow pure @safe 1896const(Char)[] matchIPSuffix(Char)(return scope const(Char)[] s) @nogc nothrow pure @safe
1897{ 1897{
1898 size_t end = s.length; 1898 size_t end = s.length;
1899 if (end < 7) return null; 1899 if (end < 7) return null;
diff --git a/libphobos/src/std/process.d b/libphobos/src/std/process.d
index 98c5b946748..958f606ff52 100644
--- a/libphobos/src/std/process.d
+++ b/libphobos/src/std/process.d
@@ -276,7 +276,7 @@ static:
276 multi-threaded programs. See e.g. 276 multi-threaded programs. See e.g.
277 $(LINK2 https://www.gnu.org/software/libc/manual/html_node/Environment-Access.html#Environment-Access, glibc). 277 $(LINK2 https://www.gnu.org/software/libc/manual/html_node/Environment-Access.html#Environment-Access, glibc).
278 */ 278 */
279 inout(char)[] opIndexAssign(return inout char[] value, scope const(char)[] name) @trusted 279 inout(char)[] opIndexAssign(return scope inout char[] value, scope const(char)[] name) @trusted
280 { 280 {
281 version (Posix) 281 version (Posix)
282 { 282 {
@@ -4385,6 +4385,7 @@ else version (Posix)
4385 4385
4386 void browse(scope const(char)[] url) nothrow @nogc @safe 4386 void browse(scope const(char)[] url) nothrow @nogc @safe
4387 { 4387 {
4388 const buffer = url.tempCString(); // Retain buffer until end of scope
4388 const(char)*[3] args; 4389 const(char)*[3] args;
4389 4390
4390 // Trusted because it's called with a zero-terminated literal 4391 // Trusted because it's called with a zero-terminated literal
@@ -4408,7 +4409,6 @@ else version (Posix)
4408 } 4409 }
4409 } 4410 }
4410 4411
4411 const buffer = url.tempCString(); // Retain buffer until end of scope
4412 args[1] = buffer; 4412 args[1] = buffer;
4413 args[2] = null; 4413 args[2] = null;
4414 4414
diff --git a/libphobos/src/std/random.d b/libphobos/src/std/random.d
index a3483561134..106e51ceedb 100644
--- a/libphobos/src/std/random.d
+++ b/libphobos/src/std/random.d
@@ -166,12 +166,16 @@ version (D_InlineAsm_X86_64) version = InlineAsm_X86_Any;
166 assert(10.iota.randomSample(3, rnd2).equal([7, 8, 9])); 166 assert(10.iota.randomSample(3, rnd2).equal([7, 8, 9]));
167 167
168 // Cover all elements in an array in random order 168 // Cover all elements in an array in random order
169 version (X86_64) // https://issues.dlang.org/show_bug.cgi?id=15147 169 version (D_LP64) // https://issues.dlang.org/show_bug.cgi?id=15147
170 assert(10.iota.randomCover(rnd2).equal([7, 4, 2, 0, 1, 6, 8, 3, 9, 5])); 170 assert(10.iota.randomCover(rnd2).equal([7, 4, 2, 0, 1, 6, 8, 3, 9, 5]));
171 else
172 assert(10.iota.randomCover(rnd2).equal([4, 8, 7, 3, 5, 9, 2, 6, 0, 1]));
171 173
172 // Shuffle an array 174 // Shuffle an array
173 version (X86_64) // https://issues.dlang.org/show_bug.cgi?id=15147 175 version (D_LP64) // https://issues.dlang.org/show_bug.cgi?id=15147
174 assert([0, 1, 2, 4, 5].randomShuffle(rnd2).equal([2, 0, 4, 5, 1])); 176 assert([0, 1, 2, 4, 5].randomShuffle(rnd2).equal([2, 0, 4, 5, 1]));
177 else
178 assert([0, 1, 2, 4, 5].randomShuffle(rnd2).equal([4, 2, 5, 0, 1]));
175} 179}
176 180
177version (StdUnittest) 181version (StdUnittest)
diff --git a/libphobos/src/std/stdio.d b/libphobos/src/std/stdio.d
index d3097d548ce..f30ea80ae44 100644
--- a/libphobos/src/std/stdio.d
+++ b/libphobos/src/std/stdio.d
@@ -4650,7 +4650,7 @@ if ((isInputRange!R1 && isSomeChar!(ElementEncodingType!R1) || isSomeString!R1)
4650 auto namez = name.tempCString!FSChar(); 4650 auto namez = name.tempCString!FSChar();
4651 auto modez = mode.tempCString!FSChar(); 4651 auto modez = mode.tempCString!FSChar();
4652 4652
4653 static _fopenImpl(const(FSChar)* namez, const(FSChar)* modez) @trusted nothrow @nogc 4653 static _fopenImpl(scope const(FSChar)* namez, scope const(FSChar)* modez) @trusted nothrow @nogc
4654 { 4654 {
4655 version (Windows) 4655 version (Windows)
4656 { 4656 {
diff --git a/libphobos/src/std/typecons.d b/libphobos/src/std/typecons.d
index db0e3da304c..6dee863521d 100644
--- a/libphobos/src/std/typecons.d
+++ b/libphobos/src/std/typecons.d
@@ -2239,7 +2239,7 @@ if (is(T == class) || is(T == interface) || isAssociativeArray!T)
2239 U stripped; 2239 U stripped;
2240 } 2240 }
2241 2241
2242 void opAssign(T another) pure nothrow @nogc 2242 void opAssign(return scope T another) pure nothrow @nogc
2243 { 2243 {
2244 // If `T` defines `opCast` we must infer the safety 2244 // If `T` defines `opCast` we must infer the safety
2245 static if (hasMember!(T, "opCast")) 2245 static if (hasMember!(T, "opCast"))
@@ -2271,7 +2271,7 @@ if (is(T == class) || is(T == interface) || isAssociativeArray!T)
2271 opAssign(initializer); 2271 opAssign(initializer);
2272 } 2272 }
2273 2273
2274 @property inout(T) get() @trusted pure nothrow @nogc inout 2274 @property inout(T) get() @trusted pure nothrow @nogc return scope inout
2275 { 2275 {
2276 return original; 2276 return original;
2277 } 2277 }
@@ -2792,6 +2792,15 @@ struct Nullable(T)
2792 } 2792 }
2793 } 2793 }
2794 2794
2795 this (ref return scope inout Nullable!T rhs) inout
2796 {
2797 _isNull = rhs._isNull;
2798 if (!_isNull)
2799 _value.payload = rhs._value.payload;
2800 else
2801 _value = DontCallDestructorT.init;
2802 }
2803
2795 /** 2804 /**
2796 * If they are both null, then they are equal. If one is null and the other 2805 * If they are both null, then they are equal. If one is null and the other
2797 * is not, then they are not equal. If they are both non-null, then they are 2806 * is not, then they are not equal. If they are both non-null, then they are
@@ -3284,11 +3293,11 @@ auto nullable(T)(T t)
3284 static struct S2 //inspired from 9404 3293 static struct S2 //inspired from 9404
3285 { 3294 {
3286 Nullable!int ni; 3295 Nullable!int ni;
3287 this(S2 other) 3296 this(ref S2 other)
3288 { 3297 {
3289 ni = other.ni; 3298 ni = other.ni;
3290 } 3299 }
3291 void opAssign(S2 other) 3300 void opAssign(ref S2 other)
3292 { 3301 {
3293 ni = other.ni; 3302 ni = other.ni;
3294 } 3303 }
@@ -9566,3 +9575,21 @@ unittest
9566 assert((a ^ true) == Ternary.no); 9575 assert((a ^ true) == Ternary.no);
9567 assert((a ^ false) == Ternary.yes); 9576 assert((a ^ false) == Ternary.yes);
9568} 9577}
9578
9579// https://issues.dlang.org/show_bug.cgi?id=22511
9580@safe unittest
9581{
9582 static struct S
9583 {
9584 int b;
9585 @disable this(this);
9586 this (ref return scope inout S rhs) inout
9587 {
9588 this.b = rhs.b + 1;
9589 }
9590 }
9591
9592 Nullable!S s1 = S(1);
9593 Nullable!S s2 = s1;
9594 assert(s2.get().b > s1.get().b);
9595}
diff --git a/libphobos/src/std/uni/package.d b/libphobos/src/std/uni/package.d
index 45b7207c1f1..a27cbea177b 100644
--- a/libphobos/src/std/uni/package.d
+++ b/libphobos/src/std/uni/package.d
@@ -1987,8 +1987,8 @@ pure:
1987 { 1987 {
1988 return this[0] == val[0] && this[1] == val[1]; 1988 return this[0] == val[0] && this[1] == val[1];
1989 } 1989 }
1990 @property ref inout(uint) a() inout { return _tuple[0]; } 1990 @property ref inout(uint) a() return inout { return _tuple[0]; }
1991 @property ref inout(uint) b() inout { return _tuple[1]; } 1991 @property ref inout(uint) b() return inout { return _tuple[1]; }
1992} 1992}
1993 1993
1994