Skip to content

Commit 992cc83

Browse files
committed
Merge remote-tracking branch 'upstream/master' into stable
2 parents 539dc47 + 312a86d commit 992cc83

File tree

17 files changed

+191
-555
lines changed

17 files changed

+191
-555
lines changed

.dscanner.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ redundant_attributes_check="-std.concurrency,-std.digest.md,-std.digest.ripemd,-
404404
style_check="+disabled"
405405
;style_check="-etc.c.curl,-etc.c.odbc.sqlext,-etc.c.odbc.sqltypes,-etc.c.odbc.sqlucode,-etc.c.sqlite3,-etc.c.zlib,-std.algorithm.comparison,-std.algorithm.internal,-std.algorithm.iteration,-std.algorithm.mutation,-std.algorithm.sorting,-std.array,-std.base64,-std.bitmanip,-std.c.linux.linux,-std.compiler,-std.container.array,-std.conv,-std.datetime.date,-std.datetime.interval,-std.datetime.systime,-std.digest,-std.digest.murmurhash,-std.digest.sha,-std.encoding,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks.affix_allocator,-std.experimental.allocator.building_blocks.allocator_list,-std.experimental.allocator.building_blocks.bucketizer,-std.experimental.allocator.building_blocks.fallback_allocator,-std.experimental.allocator.building_blocks.free_list,-std.experimental.allocator.building_blocks.free_tree,-std.experimental.allocator.building_blocks.null_allocator,-std.experimental.allocator.building_blocks.region,-std.experimental.allocator.building_blocks.segregator,-std.experimental.allocator.common,-std.experimental.allocator.gc_allocator,-std.experimental.allocator.mallocator,-std.experimental.allocator.mmap_allocator,-std.experimental.checkedint,-std.format,-std.functional,-std.getopt,-std.internal.digest.sha_SSSE3,-std.internal.math.errorfunction,-std.internal.math.gammafunction,-std.internal.test.dummyrange,-std.internal.unicode_tables,-std.json,-std.math,-std.meta,-std.numeric,-std.parallelism,-std.path,-std.process,-std.random,-std.range,-std.range.primitives,-std.regex,-std.regex.internal.ir,-std.regex.internal.kickstart,-std.signals,-std.socket,-std.stdio,-std.string,-std.uni,-std.uri,-std.utf,-std.uuid,-std.variant,-std.zlib"
406406
; Checks for undocumented public declarations
407-
undocumented_declaration_check="-etc.c.curl,-etc.c.odbc.sql,-etc.c.odbc.sqlext,-etc.c.odbc.sqltypes,-etc.c.odbc.sqlucode,-etc.c.sqlite3,-etc.c.zlib,-std.algorithm.sorting,-std.array,-std.ascii,-std.base64,-std.bitmanip,-std.c.linux.linux,-std.c.linux.socket,-std.c.osx.socket,-std.c.process,-std.compiler,-std.complex,-std.concurrency,-std.container,-std.container.array,-std.container.binaryheap,-std.container.dlist,-std.container.rbtree,-std.container.slist,-std.conv,-std.csv,-std.datetime,-std.datetime.date,-std.digest,-std.digest.hmac,-std.digest.md,-std.digest.murmurhash,-std.digest.ripemd,-std.digest.sha,-std.encoding,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks.affix_allocator,-std.experimental.allocator.building_blocks.allocator_list,-std.experimental.allocator.building_blocks.bitmapped_block,-std.experimental.allocator.building_blocks.fallback_allocator,-std.experimental.allocator.building_blocks.free_list,-std.experimental.allocator.building_blocks.free_tree,-std.experimental.allocator.building_blocks.kernighan_ritchie,-std.experimental.allocator.building_blocks.quantizer,-std.experimental.allocator.building_blocks.region,-std.experimental.allocator.building_blocks.segregator,-std.experimental.allocator.building_blocks.stats_collector,-std.experimental.allocator.gc_allocator,-std.experimental.allocator.mallocator,-std.experimental.checkedint,-std.logger.core,-std.file,-std.format,-std.functional,-std.internal.digest.sha_SSSE3,-std.internal.math.biguintcore,-std.internal.math.biguintnoasm,-std.internal.math.biguintx86,-std.internal.math.errorfunction,-std.internal.math.gammafunction,-std.internal.test.dummyrange,-std.internal.test.uda,-std.internal.windows.advapi32,-std.json,-std.math,-std.mmfile,-std.numeric,-std.outbuffer,-std.parallelism,-std.path,-std.process,-std.regex,-std.regex.internal.parser,-std.signals,-std.socket,-std.stdio,-std.string,-std.system,-std.traits,-std.uni,-std.utf,-std.variant,-std.windows.charset,-std.windows.registry,-std.windows.syserror,-std.zip,-std.zlib,-std.int128"
407+
undocumented_declaration_check="-etc.c.curl,-etc.c.odbc.sql,-etc.c.odbc.sqlext,-etc.c.odbc.sqltypes,-etc.c.odbc.sqlucode,-etc.c.sqlite3,-etc.c.zlib,-std.algorithm.sorting,-std.array,-std.ascii,-std.base64,-std.bitmanip,-std.c.linux.linux,-std.c.linux.socket,-std.c.osx.socket,-std.c.process,-std.compiler,-std.complex,-std.concurrency,-std.container,-std.container.array,-std.container.binaryheap,-std.container.dlist,-std.container.rbtree,-std.container.slist,-std.conv,-std.csv,-std.datetime,-std.datetime.date,-std.digest,-std.digest.hmac,-std.digest.md,-std.digest.murmurhash,-std.digest.ripemd,-std.digest.sha,-std.encoding,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks.affix_allocator,-std.experimental.allocator.building_blocks.allocator_list,-std.experimental.allocator.building_blocks.bitmapped_block,-std.experimental.allocator.building_blocks.fallback_allocator,-std.experimental.allocator.building_blocks.free_list,-std.experimental.allocator.building_blocks.free_tree,-std.experimental.allocator.building_blocks.kernighan_ritchie,-std.experimental.allocator.building_blocks.quantizer,-std.experimental.allocator.building_blocks.region,-std.experimental.allocator.building_blocks.segregator,-std.experimental.allocator.building_blocks.stats_collector,-std.experimental.allocator.gc_allocator,-std.experimental.allocator.mallocator,-std.experimental.checkedint,-std.logger.core,-std.file,-std.format,-std.functional,-std.internal.digest.sha_SSSE3,-std.internal.math.biguintcore,-std.internal.math.biguintnoasm,-std.internal.math.biguintx86,-std.internal.math.errorfunction,-std.internal.math.gammafunction,-std.internal.test.dummyrange,-std.internal.test.sumtype_example_overloads,-std.internal.test.uda,-std.internal.windows.advapi32,-std.json,-std.math,-std.mmfile,-std.numeric,-std.outbuffer,-std.parallelism,-std.path,-std.process,-std.regex,-std.regex.internal.parser,-std.signals,-std.socket,-std.stdio,-std.string,-std.system,-std.traits,-std.uni,-std.utf,-std.variant,-std.windows.charset,-std.windows.registry,-std.windows.syserror,-std.zip,-std.zlib,-std.int128"
408408
; Checks for unused labels
409409
unused_label_check="-std.conv,-std.internal.math.biguintx86,-std.regex.internal.thompson,-std.signals,-std.uni"
410410
; Checks for unused function parameters

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# make BUILD=debug => makes debug build of the library
1616
#
1717
# make unittest => builds all unittests (for debug AND release) and runs them
18+
# make std/somemodule.test => only builds and unittests std.somemodule
19+
# make std/somepackage.test => only builds and unittests modules in std.somepackage
20+
# make unittest/std/somemodule.run => run std.somemodule unittest
1821
#
1922
# make BUILD=debug unittest => builds all unittests (for debug) and runs them
2023
#
@@ -25,8 +28,6 @@
2528
#
2629
# make install => copies library to /usr/lib
2730
#
28-
# make std/somemodule.test => only builds and unittests std.somemodule
29-
#
3031
################################################################################
3132
# Configurable stuff, usually from the command line
3233
#
@@ -272,6 +273,7 @@ EXTRA_MODULES_INTERNAL := $(addprefix std/, \
272273
$(addprefix math/, biguintcore biguintnoasm biguintx86 \
273274
errorfunction gammafunction ) \
274275
scopebuffer test/dummyrange test/range \
276+
test/sumtype_example_overloads \
275277
$(addprefix unicode_, comp decomp grapheme norm tables) \
276278
windows/advapi32 \
277279
) \

std/bitmanip.d

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ private struct FloatingPointRepresentation(T)
805805
Allows manipulating the fraction, exponent, and sign parts of a
806806
`float` separately. The definition is:
807807
808+
$(RUNNABLE_EXAMPLE
808809
----
809810
struct FloatRep
810811
{
@@ -819,6 +820,7 @@ struct FloatRep
819820
enum uint bias = 127, fractionBits = 23, exponentBits = 8, signBits = 1;
820821
}
821822
----
823+
)
822824
*/
823825
alias FloatRep = FloatingPointRepresentation!float;
824826

@@ -874,6 +876,7 @@ alias FloatRep = FloatingPointRepresentation!float;
874876
Allows manipulating the fraction, exponent, and sign parts of a
875877
`double` separately. The definition is:
876878
879+
$(RUNNABLE_EXAMPLE
877880
----
878881
struct DoubleRep
879882
{
@@ -888,6 +891,7 @@ struct DoubleRep
888891
enum uint bias = 1023, signBits = 1, fractionBits = 52, exponentBits = 11;
889892
}
890893
----
894+
)
891895
*/
892896
alias DoubleRep = FloatingPointRepresentation!double;
893897

@@ -1050,6 +1054,8 @@ public:
10501054
of a type different than `size_t`, firstly because its length should
10511055
be a multiple of `size_t.sizeof`, and secondly because how the bits
10521056
are mapped:
1057+
1058+
$(RUNNABLE_EXAMPLE
10531059
---
10541060
size_t[] source = [1, 2, 3, 3424234, 724398, 230947, 389492];
10551061
enum sbits = size_t.sizeof * 8;
@@ -1060,6 +1066,7 @@ public:
10601066
assert(ba[n] == nth_bit);
10611067
}
10621068
---
1069+
)
10631070
The least significant bit in any `size_t` unit is the starting bit of this
10641071
unit, and the most significant bit is the last bit of this unit. Therefore,
10651072
passing e.g. an array of `int`s may result in a different `BitArray`

std/experimental/allocator/mallocator.d

Lines changed: 4 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -116,93 +116,11 @@ struct Mallocator
116116
test!Mallocator();
117117
}
118118

119-
version (Windows)
119+
version (CRuntime_Microsoft)
120120
{
121-
// DMD Win 32 bit, DigitalMars C standard library misses the _aligned_xxx
122-
// functions family (snn.lib)
123-
version (CRuntime_DigitalMars)
124-
{
125-
// Helper to cast the infos written before the aligned pointer
126-
// this header keeps track of the size (required to realloc) and of
127-
// the base ptr (required to free).
128-
private struct AlignInfo
129-
{
130-
void* basePtr;
131-
size_t size;
132-
133-
@nogc nothrow
134-
static AlignInfo* opCall(void* ptr)
135-
{
136-
return cast(AlignInfo*) (ptr - AlignInfo.sizeof);
137-
}
138-
}
139-
140-
@nogc nothrow
141-
private void* _aligned_malloc(size_t size, size_t alignment)
142-
{
143-
import core.stdc.stdlib : malloc;
144-
size_t offset = alignment + size_t.sizeof * 2 - 1;
145-
146-
// unaligned chunk
147-
void* basePtr = malloc(size + offset);
148-
if (!basePtr) return null;
149-
150-
// get aligned location within the chunk
151-
void* alignedPtr = cast(void**)((cast(size_t)(basePtr) + offset)
152-
& ~(alignment - 1));
153-
154-
// write the header before the aligned pointer
155-
AlignInfo* head = AlignInfo(alignedPtr);
156-
head.basePtr = basePtr;
157-
head.size = size;
158-
159-
return alignedPtr;
160-
}
161-
162-
@nogc nothrow
163-
private void* _aligned_realloc(void* ptr, size_t size, size_t alignment)
164-
{
165-
import core.stdc.stdlib : free;
166-
import core.stdc.string : memcpy;
167-
168-
if (!ptr) return _aligned_malloc(size, alignment);
169-
170-
// gets the header from the exising pointer
171-
AlignInfo* head = AlignInfo(ptr);
172-
173-
// gets a new aligned pointer
174-
void* alignedPtr = _aligned_malloc(size, alignment);
175-
if (!alignedPtr)
176-
{
177-
//to https://msdn.microsoft.com/en-us/library/ms235462.aspx
178-
//see Return value: in this case the original block is unchanged
179-
return null;
180-
}
181-
182-
// copy exising data
183-
memcpy(alignedPtr, ptr, head.size);
184-
free(head.basePtr);
185-
186-
return alignedPtr;
187-
}
188-
189-
@nogc nothrow
190-
private void _aligned_free(void *ptr)
191-
{
192-
import core.stdc.stdlib : free;
193-
if (!ptr) return;
194-
AlignInfo* head = AlignInfo(ptr);
195-
free(head.basePtr);
196-
}
197-
198-
}
199-
// DMD Win 64 bit, uses microsoft standard C library which implements them
200-
else
201-
{
202-
@nogc nothrow private extern(C) void* _aligned_malloc(size_t, size_t);
203-
@nogc nothrow private extern(C) void _aligned_free(void *memblock);
204-
@nogc nothrow private extern(C) void* _aligned_realloc(void *, size_t, size_t);
205-
}
121+
@nogc nothrow private extern(C) void* _aligned_malloc(size_t, size_t);
122+
@nogc nothrow private extern(C) void _aligned_free(void *memblock);
123+
@nogc nothrow private extern(C) void* _aligned_realloc(void *, size_t, size_t);
206124
}
207125

