Commit be79ec00 by Iain Buclaw

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
parent 7d5010ee
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.
...@@ -1291,35 +1291,7 @@ size_t fwrite(scope const void* ptr, size_t size, size_t nmemb, FILE* stream); ...@@ -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) ...@@ -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) ...@@ -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);
......
...@@ -328,7 +328,9 @@ public: ...@@ -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)
{ {
......
...@@ -49,9 +49,17 @@ version (Solaris) ...@@ -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) ...@@ -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
// //
......
...@@ -340,7 +340,15 @@ extern (C) int _d_run_main(int argc, char **argv, MainFunc mainFunc) ...@@ -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;
......
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.
...@@ -174,6 +174,12 @@ else version (D_InlineAsm_X86_64) ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment