diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2025-01-05 14:24:49 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2025-01-05 14:24:49 +0100 |
commit | a676a516701789730aa482bcef4adcb683ba0140 (patch) | |
tree | 6c5b56d13162e537bae0ed373a9addf9be73af56 /libphobos | |
parent | 3dfad340cb140d64b8c0ecab05fa329238ebd06b (diff) | |
download | gcc-a676a516701789730aa482bcef4adcb683ba0140.zip gcc-a676a516701789730aa482bcef4adcb683ba0140.tar.gz gcc-a676a516701789730aa482bcef4adcb683ba0140.tar.bz2 |
d: Merge upstream dmd, druntime 07bc5b9b3c, phobos de1dea109
Synchronizing with the upstream release of v2.109.0.
D front-end changes:
- Import dmd v2.109.0.
D runtime changes:
- Import druntime v2.109.0.
Phobos changes:
- Import phobos v2.109.0.
gcc/d/ChangeLog:
* decl.cc (DeclVisitor::finish_vtable): Update for new front-end
interface.
* dmd/MERGE: Merge upstream dmd 07bc5b9b3c.
* dmd/VERSION: Bump version to v2.109.0.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime 07bc5b9b3c.
* src/MERGE: Merge upstream phobos de1dea109.
Diffstat (limited to 'libphobos')
31 files changed, 159 insertions, 1208 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index 46d435e..77e8562 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -c11e1d1708646c9ac81ac2aafb57fa1ef5d289ad +07bc5b9b3c81cc0d4314e0040de981124b363ea5 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/libphobos/libdruntime/core/attribute.d b/libphobos/libdruntime/core/attribute.d index 79ad25a..95a67ea 100644 --- a/libphobos/libdruntime/core/attribute.d +++ b/libphobos/libdruntime/core/attribute.d @@ -2,6 +2,21 @@ * This module contains UDA's (User Defined Attributes) either used in * the runtime or special UDA's recognized by compiler. * + * $(SCRIPT inhibitQuickIndex = 1;) + * $(BOOKTABLE Cheat Sheet, + * $(THEAD Attribute Name, Linkage, Description) + * $(TROW $(LREF gnuAbiTag), C++, + * Declares an ABI tag on a C++ symbol.) + * $(TROW $(LREF mustuse),, + * Ensures that values of a struct or union type are not discarded.) + * $(TROW $(LREF optional), Objective-C, + * Makes an Objective-C interface method optional.) + * $(TROW $(LREF selector), Objective-C, + * Attaches an Objective-C selector to a method.) + * $(TROW $(LREF weak),, + * Specifies that a global symbol should be emitted with weak linkage.) + * ) + * * Copyright: Copyright Jacob Carlborg 2015. * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Authors: Jacob Carlborg diff --git a/libphobos/libdruntime/core/demangle.d b/libphobos/libdruntime/core/demangle.d index 272ee1e..4405dec 100644 --- a/libphobos/libdruntime/core/demangle.d +++ b/libphobos/libdruntime/core/demangle.d @@ -2867,56 +2867,6 @@ unittest assert(demangle(aggr.mangleof) == "pure nothrow @nogc @safe void " ~ parent ~ "().aggr(" ~ parent ~ "().S!(noreturn).S)"); } -/* - * Expand an OMF, DMD-generated compressed identifier into its full form - * - * This function only has a visible effect for OMF binaries (Win32), - * as compression is otherwise not used. - * - * See_Also: `compiler/src/dmd/backend/compress.d` - */ -string decodeDmdString( const(char)[] ln, ref size_t p ) nothrow pure @safe -{ - string s; - uint zlen, zpos; - - // decompress symbol - while ( p < ln.length ) - { - int ch = cast(ubyte) ln[p++]; - if ( (ch & 0xc0) == 0xc0 ) - { - zlen = (ch & 0x7) + 1; - zpos = ((ch >> 3) & 7) + 1; // + zlen; - if ( zpos > s.length ) - break; - s ~= s[$ - zpos .. $ - zpos + zlen]; - } - else if ( ch >= 0x80 ) - { - if ( p >= ln.length ) - break; - int ch2 = cast(ubyte) ln[p++]; - zlen = (ch2 & 0x7f) | ((ch & 0x38) << 4); - if ( p >= ln.length ) - break; - int ch3 = cast(ubyte) ln[p++]; - zpos = (ch3 & 0x7f) | ((ch & 7) << 7); - if ( zpos > s.length ) - break; - s ~= s[$ - zpos .. $ - zpos + zlen]; - } - else if ( Demangle!().isAlpha(cast(char)ch) || Demangle!().isDigit(cast(char)ch) || ch == '_' ) - s ~= cast(char) ch; - else - { - p--; - break; - } - } - return s; -} - // locally purified for internal use here only extern (C) private { diff --git a/libphobos/libdruntime/core/internal/parseoptions.d b/libphobos/libdruntime/core/internal/parseoptions.d index ac0eb82..2bf1da2 100644 --- a/libphobos/libdruntime/core/internal/parseoptions.d +++ b/libphobos/libdruntime/core/internal/parseoptions.d @@ -290,32 +290,8 @@ do assert(n > 4 && n < fmt.length); int nscanned; - version (CRuntime_DigitalMars) - { - /* Older sscanf's in snn.lib can write to its first argument, causing a crash - * if the string is in readonly memory. Recent updates to DMD - * https://github.com/dlang/dmd/pull/6546 - * put string literals in readonly memory. - * Although sscanf has been fixed, - * http://ftp.digitalmars.com/snn.lib - * this workaround is here so it still works with the older snn.lib. - */ - // Create mutable copy of str - const length = str.length; - char* mptr = cast(char*)malloc(length + 1); - assert(mptr); - memcpy(mptr, str.ptr, length); - mptr[length] = 0; - const result = sscanf(mptr, fmt.ptr, &res, &nscanned); - free(mptr); - if (result < 1) - return parseError("a float", optname, str, errName); - } - else - { - if (sscanf(str.ptr, fmt.ptr, &res, &nscanned) < 1) - return parseError("a float", optname, str, errName); - } + if (sscanf(str.ptr, fmt.ptr, &res, &nscanned) < 1) + return parseError("a float", optname, str, errName); str = str[nscanned .. $]; return true; } diff --git a/libphobos/libdruntime/core/stdc/assert_.d b/libphobos/libdruntime/core/stdc/assert_.d index c6d9d9f..ac237d9 100644 --- a/libphobos/libdruntime/core/stdc/assert_.d +++ b/libphobos/libdruntime/core/stdc/assert_.d @@ -30,14 +30,7 @@ extern (C): nothrow: @nogc: -version (CRuntime_DigitalMars) -{ - /*** - * Assert failure function in the Digital Mars C library. - */ - noreturn _assert(const(void)* exp, const(void)* file, uint line); -} -else version (CRuntime_Microsoft) +version (CRuntime_Microsoft) { /*** * Assert failure function in the Microsoft C library. diff --git a/libphobos/libdruntime/core/stdc/errno.d b/libphobos/libdruntime/core/stdc/errno.d index ddec70f..0430e6b 100644 --- a/libphobos/libdruntime/core/stdc/errno.d +++ b/libphobos/libdruntime/core/stdc/errno.d @@ -43,15 +43,7 @@ version (X86_64) version = X86_Any; nothrow: @nogc: -version (CRuntime_DigitalMars) -{ - extern (C) - { - ref int _errno(); - alias errno = _errno; - } -} -else version (CRuntime_Microsoft) +version (CRuntime_Microsoft) { extern (C) { @@ -172,93 +164,7 @@ else extern (C): -version (CRuntime_DigitalMars) -{ - enum EPERM = 1; /// Operation not permitted - enum ENOENT = 2; /// No such file or directory - enum ESRCH = 3; /// No such process - enum EINTR = 4; /// Interrupted system call - enum EIO = 5; /// I/O error - enum ENXIO = 6; /// No such device or address - enum E2BIG = 7; /// Argument list too long - enum ENOEXEC = 8; /// Exec format error - enum EBADF = 9; /// Bad file number - enum ECHILD = 10; /// No child processes - enum EAGAIN = 11; /// Try again - enum ENOMEM = 12; /// Out of memory - enum EACCES = 13; /// Permission denied - enum EFAULT = 14; /// Bad address - enum EBUSY = 16; /// Device or resource busy - enum EEXIST = 17; /// File exists - enum EXDEV = 18; /// Cross-device link - enum ENODEV = 19; /// No such device - enum ENOTDIR = 20; /// Not a directory - enum EISDIR = 21; /// Is a directory - enum EINVAL = 22; /// Invalid argument - enum ENFILE = 23; /// File table overflow - enum EMFILE = 24; /// Too many open files - enum ENOTTY = 25; /// Not a typewriter - enum EFBIG = 27; /// File too large - enum ENOSPC = 28; /// No space left on device - enum ESPIPE = 29; /// Illegal seek - enum EROFS = 30; /// Read-only file system - enum EMLINK = 31; /// Too many links - enum EPIPE = 32; /// Broken pipe - enum EDOM = 33; /// Math argument out of domain of func - enum ERANGE = 34; /// Math result not representable - enum EDEADLK = 36; /// Resource deadlock would occur - enum ENAMETOOLONG = 38; /// File name too long - enum ENOLCK = 39; /// No record locks available - enum ENOSYS = 40; /// Function not implemented - enum ENOTEMPTY = 41; /// Directory not empty - enum EILSEQ = 42; /// Illegal byte sequence - enum EDEADLOCK = EDEADLK; /// Resource deadlock would occur - - // POSIX compatibility - // See_Also: https://docs.microsoft.com/en-us/cpp/c-runtime-library/errno-constants - enum EADDRINUSE = 100; - enum EADDRNOTAVAIL = 101; - enum EAFNOSUPPORT = 102; - enum EALREADY = 103; - enum EBADMSG = 104; - enum ECANCELED = 105; - enum ECONNABORTED = 106; - enum ECONNREFUSED = 107; - enum ECONNRESET = 108; - enum EDESTADDRREQ = 109; - enum EHOSTUNREACH = 110; - enum EIDRM = 111; - enum EINPROGRESS = 112; - enum EISCONN = 113; - enum ELOOP = 114; - enum EMSGSIZE = 115; - enum ENETDOWN = 116; - enum ENETRESET = 117; - enum ENETUNREACH = 118; - enum ENOBUFS = 119; - enum ENODATA = 120; - enum ENOLINK = 121; - enum ENOMSG = 122; - enum ENOPROTOOPT = 123; - enum ENOSR = 124; - enum ENOSTR = 125; - enum ENOTCONN = 126; - enum ENOTRECOVERABLE = 127; - enum ENOTSOCK = 128; - enum ENOTSUP = 129; - enum EOPNOTSUPP = 130; - enum EOTHER = 131; - enum EOVERFLOW = 132; - enum EOWNERDEAD = 133; - enum EPROTO = 134; - enum EPROTONOSUPPORT = 135; - enum EPROTOTYPE = 136; - enum ETIME = 137; - enum ETIMEDOUT = 138; - enum ETXTBSY = 139; - enum EWOULDBLOCK = 140; -} -else version (CRuntime_Microsoft) +version (CRuntime_Microsoft) { enum EPERM = 1; /// Operation not permitted enum ENOENT = 2; /// No such file or directory diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d index a7364c0..6cd75f3 100644 --- a/libphobos/libdruntime/core/stdc/fenv.d +++ b/libphobos/libdruntime/core/stdc/fenv.d @@ -180,17 +180,6 @@ version (GNUFP) static assert(0, "Unimplemented architecture"); } } -else version (CRuntime_DigitalMars) -{ - struct fenv_t - { - ushort status; - ushort control; - ushort round; - ushort[2] reserved; - } - alias fexcept_t = int; -} else version (CRuntime_Microsoft) { struct fenv_t @@ -872,12 +861,6 @@ version (GNUFP) /// enum FE_DFL_ENV = cast(fenv_t*)(-1); } -else version (CRuntime_DigitalMars) -{ - private extern __gshared fenv_t _FE_DFL_ENV; - /// - enum fenv_t* FE_DFL_ENV = &_FE_DFL_ENV; -} else version (CRuntime_Microsoft) { private extern __gshared fenv_t _Fenv0; diff --git a/libphobos/libdruntime/core/stdc/math.d b/libphobos/libdruntime/core/stdc/math.d index c5eaf79..e54d581 100644 --- a/libphobos/libdruntime/core/stdc/math.d +++ b/libphobos/libdruntime/core/stdc/math.d @@ -284,102 +284,7 @@ version (none) pure int isunordered(real x, real y); } -version (CRuntime_DigitalMars) -{ - enum - { - /// - FP_NANS = 0, - /// - FP_NANQ = 1, - /// - FP_INFINITE = 2, - /// - FP_NORMAL = 3, - /// - FP_SUBNORMAL = 4, - /// - FP_ZERO = 5, - /// - FP_NAN = FP_NANQ, - /// - FP_EMPTY = 6, - /// - FP_UNSUPPORTED = 7, - } - - enum - { - /// - FP_FAST_FMA = 0, - /// - FP_FAST_FMAF = 0, - /// - FP_FAST_FMAL = 0, - } - - pure uint __fpclassify_f(float x); - pure uint __fpclassify_d(double x); - pure uint __fpclassify_ld(real x); - - //int fpclassify(real-floating x); - /// - pragma(mangle, "__fpclassify_f") pure int fpclassify(float x); - /// - pragma(mangle, "__fpclassify_d") pure int fpclassify(double x); - /// - pragma(mangle, real.sizeof == double.sizeof ? "__fpclassify_d" : "__fpclassify_ld") - pure int fpclassify(real x); - - extern (D) - { - //int isfinite(real-floating x); - /// - pure int isfinite(float x) { return fpclassify(x) >= FP_NORMAL; } - /// - pure int isfinite(double x) { return fpclassify(x) >= FP_NORMAL; } - /// - pure int isfinite(real x) { return fpclassify(x) >= FP_NORMAL; } - - //int isinf(real-floating x); - /// - pure int isinf(float x) { return fpclassify(x) == FP_INFINITE; } - /// - pure int isinf(double x) { return fpclassify(x) == FP_INFINITE; } - /// - pure int isinf(real x) { return fpclassify(x) == FP_INFINITE; } - - //int isnan(real-floating x); - /// - pure int isnan(float x) { return fpclassify(x) <= FP_NANQ; } - /// - pure int isnan(double x) { return fpclassify(x) <= FP_NANQ; } - /// - pure int isnan(real x) { return fpclassify(x) <= FP_NANQ; } - - //int isnormal(real-floating x); - /// - pure int isnormal(float x) { return fpclassify(x) == FP_NORMAL; } - /// - pure int isnormal(double x) { return fpclassify(x) == FP_NORMAL; } - /// - pure int isnormal(real x) { return fpclassify(x) == FP_NORMAL; } - - //int signbit(real-floating x); - /// - pure int signbit(float x) { return (cast(short*)&(x))[1] & 0x8000; } - /// - pure int signbit(double x) { return (cast(short*)&(x))[3] & 0x8000; } - /// - pure int signbit(real x) - { - return (real.sizeof == double.sizeof) - ? (cast(short*)&(x))[3] & 0x8000 - : (cast(short*)&(x))[4] & 0x8000; - } - } -} -else version (CRuntime_Microsoft) // fully supported since MSVCRT 12 (VS 2013) only +version (CRuntime_Microsoft) // fully supported since MSVCRT 12 (VS 2013) only { version (all) // legacy stuff to be removed in the future { diff --git a/libphobos/libdruntime/core/stdc/stdint.d b/libphobos/libdruntime/core/stdc/stdint.d index 476c42f..1776269 100644 --- a/libphobos/libdruntime/core/stdc/stdint.d +++ b/libphobos/libdruntime/core/stdc/stdint.d @@ -49,16 +49,8 @@ version (Windows) alias int16_t = short; /// alias uint8_t = ubyte; /// alias uint16_t = ushort; /// - version (CRuntime_DigitalMars) - { - alias int32_t = cpp_long; /// - alias uint32_t = cpp_ulong; /// - } - else - { - alias int32_t = int; /// - alias uint32_t = uint; /// - } + alias int32_t = int; /// + alias uint32_t = uint; /// alias int64_t = long; /// alias uint64_t = ulong; /// diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d index 1fc0461..8afb68f 100644 --- a/libphobos/libdruntime/core/stdc/stdio.d +++ b/libphobos/libdruntime/core/stdc/stdio.d @@ -52,34 +52,7 @@ extern (C): nothrow: @nogc: -version (CRuntime_DigitalMars) -{ - enum - { - /// - BUFSIZ = 0x4000, - /// - EOF = -1, - /// - FOPEN_MAX = 20, - /// - FILENAME_MAX = 256, // 255 plus NULL - /// - TMP_MAX = 32767, - /// - SYS_OPEN = 20, // non-standard - } - - /// - enum int _NFILE = 60; // non-standard - /// - enum string _P_tmpdir = "\\"; // non-standard - /// - enum wstring _wP_tmpdir = "\\"; // non-standard - /// - enum int L_tmpnam = _P_tmpdir.length + 12; -} -else version (CRuntime_Microsoft) +version (CRuntime_Microsoft) { enum { @@ -403,28 +376,7 @@ enum SEEK_END } -version (CRuntime_DigitalMars) -{ - /// - alias c_long fpos_t; - - /// - struct _iobuf - { - char* _ptr; - int _cnt; - char* _base; - int _flag; - int _file; - int _charbuf; - int _bufsiz; - char* __tmpnum; - } - - /// - alias shared(_iobuf) FILE; -} -else version (CRuntime_Microsoft) +version (CRuntime_Microsoft) { /// alias long fpos_t; @@ -926,52 +878,7 @@ enum _F_TERM = 0x0200, // non-standard } -version (CRuntime_DigitalMars) -{ - enum - { - /// - _IOFBF = 0, - /// - _IOLBF = 0x40, - /// - _IONBF = 4, - /// - _IOREAD = 1, // non-standard - /// - _IOWRT = 2, // non-standard - /// - _IOMYBUF = 8, // non-standard - /// - _IOEOF = 0x10, // non-standard - /// - _IOERR = 0x20, // non-standard - /// - _IOSTRG = 0x40, // non-standard - /// - _IORW = 0x80, // non-standard - /// - _IOTRAN = 0x100, // non-standard - /// - _IOAPP = 0x200, // non-standard - } - - extern shared void function() _fcloseallp; - - private extern shared FILE[_NFILE] _iob; - - /// - enum stdin = &_iob[0]; - /// - enum stdout = &_iob[1]; - /// - enum stderr = &_iob[2]; - /// - enum stdaux = &_iob[3]; - /// - enum stdprn = &_iob[4]; -} -else version (CRuntime_Microsoft) +version (CRuntime_Microsoft) { enum { @@ -1539,55 +1446,7 @@ size_t fwrite(scope const void* ptr, size_t size, size_t nmemb, FILE* stream); c_long ftell(FILE* stream); } -version (CRuntime_DigitalMars) -{ - // No unsafe pointer manipulation. - extern (D) @trusted - { - /// - void rewind()(FILE* stream) { fseek(stream,0L,SEEK_SET); stream._flag= stream._flag & ~_IOERR; } - /// - pure void clearerr()(FILE* stream) { stream._flag = stream._flag & ~(_IOERR|_IOEOF); } - /// - pure int feof()(FILE* stream) { return stream._flag&_IOEOF; } - /// - pure int ferror()(FILE* stream) { return stream._flag&_IOERR; } - /// - pure int fileno()(FILE* stream) { return stream._file; } - } - /// - pragma(printf) - int _snprintf(scope char* s, size_t n, scope const char* fmt, scope const ...); - /// - alias _snprintf snprintf; - - /// - pragma(printf) - int _vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); - /// - alias _vsnprintf vsnprintf; - - // - // Digital Mars under-the-hood C I/O functions. Uses _iobuf* for the - // unshared version of FILE*, usable when the FILE is locked. - // - - /// - int _fputc_nlock(int c, _iobuf* fp); - /// - int _fputwc_nlock(int c, _iobuf* fp); - /// - int _fgetc_nlock(_iobuf* fp); - /// - int _fgetwc_nlock(_iobuf* fp); - /// - int __fp_lock(FILE* fp); - /// - void __fp_unlock(FILE* fp); - /// - int setmode(int fd, int mode); -} -else version (CRuntime_Microsoft) +version (CRuntime_Microsoft) { // No unsafe pointer manipulation. @trusted @@ -2073,130 +1932,7 @@ else /// void perror(scope const char* s); -version (CRuntime_DigitalMars) -{ - version (none) - import core.sys.windows.windows : HANDLE, _WaitSemaphore, _ReleaseSemaphore; - else - { - // too slow to import windows - private alias void* HANDLE; - private void _WaitSemaphore(int iSemaphore); - private void _ReleaseSemaphore(int iSemaphore); - } - - enum - { - /// - FHND_APPEND = 0x04, - /// - FHND_DEVICE = 0x08, - /// - FHND_TEXT = 0x10, - /// - FHND_BYTE = 0x20, - /// - FHND_WCHAR = 0x40, - } - - private enum _MAX_SEMAPHORES = 10 + _NFILE; - private enum _semIO = 3; - - private extern __gshared short[_MAX_SEMAPHORES] _iSemLockCtrs; - private extern __gshared int[_MAX_SEMAPHORES] _iSemThreadIds; - private extern __gshared int[_MAX_SEMAPHORES] _iSemNestCount; - private extern __gshared HANDLE[_NFILE] _osfhnd; - extern shared ubyte[_NFILE] __fhnd_info; - - // this is copied from semlock.h in DMC's runtime. - private void LockSemaphore()(uint num) - { - asm nothrow @nogc - { - mov EDX, num; - lock; - inc _iSemLockCtrs[EDX * 2]; - jz lsDone; - push EDX; - call _WaitSemaphore; - add ESP, 4; - } - - lsDone: {} - } - - // this is copied from semlock.h in DMC's runtime. - private void UnlockSemaphore()(uint num) - { - asm nothrow @nogc - { - mov EDX, num; - lock; - dec _iSemLockCtrs[EDX * 2]; - js usDone; - push EDX; - call _ReleaseSemaphore; - add ESP, 4; - } - - usDone: {} - } - - // This converts a HANDLE to a file descriptor in DMC's runtime - /// - int _handleToFD()(HANDLE h, int flags) - { - LockSemaphore(_semIO); - scope(exit) UnlockSemaphore(_semIO); - - foreach (fd; 0 .. _NFILE) - { - if (!_osfhnd[fd]) - { - _osfhnd[fd] = h; - __fhnd_info[fd] = cast(ubyte)flags; - return fd; - } - } - - return -1; - } - - /// - HANDLE _fdToHandle()(int fd) - { - // no semaphore is required, once inserted, a file descriptor - // doesn't change. - if (fd < 0 || fd >= _NFILE) - return null; - - return _osfhnd[fd]; - } - - enum - { - /// - STDIN_FILENO = 0, - /// - STDOUT_FILENO = 1, - /// - STDERR_FILENO = 2, - } - - int open(scope const(char)* filename, int flags, ...); /// - alias _open = open; /// - int _wopen(scope const wchar* filename, int oflag, ...); /// - int sopen(scope const char* filename, int oflag, int shflag, ...); /// - alias _sopen = sopen; /// - int _wsopen(scope const wchar* filename, int oflag, int shflag, ...); /// - int close(int fd); /// - alias _close = close; /// - FILE *fdopen(int fd, scope const(char)* flags); /// - alias _fdopen = fdopen; /// - FILE *_wfdopen(int fd, scope const(wchar)* flags); /// - -} -else version (CRuntime_Microsoft) +version (CRuntime_Microsoft) { int _open(scope const char* filename, int oflag, ...); /// int _wopen(scope const wchar* filename, int oflag, ...); /// diff --git a/libphobos/libdruntime/core/stdcpp/array.d b/libphobos/libdruntime/core/stdcpp/array.d index eb63d4c..4cb0c56 100644 --- a/libphobos/libdruntime/core/stdcpp/array.d +++ b/libphobos/libdruntime/core/stdcpp/array.d @@ -13,17 +13,6 @@ module core.stdcpp.array; import core.stdcpp.xutility : StdNamespace; -// hacks to support DMD on Win32 -version (CppRuntime_Microsoft) -{ - version = CppRuntime_Windows; // use the MS runtime ABI for win32 -} -else version (CppRuntime_DigitalMars) -{ - version = CppRuntime_Windows; // use the MS runtime ABI for win32 - pragma(msg, "std::array not supported by DMC"); -} - extern(C++, (StdNamespace)): /** @@ -73,7 +62,7 @@ pure nothrow @nogc: /// ref inout(T) back() inout @safe { static if (N > 0) { return this[N-1]; } else { return as_array()[][0]; /* HACK: force OOB */ } } - version (CppRuntime_Windows) + version (CppRuntime_Microsoft) { /// inout(T)* data() inout @safe { return &_Elems[0]; } diff --git a/libphobos/libdruntime/core/stdcpp/exception.d b/libphobos/libdruntime/core/stdcpp/exception.d index d533996..4774b98 100644 --- a/libphobos/libdruntime/core/stdcpp/exception.d +++ b/libphobos/libdruntime/core/stdcpp/exception.d @@ -80,24 +80,6 @@ version (GenericBaseException) extern(D) this(const(char)*, int = 1) nothrow { this(); } // compat with MS derived classes } } -else version (CppRuntime_DigitalMars) -{ - /// - class exception - { - @nogc: - /// - extern(D) this() nothrow {} - //virtual ~this(); - void dtor() { } // reserve slot in vtbl[] - - /// - const(char)* what() const nothrow; - - protected: - this(const(char)*, int = 1) nothrow { this(); } // compat with MS derived classes - } -} else version (CppRuntime_Microsoft) { /// diff --git a/libphobos/libdruntime/core/stdcpp/string_view.d b/libphobos/libdruntime/core/stdcpp/string_view.d index 172c170..47f58b0 100644 --- a/libphobos/libdruntime/core/stdcpp/string_view.d +++ b/libphobos/libdruntime/core/stdcpp/string_view.d @@ -14,17 +14,6 @@ module core.stdcpp.string_view; import core.stdc.stddef : wchar_t; import core.stdcpp.xutility : StdNamespace; -// hacks to support DMD on Win32 -version (CppRuntime_Microsoft) -{ - version = CppRuntime_Windows; // use the MS runtime ABI for win32 -} -else version (CppRuntime_DigitalMars) -{ - version = CppRuntime_Windows; // use the MS runtime ABI for win32 - pragma(msg, "std::basic_string_view not supported by DMC"); -} - extern(C++, (StdNamespace)): @nogc: @@ -102,7 +91,7 @@ pure nothrow @nogc: private: // use the proper field names from C++ so debugging doesn't get weird - version (CppRuntime_Windows) + version (CppRuntime_Microsoft) { const_pointer _Mydata; size_type _Mysize; diff --git a/libphobos/libdruntime/core/stdcpp/typeinfo.d b/libphobos/libdruntime/core/stdcpp/typeinfo.d index 24f2938..b8478b3 100644 --- a/libphobos/libdruntime/core/stdcpp/typeinfo.d +++ b/libphobos/libdruntime/core/stdcpp/typeinfo.d @@ -13,53 +13,7 @@ module core.stdcpp.typeinfo; import core.attribute : weak; -version (CppRuntime_DigitalMars) -{ - import core.stdcpp.exception; - - extern (C++, "std"): - - class type_info - { - @nogc: - void* pdata; - - public: - //virtual ~this(); - void dtor() { } // reserve slot in vtbl[] - - //bool operator==(const type_info rhs) const; - //bool operator!=(const type_info rhs) const; - final bool before(const type_info rhs) const nothrow; - final const(char)* name() const nothrow; - protected: - //type_info(); - private: - //this(const type_info rhs); - //type_info operator=(const type_info rhs); - } - - class bad_cast : exception - { - @nogc: - extern(D) this() nothrow { } - extern(D) this(const bad_cast) nothrow { } - //bad_cast operator=(const bad_cast) nothrow { return this; } - //virtual ~this() nothrow; - override const(char)* what() const nothrow; - } - - class bad_typeid : exception - { - @nogc: - extern(D) this() nothrow { } - extern(D) this(const bad_typeid) nothrow { } - //bad_typeid operator=(const bad_typeid) nothrow { return this; } - //virtual ~this() nothrow; - override const (char)* what() const nothrow; - } -} -else version (CppRuntime_Microsoft) +version (CppRuntime_Microsoft) { import core.stdcpp.exception; diff --git a/libphobos/libdruntime/core/sys/windows/dll.d b/libphobos/libdruntime/core/sys/windows/dll.d index 77141d5..6a003b5 100644 --- a/libphobos/libdruntime/core/sys/windows/dll.d +++ b/libphobos/libdruntime/core/sys/windows/dll.d @@ -32,13 +32,7 @@ extern (C) { version (Win32) { - version (CRuntime_DigitalMars) - { - extern __gshared byte _tlsstart; - extern __gshared byte _tlsend; - extern __gshared void* _tls_callbacks_a; - } - else version (CRuntime_Microsoft) + version (CRuntime_Microsoft) { extern __gshared byte _tls_start; extern __gshared byte _tls_end; diff --git a/libphobos/libdruntime/core/sys/windows/stacktrace.d b/libphobos/libdruntime/core/sys/windows/stacktrace.d index a73fc9c..29ffc1b 100644 --- a/libphobos/libdruntime/core/sys/windows/stacktrace.d +++ b/libphobos/libdruntime/core/sys/windows/stacktrace.d @@ -309,13 +309,6 @@ private: auto res = formatStackFrame(pc); res ~= " in "; const(char)[] tempSymName = symName[0 .. strlen(symName)]; - // Deal with dmd mangling of long names for OMF 32 bits builds - // Note that `target.d` only defines `CRuntime_DigitalMars` for OMF builds - version (CRuntime_DigitalMars) - { - size_t decodeIndex = 0; - tempSymName = decodeDmdString(tempSymName, decodeIndex); - } res ~= demangle(tempSymName, demangleBuf); return res; } @@ -339,34 +332,6 @@ private: } -// Workaround OPTLINK bug (Bugzilla 8263) -extern(Windows) BOOL FixupDebugHeader(HANDLE hProcess, ULONG ActionCode, - ulong CallbackContext, ulong UserContext) -{ - if (ActionCode == CBA_READ_MEMORY) - { - auto p = cast(IMAGEHLP_CBA_READ_MEMORY*)CallbackContext; - if (!(p.addr & 0xFF) && p.bytes == 0x1C && - // IMAGE_DEBUG_DIRECTORY.PointerToRawData - (*cast(DWORD*)(p.addr + 24) & 0xFF) == 0x20) - { - immutable base = DbgHelp.get().SymGetModuleBase64(hProcess, p.addr); - // IMAGE_DEBUG_DIRECTORY.AddressOfRawData - if (base + *cast(DWORD*)(p.addr + 20) == p.addr + 0x1C && - *cast(DWORD*)(p.addr + 0x1C) == 0 && - *cast(DWORD*)(p.addr + 0x20) == ('N'|'B'<<8|'0'<<16|'9'<<24)) - { - debug(PRINTF) printf("fixup IMAGE_DEBUG_DIRECTORY.AddressOfRawData\n"); - memcpy(p.buf, cast(void*)p.addr, 0x1C); - *cast(DWORD*)(p.buf + 20) = cast(DWORD)(p.addr - base) + 0x20; - *p.bytesread = 0x1C; - return TRUE; - } - } - } - return FALSE; -} - private string generateSearchPath() { __gshared string[3] defaultPathList = ["_NT_SYMBOL_PATH", @@ -427,8 +392,6 @@ shared static this() if (!dbghelp.SymInitialize(hProcess, generateSearchPath().ptr, TRUE)) return; - dbghelp.SymRegisterCallback64(hProcess, &FixupDebugHeader, 0); - InitializeCriticalSection(&mutex); initialized = true; } diff --git a/libphobos/libdruntime/core/sys/windows/stat.d b/libphobos/libdruntime/core/sys/windows/stat.d index c87c749..85ed24f 100644 --- a/libphobos/libdruntime/core/sys/windows/stat.d +++ b/libphobos/libdruntime/core/sys/windows/stat.d @@ -31,29 +31,7 @@ int S_ISDIR(int m) { return (m & S_IFMT) == S_IFDIR; } int S_ISCHR(int m) { return (m & S_IFMT) == S_IFCHR; } } -version (CRuntime_DigitalMars) -{ - struct struct_stat - { - short st_dev; - ushort st_ino; - ushort st_mode; - short st_nlink; - ushort st_uid; - ushort st_gid; - short st_rdev; - short dummy; - int st_size; - time_t st_atime; - time_t st_mtime; - time_t st_ctime; - } - - int stat(const(char)*, struct_stat *); - int fstat(int, struct_stat *) @trusted; - int _wstat(const(wchar)*, struct_stat *); -} -else version (CRuntime_Microsoft) +version (CRuntime_Microsoft) { struct struct_stat { diff --git a/libphobos/libdruntime/rt/monitor_.d b/libphobos/libdruntime/rt/monitor_.d index c1f3f3c..cbe2a48 100644 --- a/libphobos/libdruntime/rt/monitor_.d +++ b/libphobos/libdruntime/rt/monitor_.d @@ -173,10 +173,6 @@ alias DEvent = void delegate(Object); version (Windows) { - version (CRuntime_DigitalMars) - { - pragma(lib, "snn.lib"); - } import core.sys.windows.winbase /+: CRITICAL_SECTION, DeleteCriticalSection, EnterCriticalSection, InitializeCriticalSection, LeaveCriticalSection+/; diff --git a/libphobos/libdruntime/rt/sections.d b/libphobos/libdruntime/rt/sections.d index 65f5789..6a15552 100644 --- a/libphobos/libdruntime/rt/sections.d +++ b/libphobos/libdruntime/rt/sections.d @@ -54,8 +54,6 @@ else version (Darwin) else static assert(0, "unimplemented"); } -else version (CRuntime_DigitalMars) - public import rt.sections_win32; else version (CRuntime_Microsoft) public import rt.sections_win64; else version (CRuntime_Bionic) diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index b71e3dd..a431ca1 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -303b9c9f7c6457a4f31e7444d5ff0315ba97c704 +de1dea109f40fe4a551578369c474e48845daec1 The first line of this file holds the git revision number of the last merge done from the dlang/phobos repository. diff --git a/libphobos/src/std/algorithm/searching.d b/libphobos/src/std/algorithm/searching.d index 2d89dea..42a9df5 100644 --- a/libphobos/src/std/algorithm/searching.d +++ b/libphobos/src/std/algorithm/searching.d @@ -3873,6 +3873,21 @@ if (isInputRange!Range && !isInfinite!Range && assert([BigInt(2), BigInt(3)].maxElement == BigInt(3)); } +// https://issues.dlang.org/show_bug.cgi?id=24596 +@safe unittest +{ + static class A { + int i; + int getI() @safe => i; + this(int i) @safe { this.i = i; } + } + auto arr = [new A(2), new A(3)]; + + arr.maxElement!(a => a.getI); + + assert(arr[0].getI == 2); +} + // minPos /** Computes a subrange of `range` starting at the first occurrence of `range`'s diff --git a/libphobos/src/std/bitmanip.d b/libphobos/src/std/bitmanip.d index de2ff31..639b821 100644 --- a/libphobos/src/std/bitmanip.d +++ b/libphobos/src/std/bitmanip.d @@ -805,6 +805,7 @@ private struct FloatingPointRepresentation(T) Allows manipulating the fraction, exponent, and sign parts of a `float` separately. The definition is: +$(RUNNABLE_EXAMPLE ---- struct FloatRep { @@ -819,6 +820,7 @@ struct FloatRep enum uint bias = 127, fractionBits = 23, exponentBits = 8, signBits = 1; } ---- +) */ alias FloatRep = FloatingPointRepresentation!float; @@ -874,6 +876,7 @@ alias FloatRep = FloatingPointRepresentation!float; Allows manipulating the fraction, exponent, and sign parts of a `double` separately. The definition is: +$(RUNNABLE_EXAMPLE ---- struct DoubleRep { @@ -888,6 +891,7 @@ struct DoubleRep enum uint bias = 1023, signBits = 1, fractionBits = 52, exponentBits = 11; } ---- +) */ alias DoubleRep = FloatingPointRepresentation!double; @@ -1050,6 +1054,8 @@ public: of a type different than `size_t`, firstly because its length should be a multiple of `size_t.sizeof`, and secondly because how the bits are mapped: + + $(RUNNABLE_EXAMPLE --- size_t[] source = [1, 2, 3, 3424234, 724398, 230947, 389492]; enum sbits = size_t.sizeof * 8; @@ -1060,6 +1066,7 @@ public: assert(ba[n] == nth_bit); } --- + ) The least significant bit in any `size_t` unit is the starting bit of this unit, and the most significant bit is the last bit of this unit. Therefore, passing e.g. an array of `int`s may result in a different `BitArray` diff --git a/libphobos/src/std/experimental/allocator/mallocator.d b/libphobos/src/std/experimental/allocator/mallocator.d index 02d5cf8..3d4dc9a 100644 --- a/libphobos/src/std/experimental/allocator/mallocator.d +++ b/libphobos/src/std/experimental/allocator/mallocator.d @@ -116,93 +116,11 @@ struct Mallocator test!Mallocator(); } -version (Windows) +version (CRuntime_Microsoft) { - // DMD Win 32 bit, DigitalMars C standard library misses the _aligned_xxx - // functions family (snn.lib) - version (CRuntime_DigitalMars) - { - // Helper to cast the infos written before the aligned pointer - // this header keeps track of the size (required to realloc) and of - // the base ptr (required to free). - private struct AlignInfo - { - void* basePtr; - size_t size; - - @nogc nothrow - static AlignInfo* opCall(void* ptr) - { - return cast(AlignInfo*) (ptr - AlignInfo.sizeof); - } - } - - @nogc nothrow - private void* _aligned_malloc(size_t size, size_t alignment) - { - import core.stdc.stdlib : malloc; - size_t offset = alignment + size_t.sizeof * 2 - 1; - - // unaligned chunk - void* basePtr = malloc(size + offset); - if (!basePtr) return null; - - // get aligned location within the chunk - void* alignedPtr = cast(void**)((cast(size_t)(basePtr) + offset) - & ~(alignment - 1)); - - // write the header before the aligned pointer - AlignInfo* head = AlignInfo(alignedPtr); - head.basePtr = basePtr; - head.size = size; - - return alignedPtr; - } - - @nogc nothrow - private void* _aligned_realloc(void* ptr, size_t size, size_t alignment) - { - import core.stdc.stdlib : free; - import core.stdc.string : memcpy; - - if (!ptr) return _aligned_malloc(size, alignment); - - // gets the header from the exising pointer - AlignInfo* head = AlignInfo(ptr); - - // gets a new aligned pointer - void* alignedPtr = _aligned_malloc(size, alignment); - if (!alignedPtr) - { - //to https://msdn.microsoft.com/en-us/library/ms235462.aspx - //see Return value: in this case the original block is unchanged - return null; - } - - // copy exising data - memcpy(alignedPtr, ptr, head.size); - free(head.basePtr); - - return alignedPtr; - } - - @nogc nothrow - private void _aligned_free(void *ptr) - { - import core.stdc.stdlib : free; - if (!ptr) return; - AlignInfo* head = AlignInfo(ptr); - free(head.basePtr); - } - - } - // DMD Win 64 bit, uses microsoft standard C library which implements them - else - { - @nogc nothrow private extern(C) void* _aligned_malloc(size_t, size_t); - @nogc nothrow private extern(C) void _aligned_free(void *memblock); - @nogc nothrow private extern(C) void* _aligned_realloc(void *, size_t, size_t); - } + @nogc nothrow private extern(C) void* _aligned_malloc(size_t, size_t); + @nogc nothrow private extern(C) void _aligned_free(void *memblock); + @nogc nothrow private extern(C) void* _aligned_realloc(void *, size_t, size_t); } /** @@ -399,50 +317,3 @@ version (Posix) assert(!AlignedMallocator.instance.alignedReallocate(c, size_t.max, 4096)); AlignedMallocator.instance.deallocate(c); } - -version (CRuntime_DigitalMars) -@nogc @system nothrow unittest -{ - void* m; - - size_t m_addr() { return cast(size_t) m; } - - m = _aligned_malloc(16, 0x10); - if (m) - { - assert((m_addr & 0xF) == 0); - _aligned_free(m); - } - - m = _aligned_malloc(16, 0x100); - if (m) - { - assert((m_addr & 0xFF) == 0); - _aligned_free(m); - } - - m = _aligned_malloc(16, 0x1000); - if (m) - { - assert((m_addr & 0xFFF) == 0); - _aligned_free(m); - } - - m = _aligned_malloc(16, 0x10); - if (m) - { - assert((cast(size_t) m & 0xF) == 0); - m = _aligned_realloc(m, 32, 0x10000); - if (m) assert((m_addr & 0xFFFF) == 0); - _aligned_free(m); - } - - m = _aligned_malloc(8, 0x10); - if (m) - { - *cast(ulong*) m = 0X01234567_89ABCDEF; - m = _aligned_realloc(m, 0x800, 0x1000); - if (m) assert(*cast(ulong*) m == 0X01234567_89ABCDEF); - _aligned_free(m); - } -} diff --git a/libphobos/src/std/file.d b/libphobos/src/std/file.d index 1db779b..2a0d139 100644 --- a/libphobos/src/std/file.d +++ b/libphobos/src/std/file.d @@ -4053,12 +4053,10 @@ else version (Posix) +/ void _ensureStatDone() @trusted scope { - import std.exception : enforce; - if (_didStat) return; - enforce(stat(_name.tempCString(), &_statBuf) == 0, + cenforce(stat(_name.tempCString(), &_statBuf) == 0, "Failed to stat file `" ~ _name ~ "'"); _didStat = true; @@ -4095,13 +4093,11 @@ else version (Posix) +/ void _ensureLStatDone() @trusted scope { - import std.exception : enforce; - if (_didLStat) return; stat_t statbuf = void; - enforce(lstat(_name.tempCString(), &statbuf) == 0, + cenforce(lstat(_name.tempCString(), &statbuf) == 0, "Failed to stat file `" ~ _name ~ "'"); _lstatMode = statbuf.st_mode; @@ -4183,12 +4179,12 @@ else version (Posix) assert(!de.isFile); assert(!de.isDir); assert(de.isSymlink); - assertThrown(de.size); - assertThrown(de.timeStatusChanged); - assertThrown(de.timeLastAccessed); - assertThrown(de.timeLastModified); - assertThrown(de.attributes); - assertThrown(de.statBuf); + assertThrown!FileException(de.size); + assertThrown!FileException(de.timeStatusChanged); + assertThrown!FileException(de.timeLastAccessed); + assertThrown!FileException(de.timeLastModified); + assertThrown!FileException(de.attributes); + assertThrown!FileException(de.statBuf); assert(symfile.exists); symfile.remove(); } diff --git a/libphobos/src/std/math/hardware.d b/libphobos/src/std/math/hardware.d index dec8fdd..03e5463 100644 --- a/libphobos/src/std/math/hardware.d +++ b/libphobos/src/std/math/hardware.d @@ -222,7 +222,7 @@ private: uint result = void; asm pure nothrow @nogc { - "movfcsr2gr %0,$r2" : "=r" (result); + "movfcsr2gr %0, $fcsr2" : "=r" (result); } return result & EXCEPTIONS_MASK; } @@ -1047,7 +1047,7 @@ private: ControlState cont; asm pure nothrow @nogc { - "movfcsr2gr %0,$r0" : "=r" (cont); + "movfcsr2gr %0, $fcsr0" : "=r" (cont); } cont &= (roundingMask | allExceptions); return cont; diff --git a/libphobos/src/std/math/rounding.d b/libphobos/src/std/math/rounding.d index f6654fc..a65e393 100644 --- a/libphobos/src/std/math/rounding.d +++ b/libphobos/src/std/math/rounding.d @@ -776,27 +776,18 @@ version (Posix) * * If the fractional part of x is exactly 0.5, the return value is rounded * away from zero. - * - * $(BLUE This function is not implemented for Digital Mars C runtime.) */ long lround(real x) @trusted nothrow @nogc { - version (CRuntime_DigitalMars) - assert(0, "lround not implemented"); - else - return core.stdc.math.llroundl(x); + return core.stdc.math.llroundl(x); } /// @safe nothrow @nogc unittest { - version (CRuntime_DigitalMars) {} - else - { - assert(lround(0.49) == 0); - assert(lround(0.5) == 1); - assert(lround(1.5) == 2); - } + assert(lround(0.49) == 0); + assert(lround(0.5) == 1); + assert(lround(1.5) == 2); } /** diff --git a/libphobos/src/std/process.d b/libphobos/src/std/process.d index 325689b..d178374 100644 --- a/libphobos/src/std/process.d +++ b/libphobos/src/std/process.d @@ -127,26 +127,19 @@ else version (WatchOS) version = iOSDerived; } -// When the DMC runtime is used, we have to use some custom functions -// to convert between Windows file handles and FILE*s. -version (Win32) version (CRuntime_DigitalMars) version = DMC_RUNTIME; - // Some of the following should be moved to druntime. private { // Microsoft Visual C Runtime (MSVCRT) declarations. - version (Windows) + version (CRuntime_Microsoft) { - version (DMC_RUNTIME) { } else + import core.stdc.stdint; + enum { - import core.stdc.stdint; - enum - { - STDIN_FILENO = 0, - STDOUT_FILENO = 1, - STDERR_FILENO = 2, - } + STDIN_FILENO = 0, + STDOUT_FILENO = 1, + STDERR_FILENO = 2, } } @@ -350,6 +343,8 @@ static: */ bool opBinaryRight(string op : "in")(scope const(char)[] name) @trusted { + if (name is null) + return false; version (Posix) return core.sys.posix.stdlib.getenv(name.tempCString()) !is null; else version (Windows) @@ -451,6 +446,10 @@ private: // doesn't exist. void getImpl(scope const(char)[] name, scope void delegate(const(OSChar)[]) @safe sink) @trusted { + // fix issue https://issues.dlang.org/show_bug.cgi?id=24549 + if (name is null) + return sink(null); + version (Windows) { // first we ask windows how long the environment variable is, @@ -600,6 +599,15 @@ private: assert("std_process" !in environment); } +// https://issues.dlang.org/show_bug.cgi?id=24549 +@safe unittest +{ + import std.exception : assertThrown; + assert(environment.get(null) is null); + assertThrown(environment[null]); + assert(!(null in environment)); +} + // ============================================================================= // Functions and classes for process management. // ============================================================================= diff --git a/libphobos/src/std/regex/internal/ir.d b/libphobos/src/std/regex/internal/ir.d index 04b902f..25566d6 100644 --- a/libphobos/src/std/regex/internal/ir.d +++ b/libphobos/src/std/regex/internal/ir.d @@ -318,7 +318,7 @@ struct Bytecode @property bool backreference() const { assert(code == IR.GroupStart || code == IR.GroupEnd); - return cast(bool)(raw & 1 << 23); + return (raw & 1 << 23) != 0; } //mark as local reference (for backrefs in lookarounds) @@ -332,7 +332,7 @@ struct Bytecode @property bool localRef() const { assert(code == IR.Backref); - return cast(bool)(raw & 1 << 23); + return (raw & 1 << 23) != 0; } //human readable name of instruction diff --git a/libphobos/src/std/stdio.d b/libphobos/src/std/stdio.d index 40dc854..8caa9b3 100644 --- a/libphobos/src/std/stdio.d +++ b/libphobos/src/std/stdio.d @@ -123,9 +123,6 @@ alias KeepTerminator = Flag!"keepTerminator"; version (CRuntime_Microsoft) { } -else version (CRuntime_DigitalMars) -{ -} else version (CRuntime_Glibc) { } @@ -215,54 +212,7 @@ version (Posix) static import core.sys.posix.stdio; // getdelim, flockfile } -version (CRuntime_DigitalMars) -{ - private alias _FPUTC = _fputc_nlock; - private alias _FPUTWC = _fputwc_nlock; - private alias _FGETC = _fgetc_nlock; - private alias _FGETWC = _fgetwc_nlock; - private alias _FLOCK = __fp_lock; - private alias _FUNLOCK = __fp_unlock; - - // Alias for CRuntime_Microsoft compatibility. - // @@@DEPRECATED_2.107@@@ - // Rename this back to _setmode once the deprecation phase has ended. - private alias __setmode = setmode; - - // @@@DEPRECATED_2.107@@@ - deprecated("internal alias FPUTC was unintentionally available from " - ~ "std.stdio and will be removed afer 2.107") - alias FPUTC = _fputc_nlock; - // @@@DEPRECATED_2.107@@@ - deprecated("internal alias FPUTWC was unintentionally available from " - ~ "std.stdio and will be removed afer 2.107") - alias FPUTWC = _fputwc_nlock; - // @@@DEPRECATED_2.107@@@ - deprecated("internal alias FGETC was unintentionally available from " - ~ "std.stdio and will be removed afer 2.107") - alias FGETC = _fgetc_nlock; - // @@@DEPRECATED_2.107@@@ - deprecated("internal alias FGETWC was unintentionally available from " - ~ "std.stdio and will be removed afer 2.107") - alias FGETWC = _fgetwc_nlock; - // @@@DEPRECATED_2.107@@@ - deprecated("internal alias FLOCK was unintentionally available from " - ~ "std.stdio and will be removed afer 2.107") - alias FLOCK = __fp_lock; - // @@@DEPRECATED_2.107@@@ - deprecated("internal alias FUNLOCK was unintentionally available from " - ~ "std.stdio and will be removed afer 2.107") - alias FUNLOCK = __fp_unlock; - // @@@DEPRECATED_2.107@@@ - deprecated("internal alias _setmode was unintentionally available from " - ~ "std.stdio and will be removed afer 2.107") - alias _setmode = setmode; - // @@@DEPRECATED_2.107@@@ - deprecated("internal function _fileno was unintentionally available from " - ~ "std.stdio and will be removed afer 2.107") - fileno_t _fileno(FILE* f) { return f._file; } -} -else version (CRuntime_Microsoft) +version (CRuntime_Microsoft) { private alias _FPUTC = _fputc_nolock; private alias _FPUTWC = _fputwc_nolock; @@ -272,10 +222,6 @@ else version (CRuntime_Microsoft) private alias _FUNLOCK = _unlock_file; // @@@DEPRECATED_2.107@@@ - // Remove this once the deprecation phase for CRuntime_DigitalMars has ended. - private alias __setmode = _setmode; - - // @@@DEPRECATED_2.107@@@ deprecated("internal alias FPUTC was unintentionally available from " ~ "std.stdio and will be removed afer 2.107") alias FPUTC = _fputc_nolock; @@ -413,11 +359,7 @@ else private extern (C) @nogc nothrow { pragma(mangle, _FPUTC.mangleof) int trustedFPUTC(int ch, _iobuf* h) @trusted; - - version (CRuntime_DigitalMars) - pragma(mangle, _FPUTWC.mangleof) int trustedFPUTWC(int ch, _iobuf* h) @trusted; - else - pragma(mangle, _FPUTWC.mangleof) int trustedFPUTWC(wchar_t ch, _iobuf* h) @trusted; + pragma(mangle, _FPUTWC.mangleof) int trustedFPUTWC(wchar_t ch, _iobuf* h) @trusted; } //------------------------------------------------------------------------------ @@ -829,7 +771,6 @@ Throws: `ErrnoException` in case of error. f.close(); } - version (CRuntime_DigitalMars) {} else // Not implemented version (CRuntime_Microsoft) {} else // Not implemented @safe unittest // Test changing mode { @@ -889,22 +830,7 @@ Params: auto modez = stdioOpenmode.tempCString(); detach(); - version (CRuntime_DigitalMars) - { - // This is a re-implementation of DMC's fdopen, but without the - // mucking with the file descriptor. POSIX standard requires the - // new fdopen'd file to retain the given file descriptor's - // position. - auto fp = fopen("NUL", modez); - errnoEnforce(fp, "Cannot open placeholder NUL stream"); - _FLOCK(fp); - auto iob = cast(_iobuf*) fp; - .close(iob._file); - iob._file = fd; - iob._flag &= ~_IOTRAN; - _FUNLOCK(fp); - } - else version (CRuntime_Microsoft) + version (CRuntime_Microsoft) { auto fp = _fdopen(fd, modez); errnoEnforce(fp); @@ -943,26 +869,21 @@ Throws: `ErrnoException` in case of error. import std.format : format; // Create file descriptors from the handles - version (CRuntime_DigitalMars) - auto fd = _handleToFD(handle, FHND_DEVICE); - else // MSVCRT - { - int mode; - modeLoop: - foreach (c; stdioOpenmode) - switch (c) - { - case 'r': mode |= _O_RDONLY; break; - case '+': mode &=~_O_RDONLY; break; - case 'a': mode |= _O_APPEND; break; - case 'b': mode |= _O_BINARY; break; - case 't': mode |= _O_TEXT; break; - case ',': break modeLoop; - default: break; - } + int mode; + modeLoop: + foreach (c; stdioOpenmode) + switch (c) + { + case 'r': mode |= _O_RDONLY; break; + case '+': mode &=~_O_RDONLY; break; + case 'a': mode |= _O_APPEND; break; + case 'b': mode |= _O_BINARY; break; + case 't': mode |= _O_TEXT; break; + case ',': break modeLoop; + default: break; + } - auto fd = _open_osfhandle(cast(intptr_t) handle, mode); - } + auto fd = _open_osfhandle(cast(intptr_t) handle, mode); errnoEnforce(fd >= 0, "Cannot open Windows HANDLE"); fdopen(fd, stdioOpenmode, "HANDLE(%s)".format(handle)); @@ -1186,17 +1107,8 @@ Throws: `ErrnoException` if the file is not opened or the call to `fread` fails. version (Windows) { immutable fileno_t fd = .fileno(_p.handle); - immutable mode = .__setmode(fd, _O_BINARY); - scope(exit) .__setmode(fd, mode); - version (CRuntime_DigitalMars) - { - import core.atomic : atomicOp; - - // https://issues.dlang.org/show_bug.cgi?id=4243 - immutable info = __fhnd_info[fd]; - atomicOp!"&="(__fhnd_info[fd], ~FHND_TEXT); - scope(exit) __fhnd_info[fd] = info; - } + immutable mode = ._setmode(fd, _O_BINARY); + scope(exit) ._setmode(fd, mode); } immutable freadResult = trustedFread(_p.handle, buffer); assert(freadResult <= buffer.length); // fread return guarantee @@ -1276,24 +1188,14 @@ Throws: `ErrnoException` if the file is not opened or if the call to `fwrite` fa version (Windows) { immutable fileno_t fd = .fileno(_p.handle); - immutable oldMode = .__setmode(fd, _O_BINARY); + immutable oldMode = ._setmode(fd, _O_BINARY); if (oldMode != _O_BINARY) { // need to flush the data that was written with the original mode - .__setmode(fd, oldMode); - flush(); // before changing translation mode .__setmode(fd, _O_BINARY); - .__setmode(fd, _O_BINARY); - } - - version (CRuntime_DigitalMars) - { - import core.atomic : atomicOp; - - // https://issues.dlang.org/show_bug.cgi?id=4243 - immutable info = __fhnd_info[fd]; - atomicOp!"&="(__fhnd_info[fd], ~FHND_TEXT); - scope (exit) __fhnd_info[fd] = info; + ._setmode(fd, oldMode); + flush(); // before changing translation mode ._setmode(fd, _O_BINARY); + ._setmode(fd, _O_BINARY); } scope (exit) @@ -1301,7 +1203,7 @@ Throws: `ErrnoException` if the file is not opened or if the call to `fwrite` fa if (oldMode != _O_BINARY) { flush(); - .__setmode(fd, oldMode); + ._setmode(fd, oldMode); } } } @@ -1394,9 +1296,6 @@ Throws: `Exception` if the file is not opened. f.seek(7); assert(f.readln() == "hijklmnopqrstuvwxyz"); - version (CRuntime_DigitalMars) - auto bigOffset = int.max - 100; - else version (CRuntime_Bionic) auto bigOffset = int.max - 100; else @@ -2349,10 +2248,7 @@ Returns the underlying operating system `HANDLE` (Windows only). version (Windows) @property HANDLE windowsHandle() { - version (CRuntime_DigitalMars) - return _fdToHandle(fileno); - else - return cast(HANDLE)_get_osfhandle(fileno); + return cast(HANDLE)_get_osfhandle(fileno); } @@ -3151,11 +3047,11 @@ is empty, throws an `Exception`. In case of an I/O error throws // concept of ANSI/UNICODE mode. fputc doesn't work in UNICODE // mode; fputwc has to be used. So that essentially means // "wide-oriented" for us. - immutable int mode = __setmode(f.fileno, _O_TEXT); + immutable int mode = _setmode(f.fileno, _O_TEXT); // Set some arbitrary mode to obtain the previous one. - if (mode != -1) // __setmode() succeeded + if (mode != -1) // _setmode() succeeded { - __setmode(f.fileno, mode); // Restore previous mode. + _setmode(f.fileno, mode); // Restore previous mode. if (mode & (_O_WTEXT | _O_U16TEXT | _O_U8TEXT)) { orientation_ = 1; // wide @@ -3386,8 +3282,6 @@ is empty, throws an `Exception`. In case of an I/O error throws { fileno_t fd; int oldMode; - version (CRuntime_DigitalMars) - ubyte oldInfo; } public: @@ -3407,15 +3301,7 @@ is empty, throws an `Exception`. In case of an I/O error throws { .fflush(fps); // before changing translation mode fd = .fileno(fps); - oldMode = .__setmode(fd, _O_BINARY); - version (CRuntime_DigitalMars) - { - import core.atomic : atomicOp; - - // https://issues.dlang.org/show_bug.cgi?id=4243 - oldInfo = __fhnd_info[fd]; - atomicOp!"&="(__fhnd_info[fd], ~FHND_TEXT); - } + oldMode = ._setmode(fd, _O_BINARY); } } @@ -3429,12 +3315,7 @@ is empty, throws an `Exception`. In case of an I/O error throws version (Windows) { .fflush(fps); // before restoring translation mode - version (CRuntime_DigitalMars) - { - // https://issues.dlang.org/show_bug.cgi?id=4243 - __fhnd_info[fd] = oldInfo; - } - .__setmode(fd, oldMode); + ._setmode(fd, oldMode); } _FUNLOCK(fps); @@ -3887,19 +3768,12 @@ void main() return setlocale(LC_CTYPE, loc.ptr).fromStringz.endsWith(loc); }); scope(exit) () @trusted { setlocale(LC_CTYPE, oldCt); } (); - version (CRuntime_DigitalMars) // DM can't handle Unicode above U+07FF. - { - alias strs = AliasSeq!("xä\u07FE", "yö\u07FF"w); - } - else - { - alias strs = AliasSeq!("xä\U0001F607", "yö\U0001F608"w); - } + alias strs = AliasSeq!("xä\U0001F607", "yö\U0001F608"w); { auto f = File(deleteme, "w"); version (CRuntime_Microsoft) { - () @trusted { __setmode(fileno(f.getFP()), _O_U8TEXT); } (); + () @trusted { _setmode(fileno(f.getFP()), _O_U8TEXT); } (); } else { @@ -5537,120 +5411,7 @@ private struct LockedFile // Private implementation of readln private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator, File.Orientation orientation) @safe { - version (CRuntime_DigitalMars) - return () @trusted { - auto lf = LockedFile(fps); - ReadlnAppender app; - app.initialize(buf); - - if (__fhnd_info[lf.fp._file] & FHND_WCHAR) - { /* Stream is in wide characters. - * Read them and convert to chars. - */ - static assert(wchar_t.sizeof == 2); - for (int c = void; (c = lf.fgetwc()) != -1; ) - { - if ((c & ~0x7F) == 0) - { - app.putchar(cast(char) c); - if (c == terminator) - break; - } - else - { - if (c >= 0xD800 && c <= 0xDBFF) - { - int c2 = void; - if ((c2 = lf.fgetwc()) != -1 || - c2 < 0xDC00 && c2 > 0xDFFF) - { - StdioException("unpaired UTF-16 surrogate"); - } - c = ((c - 0xD7C0) << 10) + (c2 - 0xDC00); - } - app.putdchar(cast(dchar) c); - } - } - if (ferror(fps)) - StdioException(); - } - else if (lf.fp._flag & _IONBF) - { - /* Use this for unbuffered I/O, when running - * across buffer boundaries, or for any but the common - * cases. - */ - L1: - int c; - while ((c = lf.fgetc()) != -1) - { - app.putchar(cast(char) c); - if (c == terminator) - { - buf = app.data; - return buf.length; - } - - } - - if (ferror(fps)) - StdioException(); - } - else - { - int u = lf.fp._cnt; - char* p = lf.fp._ptr; - int i; - if (lf.fp._flag & _IOTRAN) - { /* Translated mode ignores \r and treats ^Z as end-of-file - */ - char c; - while (1) - { - if (i == u) // if end of buffer - goto L1; // give up - c = p[i]; - i++; - if (c != '\r') - { - if (c == terminator) - break; - if (c != 0x1A) - continue; - goto L1; - } - else - { if (i != u && p[i] == terminator) - break; - goto L1; - } - } - app.putonly(p[0 .. i]); - app.buf[i - 1] = cast(char) terminator; - if (terminator == '\n' && c == '\r') - i++; - } - else - { - while (1) - { - if (i == u) // if end of buffer - goto L1; // give up - auto c = p[i]; - i++; - if (c == terminator) - break; - } - app.putonly(p[0 .. i]); - } - lf.fp._cnt -= i; - lf.fp._ptr += i; - } - - buf = app.data; - return buf.length; - }(); - else version (CRuntime_Microsoft) + version (CRuntime_Microsoft) { auto lf = LockedFile(fps); diff --git a/libphobos/src/std/string.d b/libphobos/src/std/string.d index ca14c23..b350d6b 100644 --- a/libphobos/src/std/string.d +++ b/libphobos/src/std/string.d @@ -5942,36 +5942,36 @@ C1[] tr(C1, C2, C3, C4 = immutable char) n = 0; // consider it 'found' at position 0 Lfound: - - // Find the nth character in to[] - dchar nextt; - for (size_t i = 0; i < to.length; ) - { - immutable t = decode(to, i); - if (t == '-' && lastt != dchar.init && i < to.length) + { // create a new scope so that gotos don't skip of declaration of nextt + // Find the nth character in to[] + dchar nextt; + for (size_t i = 0; i < to.length; ) { - nextt = decode(to, i); - n -= nextt - lastt; - if (n < 0) + immutable t = decode(to, i); + if (t == '-' && lastt != dchar.init && i < to.length) { - newc = nextt + n + 1; + nextt = decode(to, i); + n -= nextt - lastt; + if (n < 0) + { + newc = nextt + n + 1; + goto Lnewc; + } + lastt = dchar.init; + continue; + } + if (n == 0) + { newc = t; goto Lnewc; } - lastt = dchar.init; - continue; - } - if (n == 0) - { newc = t; - goto Lnewc; + lastt = t; + nextt = t; + n--; } - lastt = t; - nextt = t; - n--; + if (mod_d) + continue; + newc = nextt; } - if (mod_d) - continue; - newc = nextt; - Lnewc: if (mod_s && modified && newc == lastc) continue; diff --git a/libphobos/src/std/typecons.d b/libphobos/src/std/typecons.d index f5b4846..3c425c7 100644 --- a/libphobos/src/std/typecons.d +++ b/libphobos/src/std/typecons.d @@ -3125,7 +3125,10 @@ private: } // call possible struct destructors - .destroy!(No.initialize)(*cast(T*) &this.data); + static if (is(T == struct)) + { + .destroy!(No.initialize)(*cast(T*) &this.data); + } } } |