208126
/**
@@ -399,50 +317,3 @@ version (Posix)
399317
assert(!AlignedMallocator.instance.alignedReallocate(c, size_t.max, 4096));
400318
AlignedMallocator.instance.deallocate(c);
401319
}
402-
403-
version (CRuntime_DigitalMars)
404-
@nogc @system nothrow unittest
405-
{
406-
void* m;
407-
408-
size_t m_addr() { return cast(size_t) m; }
409-
410-
m = _aligned_malloc(16, 0x10);
411-
if (m)
412-
{
413-
assert((m_addr & 0xF) == 0);
414-
_aligned_free(m);
415-
}
416-
417-
m = _aligned_malloc(16, 0x100);
418-
if (m)
419-
{
420-
assert((m_addr & 0xFF) == 0);
421-
_aligned_free(m);
422-
}
423-
424-
m = _aligned_malloc(16, 0x1000);
425-
if (m)
426-
{
427-
assert((m_addr & 0xFFF) == 0);
428-
_aligned_free(m);
429-
}
430-
431-
m = _aligned_malloc(16, 0x10);
432-
if (m)
433-
{
434-
assert((cast(size_t) m & 0xF) == 0);
435-
m = _aligned_realloc(m, 32, 0x10000);
436-
if (m) assert((m_addr & 0xFFFF) == 0);
437-
_aligned_free(m);
438-
}
439-
440-
m = _aligned_malloc(8, 0x10);
441-
if (m)
442-
{
443-
*cast(ulong*) m = 0X01234567_89ABCDEF;
444-
m = _aligned_realloc(m, 0x800, 0x1000);
445-
if (m) assert(*cast(ulong*) m == 0X01234567_89ABCDEF);
446-
_aligned_free(m);
447-
}
448-
}

std/file.d

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4053,12 +4053,10 @@ else version (Posix)
40534053
+/
40544054
void _ensureStatDone() @trusted scope
40554055
{
4056-
import std.exception : enforce;
4057-
40584056
if (_didStat)
40594057
return;
40604058

4061-
enforce(stat(_name.tempCString(), &_statBuf) == 0,
4059+
cenforce(stat(_name.tempCString(), &_statBuf) == 0,
40624060
"Failed to stat file `" ~ _name ~ "'");
40634061

40644062
_didStat = true;
@@ -4095,13 +4093,11 @@ else version (Posix)
40954093
+/
40964094
void _ensureLStatDone() @trusted scope
40974095
{
4098-
import std.exception : enforce;
4099-
41004096
if (_didLStat)
41014097
return;
41024098

41034099
stat_t statbuf = void;
4104-
enforce(lstat(_name.tempCString(), &statbuf) == 0,
4100+
cenforce(lstat(_name.tempCString(), &statbuf) == 0,
41054101
"Failed to stat file `" ~ _name ~ "'");
41064102

41074103
_lstatMode = statbuf.st_mode;
@@ -4183,12 +4179,12 @@ else version (Posix)
41834179
assert(!de.isFile);
41844180
assert(!de.isDir);
41854181
assert(de.isSymlink);
4186-
assertThrown(de.size);
4187-
assertThrown(de.timeStatusChanged);
4188-
assertThrown(de.timeLastAccessed);
4189-
assertThrown(de.timeLastModified);
4190-
assertThrown(de.attributes);
4191-
assertThrown(de.statBuf);
4182+
assertThrown!FileException(de.size);
4183+
assertThrown!FileException(de.timeStatusChanged);
4184+
assertThrown!FileException(de.timeLastAccessed);
4185+
assertThrown!FileException(de.timeLastModified);
4186+
assertThrown!FileException(de.attributes);
4187+
assertThrown!FileException(de.statBuf);
41924188
assert(symfile.exists);
41934189
symfile.remove();
41944190
}

std/format/spec.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,21 +681,21 @@ if (is(Unqual!Char == Char))
681681
auto fmt = "Number: %6.4e\nString: %s";
682682
auto f = FormatSpec!char(fmt);
683683

684-
assert(f.writeUpToNextSpec(a) == true);
684+
assert(f.writeUpToNextSpec(a));
685685

686686
assert(a.data == "Number: ");
687687
assert(f.trailing == "\nString: %s");
688688
assert(f.spec == 'e');
689689
assert(f.width == 6);
690690
assert(f.precision == 4);
691691

692-
assert(f.writeUpToNextSpec(a) == true);
692+
assert(f.writeUpToNextSpec(a));
693693

694694
assert(a.data == "Number: \nString: ");
695695
assert(f.trailing == "");
696696
assert(f.spec == 's');
697697

698-
assert(f.writeUpToNextSpec(a) == false);
698+
assert(!f.writeUpToNextSpec(a));
699699

700700
assert(a.data == "Number: \nString: ");
701701
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/++
2+
For testing only.
3+
4+
Overload set used in std.sumtype example. Needs its own internal module so that
5+
it can be available for `make publictests` without polluting the public API.
6+
+/
7+
module std.internal.test.sumtype_example_overloads;
8+
9+
import std.sumtype;
10+
11+
@safe
12+
{
13+
string handle(int) { return "got an int"; }
14+
string handle(string) { return "got a string"; }
15+
string handle(double) { return "got a double"; }
16+
alias handle = match!handle;
17+
}

std/math/exponential.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ if (isFloatingPoint!(F) && isIntegral!(G))
256256
* If x is 0 and n is negative, the result is the same as the result of a
257257
* division by zero.
258258
*/
259-
typeof(Unqual!(F).init * Unqual!(G).init) pow(F, G)(F x, G n) @nogc @trusted pure nothrow
259+
typeof(Unqual!(F).init * Unqual!(G).init) pow(F, G)(F x, G n) @nogc @safe pure nothrow
260260
if (isIntegral!(F) && isIntegral!(G))
261261
{
262262
import std.traits : isSigned;

std/math/rounding.d

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -772,27 +772,18 @@ version (Posix)
772772
*
773773
* If the fractional part of x is exactly 0.5, the return value is rounded
774774
* away from zero.
775-
*
776-
* $(BLUE This function is not implemented for Digital Mars C runtime.)
777775
*/
778776
long lround(real x) @trusted nothrow @nogc
779777
{
780-
version (CRuntime_DigitalMars)
781-
assert(0, "lround not implemented");
782-
else
783-
return core.stdc.math.llroundl(x);
778+
return core.stdc.math.llroundl(x);
784779
}
785780

786781
///
787782
@safe nothrow @nogc unittest
788783
{
789-
version (CRuntime_DigitalMars) {}
790-
else
791-
{
792-
assert(lround(0.49) == 0);
793-
assert(lround(0.5) == 1);
794-
assert(lround(1.5) == 2);
795-
}
784+
assert(lround(0.49) == 0);
785+
assert(lround(0.5) == 1);
786+
assert(lround(1.5) == 2);
796787
}
797788

798789
/**

std/net/curl.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ private auto _basicHTTP(T)(const(char)[] url, const(void)[] sendData, HTTP clien
10631063
{
10641064
size_t minLen = min(buf.length, remainingData.length);
10651065
if (minLen == 0) return 0;
1066-
buf[0 .. minLen] = remainingData[0 .. minLen];
1066+
buf[0 .. minLen] = cast(void[]) remainingData[0 .. minLen];
10671067
remainingData = remainingData[minLen..$];
10681068
return minLen;
10691069
};
@@ -1202,7 +1202,7 @@ private auto _basicFTP(T)(const(char)[] url, const(void)[] sendData, FTP client)
12021202
{
12031203
size_t minLen = min(buf.length, sendData.length);
12041204
if (minLen == 0) return 0;
1205-
buf[0 .. minLen] = sendData[0 .. minLen];
1205+
buf[0 .. minLen] = cast(void[]) sendData[0 .. minLen];
12061206
sendData = sendData[minLen..$];
12071207
return minLen;
12081208
};

0 commit comments

Comments
 (0)