libphobos: Backport minimal MinGW support patches.

Merges upstream druntime 1ca80e4e, phobos b5e9661a0.

Reviewed-on: https://github.com/dlang/druntime/pull/2587
	     https://github.com/dlang/phobos/pull/6981

From-SVN: r270638
This commit is contained in:
Iain Buclaw 2019-04-29 05:42:36 +00:00
parent 7d5010ee7a
commit be79ec008e
7 changed files with 53 additions and 44 deletions

View File

@ -1,4 +1,4 @@
e03164b5259a9f116eb91dfa5a18c192fa72e575 1ca80e4e0cf460575752a0c157ca52c184f4b982
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the dlang/druntime repository. merge done from the dlang/druntime repository.

View File

@ -1291,35 +1291,7 @@ size_t fwrite(scope const void* ptr, size_t size, size_t nmemb, FILE* stream);
c_long ftell(FILE* stream); c_long ftell(FILE* stream);
} }
version (MinGW) 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; }
}
///
int __mingw_snprintf(scope char* s, size_t n, scope const char* fmt, ...);
///
alias __mingw_snprintf _snprintf;
///
alias __mingw_snprintf snprintf;
///
int __mingw_vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
///
alias __mingw_vsnprintf _vsnprintf;
///
alias __mingw_vsnprintf vsnprintf;
}
else version (CRuntime_DigitalMars)
{ {
// No unsafe pointer manipulation. // No unsafe pointer manipulation.
extern (D) @trusted extern (D) @trusted
@ -1362,6 +1334,23 @@ else version (CRuntime_Microsoft)
pure int fileno(FILE* stream); pure int fileno(FILE* stream);
} }
version (MinGW)
{
int __mingw_snprintf(scope char* s, size_t n, scope const char* fmt, ...);
///
alias __mingw_snprintf _snprintf;
///
alias __mingw_snprintf snprintf;
///
int __mingw_vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
///
alias __mingw_vsnprintf _vsnprintf;
///
alias __mingw_vsnprintf vsnprintf;
}
else
{
/// ///
int _snprintf(scope char* s, size_t n, scope const char* format, ...); int _snprintf(scope char* s, size_t n, scope const char* format, ...);
/// ///
@ -1371,6 +1360,7 @@ else version (CRuntime_Microsoft)
int _vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); int _vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
/// ///
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
}
/// ///
int _fputc_nolock(int c, FILE *fp); int _fputc_nolock(int c, FILE *fp);

View File

@ -328,7 +328,9 @@ public:
*/ */
bool dll_fixTLS( HINSTANCE hInstance, void* tlsstart, void* tlsend, void* tls_callbacks_a, int* tlsindex ) nothrow bool dll_fixTLS( HINSTANCE hInstance, void* tlsstart, void* tlsend, void* tls_callbacks_a, int* tlsindex ) nothrow
{ {
version (Win64) version (GNU_EMUTLS)
return true;
else version (Win64)
return true; // fixed return true; // fixed
else version (Win32) else version (Win32)
{ {

View File

@ -49,9 +49,17 @@ version (Solaris)
import core.sys.solaris.sys.types; import core.sys.solaris.sys.types;
} }
// this should be true for most architectures version (GNU)
version (GNU_StackGrowsDown) {
import gcc.builtins;
version (GNU_StackGrowsDown)
version = StackGrowsDown;
}
else
{
// this should be true for most architectures
version = StackGrowsDown; version = StackGrowsDown;
}
/** /**
* Returns the process ID of the calling process, which is guaranteed to be * Returns the process ID of the calling process, which is guaranteed to be
@ -301,11 +309,6 @@ else version (Posix)
import core.sys.darwin.pthread : pthread_mach_thread_np; import core.sys.darwin.pthread : pthread_mach_thread_np;
} }
version (GNU)
{
import gcc.builtins;
}
// //
// Entry point for POSIX threads // Entry point for POSIX threads
// //

View File

@ -340,7 +340,15 @@ extern (C) int _d_run_main(int argc, char **argv, MainFunc mainFunc)
version (CRuntime_Microsoft) version (CRuntime_Microsoft)
{ {
// enable full precision for reals // enable full precision for reals
version (Win64) version (GNU)
{
size_t fpu_cw;
asm { "fstcw %0" : "=m" (fpu_cw); }
fpu_cw |= 0b11_00_111111; // 11: use 64 bit extended-precision
// 111111: mask all FP exceptions
asm { "fldcw %0" : "=m" (fpu_cw); }
}
else version (Win64)
asm asm
{ {
push RAX; push RAX;

View File

@ -1,4 +1,4 @@
b538f758a4d274b64751f80564b0207845cd018c b5e9661a089b6514e01fa5195c0f2bc9cc06eddd
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the dlang/phobos repository. merge done from the dlang/phobos repository.

View File

@ -174,6 +174,12 @@ else version (D_InlineAsm_X86_64)
version = InlineAsm_X86_Any; version = InlineAsm_X86_Any;
} }
version (CRuntime_Microsoft)
{
version (InlineAsm_X86_Any)
version = MSVC_InlineAsm;
}
version (X86_64) version = StaticallyHaveSSE; version (X86_64) version = StaticallyHaveSSE;
version (X86) version (OSX) version = StaticallyHaveSSE; version (X86) version (OSX) version = StaticallyHaveSSE;
@ -3692,7 +3698,7 @@ real logb(real x) @trusted nothrow @nogc
ret ; ret ;
} }
} }
else version (CRuntime_Microsoft) else version (MSVC_InlineAsm)
{ {
asm pure nothrow @nogc asm pure nothrow @nogc
{ {
@ -3979,7 +3985,7 @@ real ceil(real x) @trusted pure nothrow @nogc
ret ; ret ;
} }
} }
else version (CRuntime_Microsoft) else version (MSVC_InlineAsm)
{ {
short cw; short cw;
asm pure nothrow @nogc asm pure nothrow @nogc
@ -4107,7 +4113,7 @@ real floor(real x) @trusted pure nothrow @nogc
ret ; ret ;
} }
} }
else version (CRuntime_Microsoft) else version (MSVC_InlineAsm)
{ {
short cw; short cw;
asm pure nothrow @nogc asm pure nothrow @nogc
@ -4607,7 +4613,7 @@ real trunc(real x) @trusted nothrow @nogc
ret ; ret ;
} }
} }
else version (CRuntime_Microsoft) else version (MSVC_InlineAsm)
{ {
short cw; short cw;
asm pure nothrow @nogc asm pure nothrow @nogc