mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
Merge pull request #16521 from kinke/rm_cruntime_dm
Get rid of obsolete `{C,Cpp}Runtime_DigitalMars` special cases Signed-off-by: Dennis <dkorpel@users.noreply.github.com> Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com> Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
This commit is contained in:
commit
97dc44aa76
40 changed files with 61 additions and 1140 deletions
|
@ -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:
|
||||
|
|
|
@ -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=<name>",
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
|
@ -6013,10 +6012,9 @@ struct TargetCPP final
|
|||
{
|
||||
Unspecified = 0u,
|
||||
Clang = 1u,
|
||||
DigitalMars = 2u,
|
||||
Gcc = 3u,
|
||||
Microsoft = 4u,
|
||||
Sun = 5u,
|
||||
Gcc = 2u,
|
||||
Microsoft = 3u,
|
||||
Sun = 4u,
|
||||
};
|
||||
|
||||
bool reverseOverloads;
|
||||
|
|
|
@ -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");
|
||||
|
@ -1345,7 +1343,6 @@ struct TargetC
|
|||
{
|
||||
Unspecified,
|
||||
Bionic,
|
||||
DigitalMars,
|
||||
Glibc,
|
||||
Microsoft,
|
||||
Musl,
|
||||
|
@ -1448,7 +1445,6 @@ struct TargetCPP
|
|||
{
|
||||
Unspecified,
|
||||
Clang,
|
||||
DigitalMars,
|
||||
Gcc,
|
||||
Microsoft,
|
||||
Sun
|
||||
|
|
|
@ -50,7 +50,6 @@ struct TargetC
|
|||
{
|
||||
Unspecified,
|
||||
Bionic,
|
||||
DigitalMars,
|
||||
Glibc,
|
||||
Microsoft,
|
||||
Musl,
|
||||
|
@ -86,7 +85,6 @@ struct TargetCPP
|
|||
{
|
||||
Unspecified,
|
||||
Clang,
|
||||
DigitalMars,
|
||||
Gcc,
|
||||
Microsoft,
|
||||
Sun
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -14,11 +14,6 @@ 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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,6 @@ version (CRuntime_Microsoft)
|
|||
else
|
||||
static assert(S.sizeof == 0);
|
||||
|
||||
version (CRuntime_DigitalMars)
|
||||
static assert(S.alignof == 0);
|
||||
else
|
||||
static assert(S.alignof == 1);
|
||||
|
||||
extern (C++) struct T { }
|
||||
|
|
|
@ -44,7 +44,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]);
|
||||
|
||||
|
|
|
@ -1,81 +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 (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)
|
||||
{
|
||||
enum __new_mangle = "_Znwm";
|
||||
enum __delete_mangle = "_ZdlPv";
|
||||
}
|
||||
else
|
||||
{
|
||||
enum __new_mangle = "_Znwj";
|
||||
enum __delete_mangle = "_ZdlPv";
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ extern(C++) struct S22323
|
|||
|
||||
void test22323()
|
||||
{
|
||||
import cppnew;
|
||||
import core.stdcpp.new_;
|
||||
|
||||
assert(C22323.ctorCount == 0);
|
||||
assert(C22323.dtorCount == 0);
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -905,9 +905,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;
|
||||
|
|
|
@ -239,13 +239,6 @@ void test39()
|
|||
|
||||
extern(C++, "foo", "bar", "baz") int doStuff(int);
|
||||
|
||||
version(CppRuntime_DigitalMars) // DMC doesn't support c++11
|
||||
{
|
||||
void test40() {}
|
||||
void test41() {}
|
||||
}
|
||||
else
|
||||
{
|
||||
void test40();
|
||||
|
||||
void foovargs(T...)(T args)
|
||||
|
@ -270,7 +263,6 @@ else
|
|||
assert(args[0] + args[1] == 3);
|
||||
}
|
||||
alias Make_Shared_Poc = make_shared_poc!(int, int, int);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
|
|
|
@ -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() {}
|
||||
}
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
str = str[nscanned .. $];
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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 int64_t = long; ///
|
||||
alias uint64_t = ulong; ///
|
||||
|
||||
|
|
|
@ -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, ...); ///
|
||||
|
|
|
@ -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]; }
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
///
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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 refcnt = dll_getRefCount(ll_dllModule);
|
||||
return refcnt > internalReferences;
|
||||
}
|
||||
|
@ -2518,9 +2514,6 @@ 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;
|
||||
|
||||
if (needRef)
|
||||
|
|
|
@ -473,9 +473,6 @@ FILE* openOrCreateFile(string name)
|
|||
|
||||
version (Windows) HANDLE handle(int fd)
|
||||
{
|
||||
version (CRuntime_DigitalMars)
|
||||
return _fdToHandle(fd);
|
||||
else
|
||||
return cast(HANDLE)_get_osfhandle(fd);
|
||||
}
|
||||
|
||||
|
|
|
@ -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+/;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue