From f08bbff91ffc8cc607f2fbbc964af6a4c08283ce Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sat, 25 May 2024 15:06:37 +0200 Subject: [PATCH 1/3] Get rid of obsolete CRuntime_DigitalMars special cases --- compiler/samples/dserver.d | 1 - compiler/src/dmd/cli.d | 11 +- compiler/src/dmd/dmdparams.d | 2 - compiler/src/dmd/frontend.h | 20 +- compiler/src/dmd/target.d | 8 +- compiler/src/dmd/target.h | 2 - compiler/test/compilable/test18955.d | 7 +- compiler/test/compilable/zerosize.d | 5 +- compiler/test/runnable/testthread.d | 11 - compiler/test/runnable_cxx/test20652.d | 6 +- druntime/mak/DOCS | 1 - druntime/mak/SRCS | 1 - druntime/src/core/demangle.d | 50 ---- druntime/src/core/internal/parseoptions.d | 28 +-- druntime/src/core/stdc/assert_.d | 9 +- druntime/src/core/stdc/errno.d | 98 +------- druntime/src/core/stdc/fenv.d | 17 -- druntime/src/core/stdc/math.d | 97 +------- druntime/src/core/stdc/stdint.d | 12 +- druntime/src/core/stdc/stdio.d | 274 +-------------------- druntime/src/core/sys/windows/dll.d | 8 +- druntime/src/core/sys/windows/stacktrace.d | 7 - druntime/src/core/sys/windows/stat.d | 24 +- druntime/src/core/thread/osthread.d | 11 +- druntime/src/rt/cover.d | 5 +- druntime/src/rt/monitor_.d | 4 - druntime/src/rt/sections.d | 2 - druntime/src/rt/sections_win32.d | 252 ------------------- 28 files changed, 37 insertions(+), 936 deletions(-) delete mode 100644 druntime/src/rt/sections_win32.d diff --git a/compiler/samples/dserver.d b/compiler/samples/dserver.d index e565c10614..bc811ba320 100644 --- a/compiler/samples/dserver.d +++ b/compiler/samples/dserver.d @@ -131,7 +131,6 @@ BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) g_hInst = hInstance; dll_process_attach( hInstance, true ); printf("ATTACH\n"); - version(CRuntime_DigitalMars) _fcloseallp = null; // https://issues.dlang.org/show_bug.cgi?id=1550 break; case DLL_PROCESS_DETACH: diff --git a/compiler/src/dmd/cli.d b/compiler/src/dmd/cli.d index ab7dcfa6e1..f0f3c5c66f 100644 --- a/compiler/src/dmd/cli.d +++ b/compiler/src/dmd/cli.d @@ -769,12 +769,11 @@ dmd -cov -unittest myprog.d `darwin` or `osx` for MacOS, `dragonfly` or `dragonflybsd` for DragonflyBSD, `freebsd`, `openbsd`, `linux`, `solaris` or `windows` for their respective operating systems. $(I cenv) is the C runtime environment and is optional: `musl` for musl-libc, - `msvc` for the MSVC runtime (the default for windows with this option), - `bionic` for the Andriod libc, `digital_mars` for the Digital Mars runtime for Windows - `gnu` or `glibc` for the GCC C runtime, `newlib` or `uclibc` for their respective C runtimes. - ($ I cppenv) is the C++ runtime environment: `clang` for the LLVM C++ runtime - `gcc` for GCC's C++ runtime, `msvc` for microsoft's MSVC C++ runtime (the default for windows with this switch), - `sun` for Sun's C++ runtime and `digital_mars` for the Digital Mars C++ runtime for windows. + `msvc` for the MSVC runtime, `bionic` for the Andriod libc, `gnu` or `glibc` + for the GCC C runtime, `newlib` or `uclibc` for their respective C runtimes. + ($ I cppenv) is the C++ runtime environment: `clang` for the LLVM C++ runtime, + `gcc` for GCC's C++ runtime, `msvc` for microsoft's MSVC C++ runtime, + `sun` for Sun's C++ runtime. " ), Option("transition=", diff --git a/compiler/src/dmd/dmdparams.d b/compiler/src/dmd/dmdparams.d index 7a00e65028..43c73f11ca 100644 --- a/compiler/src/dmd/dmdparams.d +++ b/compiler/src/dmd/dmdparams.d @@ -283,7 +283,6 @@ struct Triple case "musl": return Musl; case "msvc": return Microsoft; case "bionic": return Bionic; - case "digital_mars": return DigitalMars; case "newlib": return Newlib; case "uclibc": return UClibc; case "glibc": return Glibc; @@ -303,7 +302,6 @@ struct Triple case "gcc": return Gcc; case "msvc": return Microsoft; case "sun": return Sun; - case "digital_mars": return DigitalMars; default: { unknown(cppenv, "C++ runtime environment"); diff --git a/compiler/src/dmd/frontend.h b/compiler/src/dmd/frontend.h index 2ab5a765c5..fe1a2f4457 100644 --- a/compiler/src/dmd/frontend.h +++ b/compiler/src/dmd/frontend.h @@ -5956,13 +5956,12 @@ struct TargetC final { Unspecified = 0u, Bionic = 1u, - DigitalMars = 2u, - Glibc = 3u, - Microsoft = 4u, - Musl = 5u, - Newlib = 6u, - UClibc = 7u, - WASI = 8u, + Glibc = 2u, + Microsoft = 3u, + Musl = 4u, + Newlib = 5u, + UClibc = 6u, + WASI = 7u, }; enum class BitFieldStyle : uint8_t @@ -6014,10 +6013,9 @@ struct TargetCPP final { Unspecified = 0u, Clang = 1u, - DigitalMars = 2u, - Gcc = 3u, - Microsoft = 4u, - Sun = 5u, + Gcc = 2u, + Microsoft = 3u, + Sun = 4u, }; bool reverseOverloads; diff --git a/compiler/src/dmd/target.d b/compiler/src/dmd/target.d index e43287f87c..6d3bc4dc67 100644 --- a/compiler/src/dmd/target.d +++ b/compiler/src/dmd/target.d @@ -248,7 +248,6 @@ void addCRuntimePredefinedGlobalIdent(const ref TargetC c) default: case Unspecified: return; case Bionic: return predef("CRuntime_Bionic"); - case DigitalMars: return predef("CRuntime_DigitalMars"); case Glibc: return predef("CRuntime_Glibc"); case Microsoft: return predef("CRuntime_Microsoft"); case Musl: return predef("CRuntime_Musl"); @@ -269,7 +268,6 @@ void addCppRuntimePredefinedGlobalIdent(const ref TargetCPP cpp) default: case Unspecified: return; case Clang: return predef("CppRuntime_Clang"); - case DigitalMars: return predef("CppRuntime_DigitalMars"); case Gcc: return predef("CppRuntime_Gcc"); case Microsoft: return predef("CppRuntime_Microsoft"); case Sun: return predef("CppRuntime_Sun"); @@ -1358,7 +1356,6 @@ struct TargetC { Unspecified, Bionic, - DigitalMars, Glibc, Microsoft, Musl, @@ -1419,7 +1416,7 @@ struct TargetC wchar_tsize = 4; if (os == Target.OS.Windows) - runtime = target.omfobj ? Runtime.DigitalMars : Runtime.Microsoft; + runtime = Runtime.Microsoft; else if (os == Target.OS.linux) { // Note: This is overridden later by `-target=` if supplied. @@ -1462,7 +1459,6 @@ struct TargetCPP { Unspecified, Clang, - DigitalMars, Gcc, Microsoft, Sun @@ -1490,7 +1486,7 @@ struct TargetCPP assert(0); exceptions = (os & Target.OS.Posix) != 0; if (os == Target.OS.Windows) - runtime = target.omfobj ? Runtime.DigitalMars : Runtime.Microsoft; + runtime = Runtime.Microsoft; else if (os & (Target.OS.linux | Target.OS.DragonFlyBSD)) runtime = Runtime.Gcc; else if (os & (Target.OS.OSX | Target.OS.FreeBSD | Target.OS.OpenBSD)) diff --git a/compiler/src/dmd/target.h b/compiler/src/dmd/target.h index 6237cf1483..da34806752 100644 --- a/compiler/src/dmd/target.h +++ b/compiler/src/dmd/target.h @@ -50,7 +50,6 @@ struct TargetC { Unspecified, Bionic, - DigitalMars, Glibc, Microsoft, Musl, @@ -87,7 +86,6 @@ struct TargetCPP { Unspecified, Clang, - DigitalMars, Gcc, Microsoft, Sun diff --git a/compiler/test/compilable/test18955.d b/compiler/test/compilable/test18955.d index af8908fc1b..7fb1c176ca 100644 --- a/compiler/test/compilable/test18955.d +++ b/compiler/test/compilable/test18955.d @@ -15,10 +15,5 @@ version(Windows) version(D_LP64) static assert(test.mangleof == "?test@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@@std@@@Z"); else - { - version(CRuntime_DigitalMars) - static assert(test.mangleof == "?test@@YAXABV?$basic_string@std@DU?$char_traits@std@D@1@@std@@@Z"); - else - static assert(test.mangleof == "?test@@YAXABV?$basic_string@DU?$char_traits@D@std@@@std@@@Z"); - } + static assert(test.mangleof == "?test@@YAXABV?$basic_string@DU?$char_traits@D@std@@@std@@@Z"); } diff --git a/compiler/test/compilable/zerosize.d b/compiler/test/compilable/zerosize.d index 6e26deb549..7986c92c7f 100644 --- a/compiler/test/compilable/zerosize.d +++ b/compiler/test/compilable/zerosize.d @@ -6,10 +6,7 @@ version (CRuntime_Microsoft) else static assert(S.sizeof == 0); -version (CRuntime_DigitalMars) - static assert(S.alignof == 0); -else - static assert(S.alignof == 1); +static assert(S.alignof == 1); extern (C++) struct T { } diff --git a/compiler/test/runnable/testthread.d b/compiler/test/runnable/testthread.d index 139a891072..811b6c2222 100644 --- a/compiler/test/runnable/testthread.d +++ b/compiler/test/runnable/testthread.d @@ -3,15 +3,6 @@ import core.stdc.stdio; import core.thread; -version (CRuntime_DigitalMars) -{ - extern (C) - { - extern int _tlsstart; - extern int _tlsend; - } -} - int tlsx; class Foo @@ -25,8 +16,6 @@ class Foo tlsx = 5; Thread t = Thread.getThis(); - version (CRuntime_DigitalMars) - printf("thread ptr=%p, %p &tlsx = %p %p\n", t, &_tlsstart, &tlsx, &_tlsend); x = 3; printf("-bar()\n"); } diff --git a/compiler/test/runnable_cxx/test20652.d b/compiler/test/runnable_cxx/test20652.d index 68bb0a711e..a4962f664e 100644 --- a/compiler/test/runnable_cxx/test20652.d +++ b/compiler/test/runnable_cxx/test20652.d @@ -3,11 +3,7 @@ import core.simd; -version (CRuntime_DigitalMars) // DMC doesn't support immintrin.h -{ - void main() {} -} -else static if (!__traits(compiles, float4)) // No __vector support +static if (!__traits(compiles, float4)) // No __vector support { void main() {} } diff --git a/druntime/mak/DOCS b/druntime/mak/DOCS index 81de39c5ed..0ce633eda8 100644 --- a/druntime/mak/DOCS +++ b/druntime/mak/DOCS @@ -553,7 +553,6 @@ DOCS=\ $(DOCDIR)\rt_sections.html \ $(DOCDIR)\rt_sections_darwin_64.html \ $(DOCDIR)\rt_sections_solaris.html \ - $(DOCDIR)\rt_sections_win32.html \ $(DOCDIR)\rt_sections_win64.html \ $(DOCDIR)\rt_tlsgc.html \ $(DOCDIR)\rt_trace.html \ diff --git a/druntime/mak/SRCS b/druntime/mak/SRCS index 0794a5797d..447948adfb 100644 --- a/druntime/mak/SRCS +++ b/druntime/mak/SRCS @@ -587,7 +587,6 @@ SRCS=\ src\rt\sections_osx_x86.d \ src\rt\sections_osx_x86_64.d \ src\rt\sections_solaris.d \ - src\rt\sections_win32.d \ src\rt\sections_win64.d \ src\rt\tlsgc.d \ src\rt\trace.d \ diff --git a/druntime/src/core/demangle.d b/druntime/src/core/demangle.d index 272ee1e1ba..4405dec263 100644 --- a/druntime/src/core/demangle.d +++ b/druntime/src/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/druntime/src/core/internal/parseoptions.d b/druntime/src/core/internal/parseoptions.d index ac0eb826b3..2bf1da2fbf 100644 --- a/druntime/src/core/internal/parseoptions.d +++ b/druntime/src/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/druntime/src/core/stdc/assert_.d b/druntime/src/core/stdc/assert_.d index c6d9d9f6cc..ac237d9c89 100644 --- a/druntime/src/core/stdc/assert_.d +++ b/druntime/src/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/druntime/src/core/stdc/errno.d b/druntime/src/core/stdc/errno.d index ddec70f7af..0430e6b33e 100644 --- a/druntime/src/core/stdc/errno.d +++ b/druntime/src/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/druntime/src/core/stdc/fenv.d b/druntime/src/core/stdc/fenv.d index a7364c0a21..6cd75f3a79 100644 --- a/druntime/src/core/stdc/fenv.d +++ b/druntime/src/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/druntime/src/core/stdc/math.d b/druntime/src/core/stdc/math.d index c5eaf79a82..e54d581399 100644 --- a/druntime/src/core/stdc/math.d +++ b/druntime/src/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/druntime/src/core/stdc/stdint.d b/druntime/src/core/stdc/stdint.d index 476c42f08e..1776269378 100644 --- a/druntime/src/core/stdc/stdint.d +++ b/druntime/src/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/druntime/src/core/stdc/stdio.d b/druntime/src/core/stdc/stdio.d index 1fc046163e..8afb68f858 100644 --- a/druntime/src/core/stdc/stdio.d +++ b/druntime/src/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/druntime/src/core/sys/windows/dll.d b/druntime/src/core/sys/windows/dll.d index 4fee33fa92..adcb3f3c89 100644 --- a/druntime/src/core/sys/windows/dll.d +++ b/druntime/src/core/sys/windows/dll.d @@ -29,13 +29,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/druntime/src/core/sys/windows/stacktrace.d b/druntime/src/core/sys/windows/stacktrace.d index a73fc9ce4d..ae7047b646 100644 --- a/druntime/src/core/sys/windows/stacktrace.d +++ b/druntime/src/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; } diff --git a/druntime/src/core/sys/windows/stat.d b/druntime/src/core/sys/windows/stat.d index c87c749887..85ed24f93d 100644 --- a/druntime/src/core/sys/windows/stat.d +++ b/druntime/src/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/druntime/src/core/thread/osthread.d b/druntime/src/core/thread/osthread.d index d7f50b994e..42f28f3458 100644 --- a/druntime/src/core/thread/osthread.d +++ b/druntime/src/core/thread/osthread.d @@ -2453,11 +2453,7 @@ private bool ll_dllHasExternalReferences() nothrow { - version (CRuntime_DigitalMars) - enum internalReferences = 1; // only the watchdog thread - else - int internalReferences = msvcUsesUCRT ? 1 + ll_countLowLevelThreadsWithDLLUnloadCallback() : 1; - + int internalReferences = msvcUsesUCRT ? 1 + ll_countLowLevelThreadsWithDLLUnloadCallback() : 1; int refcnt = dll_getRefCount(ll_dllModule); return refcnt > internalReferences; } @@ -2518,10 +2514,7 @@ private // if a thread is created from a DLL, the MS runtime (starting with VC2015) increments the DLL reference count // to avoid the DLL being unloaded while the thread is still running. Mimick this behavior here for all // runtimes not doing this - version (CRuntime_DigitalMars) - enum needRef = true; - else - bool needRef = !msvcUsesUCRT; + bool needRef = !msvcUsesUCRT; if (needRef) { diff --git a/druntime/src/rt/cover.d b/druntime/src/rt/cover.d index ef1d505d8f..94c8ea2bb6 100644 --- a/druntime/src/rt/cover.d +++ b/druntime/src/rt/cover.d @@ -473,10 +473,7 @@ FILE* openOrCreateFile(string name) version (Windows) HANDLE handle(int fd) { - version (CRuntime_DigitalMars) - return _fdToHandle(fd); - else - return cast(HANDLE)_get_osfhandle(fd); + return cast(HANDLE)_get_osfhandle(fd); } void lockFile(int fd) diff --git a/druntime/src/rt/monitor_.d b/druntime/src/rt/monitor_.d index c1f3f3cb9a..cbe2a48440 100644 --- a/druntime/src/rt/monitor_.d +++ b/druntime/src/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/druntime/src/rt/sections.d b/druntime/src/rt/sections.d index a84a5c6bcd..decd23f780 100644 --- a/druntime/src/rt/sections.d +++ b/druntime/src/rt/sections.d @@ -49,8 +49,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/druntime/src/rt/sections_win32.d b/druntime/src/rt/sections_win32.d deleted file mode 100644 index a09eda4cad..0000000000 --- a/druntime/src/rt/sections_win32.d +++ /dev/null @@ -1,252 +0,0 @@ -/** - * Written in the D programming language. - * This module provides Win32-specific support for sections. - * - * Copyright: Copyright Digital Mars 2008 - 2012. - * License: Distributed under the - * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). - * (See accompanying file LICENSE) - * Authors: Walter Bright, Sean Kelly, Martin Nowak - * Source: $(DRUNTIMESRC rt/_sections_win32.d) - */ - -module rt.sections_win32; - -version (CRuntime_DigitalMars): - -// debug = PRINTF; -debug(PRINTF) import core.stdc.stdio; -import rt.minfo; -import core.stdc.stdlib : malloc, free; -import core.sys.windows.winbase : FreeLibrary, GetProcAddress, LoadLibraryA, LoadLibraryW; -import core.sys.windows.winnt : WCHAR; - -struct SectionGroup -{ - static int opApply(scope int delegate(ref SectionGroup) dg) - { - return dg(_sections); - } - - static int opApplyReverse(scope int delegate(ref SectionGroup) dg) - { - return dg(_sections); - } - - @property immutable(ModuleInfo*)[] modules() const nothrow @nogc - { - return _moduleGroup.modules; - } - - @property ref inout(ModuleGroup) moduleGroup() inout return nothrow @nogc - { - return _moduleGroup; - } - - @property inout(void[])[] gcRanges() inout nothrow @nogc - { - return _gcRanges[]; - } - -private: - ModuleGroup _moduleGroup; - void[][] _gcRanges; -} - -shared(bool) conservative; - -/**** - * Gets called on program startup just before GC is initialized. - */ -void initSections() nothrow @nogc -{ - _sections._moduleGroup = ModuleGroup(getModuleInfos()); - - import rt.sections; - conservative = !scanDataSegPrecisely(); - - if (conservative) - { - _sections._gcRanges = (cast(void[]*) malloc(2 * (void[]).sizeof))[0..2]; - - auto databeg = cast(void*)&_xi_a; - auto dataend = cast(void*)_moduleinfo_array.ptr; - _sections._gcRanges[0] = databeg[0 .. dataend - databeg]; - - // skip module info and CONST segment - auto bssbeg = cast(void*)&_edata; - auto bssend = cast(void*)&_end; - _sections._gcRanges[1] = bssbeg[0 .. bssend - bssbeg]; - } - else - { - size_t count = &_DPend - &_DPbegin; - auto ranges = cast(void[]*) malloc(count * (void[]).sizeof); - size_t r = 0; - void* prev = null; - for (size_t i = 0; i < count; i++) - { - void* addr = (&_DPbegin)[i]; - if (prev + (void*).sizeof == addr) - ranges[r-1] = ranges[r-1].ptr[0 .. ranges[r-1].length + (void*).sizeof]; - else - ranges[r++] = (cast(void**)addr)[0..1]; - prev = addr; - } - _sections._gcRanges = ranges[0..r]; - } -} - -/*** - * Gets called on program shutdown just after GC is terminated. - */ -void finiSections() nothrow @nogc -{ - free(_sections._gcRanges.ptr); -} - -/*** - * Called once per thread; returns array of thread local storage ranges - */ -void[] initTLSRanges() nothrow @nogc -{ - auto pbeg = cast(void*)&_tlsstart; - auto pend = cast(void*)&_tlsend; - return pbeg[0 .. pend - pbeg]; -} - -void finiTLSRanges(void[] rng) nothrow @nogc -{ -} - -void scanTLSRanges(void[] rng, scope void delegate(void* pbeg, void* pend) nothrow dg) nothrow -{ - if (conservative) - { - dg(rng.ptr, rng.ptr + rng.length); - } - else - { - for (auto p = &_TPbegin; p < &_TPend; ) - { - uint beg = *p++; - uint end = beg + cast(uint)((void*).sizeof); - while (p < &_TPend && *p == end) - { - end += (void*).sizeof; - p++; - } - dg(rng.ptr + beg, rng.ptr + end); - } - } -} - -private: - -/////////////////////////////////////////////////////////////////////////////// -// Compiler to runtime interface. -/////////////////////////////////////////////////////////////////////////////// - -__gshared SectionGroup _sections; - -// Windows: this gets initialized by minit.asm -extern(C) __gshared immutable(ModuleInfo*)[] _moduleinfo_array; -extern(C) void _minit() nothrow @nogc; - -immutable(ModuleInfo*)[] getModuleInfos() nothrow @nogc -out (result) -{ - foreach (m; result) - assert(m !is null); -} -do -{ - // _minit directly alters the global _moduleinfo_array - _minit(); - return _moduleinfo_array; -} - -extern(C) -{ - extern __gshared - { - int _xi_a; // &_xi_a just happens to be start of data segment - int _edata; // &_edata is start of BSS segment - int _end; // &_end is past end of BSS - - void* _DPbegin; // first entry in the array of pointers addresses - void* _DPend; // &_DPend points after last entry of array - uint _TPbegin; // first entry in the array of TLS offsets of pointers - uint _TPend; // &_DPend points after last entry of array - } - - extern - { - int _tlsstart; - int _tlsend; - } -} - -/////////////////////////////////////////////////////////////////////////////// -// dynamic loading -/////////////////////////////////////////////////////////////////////////////// - -/*********************************** - * These are a temporary means of providing a GC hook for DLL use. They may be - * replaced with some other similar functionality later. - */ -extern (C) -{ - void* gc_getProxy(); - void gc_setProxy(void* p); - void gc_clrProxy(); - - alias void function(void*) gcSetFn; - alias void function() gcClrFn; -} - -/******************************************* - * Loads a DLL written in D with the name 'name'. - * Returns: - * opaque handle to the DLL if successfully loaded - * null if failure - */ -extern (C) void* rt_loadLibrary(const char* name) -{ - return initLibrary(.LoadLibraryA(name)); -} - -extern (C) void* rt_loadLibraryW(const WCHAR* name) -{ - return initLibrary(.LoadLibraryW(name)); -} - -void* initLibrary(void* mod) -{ - // BUG: LoadLibrary() call calls rt_init(), which fails if proxy is not set! - // (What? LoadLibrary() is a Windows API call, it shouldn't call rt_init().) - if (mod is null) - return mod; - gcSetFn gcSet = cast(gcSetFn) GetProcAddress(mod, "gc_setProxy"); - if (gcSet !is null) - { // BUG: Set proxy, but too late - gcSet(gc_getProxy()); - } - return mod; -} - -/************************************* - * Unloads DLL that was previously loaded by rt_loadLibrary(). - * Input: - * ptr the handle returned by rt_loadLibrary() - * Returns: - * 1 succeeded - * 0 some failure happened - */ -extern (C) int rt_unloadLibrary(void* ptr) -{ - gcClrFn gcClr = cast(gcClrFn) GetProcAddress(ptr, "gc_clrProxy"); - if (gcClr !is null) - gcClr(); - return FreeLibrary(ptr) != 0; -} From 01c9c22f3f3d38cf19b4b9dee61a3fd485f09790 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sat, 25 May 2024 18:58:37 +0200 Subject: [PATCH 2/3] Get rid of obsolete CppRuntime_DigitalMars special cases --- compiler/test/compilable/cppmangle.d | 1 - compiler/test/compilable/cppmangle3.d | 1 - .../test/dshell/extra-files/dll_cxx/cppnew.d | 13 ----- compiler/test/runnable_cxx/cpp_abi_tests.d | 1 - compiler/test/runnable_cxx/cppa.d | 4 +- compiler/test/runnable_cxx/externmangle.d | 48 ++++++++----------- druntime/src/core/stdcpp/array.d | 13 +---- druntime/src/core/stdcpp/exception.d | 18 ------- druntime/src/core/stdcpp/string_view.d | 13 +---- druntime/src/core/stdcpp/typeinfo.d | 48 +------------------ 10 files changed, 24 insertions(+), 136 deletions(-) diff --git a/compiler/test/compilable/cppmangle.d b/compiler/test/compilable/cppmangle.d index 264b374dd5..948fee2cfd 100644 --- a/compiler/test/compilable/cppmangle.d +++ b/compiler/test/compilable/cppmangle.d @@ -8,7 +8,6 @@ import core.stdc.stdio; version (CppRuntime_Clang) version = CppMangle_Itanium; -version (CppRuntime_DigitalMars) version = CppMangle_MSVC; version (CppRuntime_Gcc) version = CppMangle_Itanium; version (CppRuntime_Microsoft) version = CppMangle_MSVC; version (CppRuntime_Sun) version = CppMangle_Itanium; diff --git a/compiler/test/compilable/cppmangle3.d b/compiler/test/compilable/cppmangle3.d index 82c68f7a3a..92c858854f 100644 --- a/compiler/test/compilable/cppmangle3.d +++ b/compiler/test/compilable/cppmangle3.d @@ -4,7 +4,6 @@ module cppmangle3; version (CppRuntime_Clang) version = CppMangle_Itanium; -version (CppRuntime_DigitalMars) version = CppMangle_MSVC; version (CppRuntime_Gcc) version = CppMangle_Itanium; version (CppRuntime_Microsoft) version = CppMangle_MSVC; version (CppRuntime_Sun) version = CppMangle_Itanium; diff --git a/compiler/test/dshell/extra-files/dll_cxx/cppnew.d b/compiler/test/dshell/extra-files/dll_cxx/cppnew.d index cae1822404..7d440077e3 100644 --- a/compiler/test/dshell/extra-files/dll_cxx/cppnew.d +++ b/compiler/test/dshell/extra-files/dll_cxx/cppnew.d @@ -53,19 +53,6 @@ version (CppRuntime_Microsoft) enum __delete_mangle = "??3@YAXPAX@Z"; } } -else version (CppRuntime_DigitalMars) -{ - version (D_LP64) - { - enum __new_mangle = "??2@YAPEAX_K@Z"; - enum __delete_mangle = "??3@YAXPEAX@Z"; - } - else - { - enum __new_mangle = "??2@YAPAXI@Z"; - enum __delete_mangle = "??3@YAXPAX@Z"; - } -} else { version (D_LP64) diff --git a/compiler/test/runnable_cxx/cpp_abi_tests.d b/compiler/test/runnable_cxx/cpp_abi_tests.d index c0f4e6dd78..5d4bc99c1b 100644 --- a/compiler/test/runnable_cxx/cpp_abi_tests.d +++ b/compiler/test/runnable_cxx/cpp_abi_tests.d @@ -272,7 +272,6 @@ void main() foreach(byte val; values!byte()) check(val); foreach(ubyte val; values!ubyte()) check(val); foreach(char val; values!char()) check(val); -version(CppRuntime_DigitalMars){} else version(CppRuntime_Microsoft) { // TODO: figure out how to detect VS2013 which doesn't support char16_t/char32_t diff --git a/compiler/test/runnable_cxx/cppa.d b/compiler/test/runnable_cxx/cppa.d index cb268af062..58facc52ae 100644 --- a/compiler/test/runnable_cxx/cppa.d +++ b/compiler/test/runnable_cxx/cppa.d @@ -908,9 +908,7 @@ void fuzz2() } //////// -version(CppRuntime_DigitalMars) - enum UNICODE = false; -else version(CppRuntime_Microsoft) +version(CppRuntime_Microsoft) enum UNICODE = false; //VS2013 doesn't support them else enum UNICODE = true; diff --git a/compiler/test/runnable_cxx/externmangle.d b/compiler/test/runnable_cxx/externmangle.d index ef132dcca7..266cad9f6c 100644 --- a/compiler/test/runnable_cxx/externmangle.d +++ b/compiler/test/runnable_cxx/externmangle.d @@ -239,38 +239,30 @@ void test39() extern(C++, "foo", "bar", "baz") int doStuff(int); -version(CppRuntime_DigitalMars) // DMC doesn't support c++11 +void test40(); + +void foovargs(T...)(T args) { - void test40() {} - void test41() {} + static if (is(T[0] == char*)) + { + assert(*args[0] == 'a'); + } + else + { + float ret = args[0] + args[1]; + assert(ret == 3.0f); + } } -else + +alias FooVargs = foovargs!(int, float); +alias FooVargs2 = foovargs!(char*); + +void test41(); +void make_shared_poc(T, Args...)(ref Args args) { - void test40(); - - void foovargs(T...)(T args) - { - static if (is(T[0] == char*)) - { - assert(*args[0] == 'a'); - } - else - { - float ret = args[0] + args[1]; - assert(ret == 3.0f); - } - } - - alias FooVargs = foovargs!(int, float); - alias FooVargs2 = foovargs!(char*); - - void test41(); - void make_shared_poc(T, Args...)(ref Args args) - { - assert(args[0] + args[1] == 3); - } - alias Make_Shared_Poc = make_shared_poc!(int, int, int); + assert(args[0] + args[1] == 3); } +alias Make_Shared_Poc = make_shared_poc!(int, int, int); void main() { diff --git a/druntime/src/core/stdcpp/array.d b/druntime/src/core/stdcpp/array.d index eb63d4ccaa..4cb0c56ec5 100644 --- a/druntime/src/core/stdcpp/array.d +++ b/druntime/src/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/druntime/src/core/stdcpp/exception.d b/druntime/src/core/stdcpp/exception.d index d5339964e3..4774b98615 100644 --- a/druntime/src/core/stdcpp/exception.d +++ b/druntime/src/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/druntime/src/core/stdcpp/string_view.d b/druntime/src/core/stdcpp/string_view.d index 172c170444..47f58b014e 100644 --- a/druntime/src/core/stdcpp/string_view.d +++ b/druntime/src/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/druntime/src/core/stdcpp/typeinfo.d b/druntime/src/core/stdcpp/typeinfo.d index 24f2938cca..b8478b3941 100644 --- a/druntime/src/core/stdcpp/typeinfo.d +++ b/druntime/src/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; From 0127c72cb84ae0d5f417029040a706c2776ee2fc Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sat, 25 May 2024 20:59:21 +0200 Subject: [PATCH 3/3] Get rid of DMC workaround for the dll_cxx dshell test --- compiler/test/dshell/dll_cxx.d | 2 +- .../test/dshell/extra-files/dll_cxx/cppnew.d | 68 ------------------- .../test/dshell/extra-files/dll_cxx/testdll.d | 2 +- 3 files changed, 2 insertions(+), 70 deletions(-) delete mode 100644 compiler/test/dshell/extra-files/dll_cxx/cppnew.d diff --git a/compiler/test/dshell/dll_cxx.d b/compiler/test/dshell/dll_cxx.d index 0102e12793..827cc7506e 100644 --- a/compiler/test/dshell/dll_cxx.d +++ b/compiler/test/dshell/dll_cxx.d @@ -53,7 +53,7 @@ int main() // The arguments have to be passed as an array, because run would replace '/' with '\\' otherwise. run(dllCmd); - run(`$DMD -m$MODEL -I$SRC -g -od=$OUTPUT_BASE -of=$EXE_NAME $SRC/testdll.d $SRC/cppnew.d ` ~ mainExtra); + run(`$DMD -m$MODEL -g -od=$OUTPUT_BASE -of=$EXE_NAME $SRC/testdll.d ` ~ mainExtra); run(`$EXE_NAME`, stdout, stderr, [`LD_LIBRARY_PATH`: Vars.OUTPUT_BASE]); diff --git a/compiler/test/dshell/extra-files/dll_cxx/cppnew.d b/compiler/test/dshell/extra-files/dll_cxx/cppnew.d deleted file mode 100644 index 7d440077e3..0000000000 --- a/compiler/test/dshell/extra-files/dll_cxx/cppnew.d +++ /dev/null @@ -1,68 +0,0 @@ -module cppnew; - -/* This module contains copies from core.stdcpp.new_.d, but with - * modifications for DMC. */ - -T* cpp_new(T, Args...)(auto ref Args args) if (!is(T == class)) -{ - import core.lifetime : emplace, forward; - - T* mem = cast(T*)__cpp_new(T.sizeof); - return mem.emplace(forward!args); -} - -T cpp_new(T, Args...)(auto ref Args args) if (is(T == class)) -{ - import core.lifetime : emplace, forward; - - T mem = cast(T)__cpp_new(__traits(classInstanceSize, T)); - return mem.emplace(forward!args); -} - -void cpp_delete(T)(T* ptr) if (!is(T == class)) -{ - destroy!false(*ptr); - __cpp_delete(ptr); -} - -void cpp_delete(T)(T instance) if (is(T == class)) -{ - destroy!false(instance); - __cpp_delete(cast(void*) instance); -} - -/// Binding for ::operator new(std::size_t count) -pragma(mangle, __new_mangle) -extern(C++) void* __cpp_new(size_t count); - -/// Binding for ::operator delete(void* ptr) -pragma(mangle, __delete_mangle) -extern(C++) void __cpp_delete(void* ptr); - -// we have to hard-code the mangling for the global new/delete operators -version (CppRuntime_Microsoft) -{ - version (D_LP64) - { - enum __new_mangle = "??2@YAPEAX_K@Z"; - enum __delete_mangle = "??3@YAXPEAX@Z"; - } - else - { - enum __new_mangle = "??2@YAPAXI@Z"; - enum __delete_mangle = "??3@YAXPAX@Z"; - } -} -else -{ - version (D_LP64) - { - enum __new_mangle = "_Znwm"; - enum __delete_mangle = "_ZdlPv"; - } - else - { - enum __new_mangle = "_Znwj"; - enum __delete_mangle = "_ZdlPv"; - } -} diff --git a/compiler/test/dshell/extra-files/dll_cxx/testdll.d b/compiler/test/dshell/extra-files/dll_cxx/testdll.d index 287176dce0..1c852aa104 100644 --- a/compiler/test/dshell/extra-files/dll_cxx/testdll.d +++ b/compiler/test/dshell/extra-files/dll_cxx/testdll.d @@ -24,7 +24,7 @@ extern(C++) struct S22323 void test22323() { - import cppnew; + import core.stdcpp.new_; assert(C22323.ctorCount == 0); assert(C22323.dtorCount == 0);