mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 13:40:20 +03:00
use CRuntime_DigitalMars/CRuntime_Microsoft instead of Win32/Win64 where appropriate
This commit is contained in:
parent
46f344490b
commit
3ed25d61ae
7 changed files with 132 additions and 39 deletions
|
@ -1,5 +1,6 @@
|
|||
# Makefile for zlib64
|
||||
|
||||
MODEL=64
|
||||
VCDIR=\Program Files (x86)\Microsoft Visual Studio 10.0\VC
|
||||
|
||||
CC="$(VCDIR)\bin\amd64\cl"
|
||||
|
@ -78,14 +79,14 @@ example.obj: example.c zlib.h zconf.h
|
|||
minigzip.obj: minigzip.c zlib.h zconf.h
|
||||
$(CC) /c $(cvarsdll) $(CFLAGS) $*.c
|
||||
|
||||
zlib64.lib: $(OBJS)
|
||||
$(LIB) $(LIBFLAGS) /OUT:zlib64.lib $(OBJS)
|
||||
zlib$(MODEL).lib: $(OBJS)
|
||||
$(LIB) $(LIBFLAGS) /OUT:zlib$(MODEL).lib $(OBJS)
|
||||
|
||||
example.exe: example.obj zlib64.lib
|
||||
$(LD) $(LDFLAGS) example.obj zlib64.lib
|
||||
example.exe: example.obj zlib$(MODEL).lib
|
||||
$(LD) $(LDFLAGS) example.obj zlib$(MODEL).lib
|
||||
|
||||
minigzip.exe: minigzip.obj zlib64.lib
|
||||
$(LD) $(LDFLAGS) minigzip.obj zlib64.lib
|
||||
minigzip.exe: minigzip.obj zlib$(MODEL).lib
|
||||
$(LD) $(LDFLAGS) minigzip.obj zlib$(MODEL).lib
|
||||
|
||||
test: example.exe minigzip.exe
|
||||
example
|
||||
|
|
|
@ -2891,7 +2891,7 @@ unittest
|
|||
ld = parse!real(s2);
|
||||
assert(s2.empty);
|
||||
x = *cast(longdouble *)&ld;
|
||||
version (Win64)
|
||||
version (CRuntime_Microsoft)
|
||||
ld1 = 0x1.FFFFFFFFFFFFFFFEp-16382L; // strtold currently mapped to strtod
|
||||
else version (Android)
|
||||
ld1 = 0x1.FFFFFFFFFFFFFFFEp-16382L; // strtold currently mapped to strtod
|
||||
|
|
14
std/format.d
14
std/format.d
|
@ -29,7 +29,7 @@ import std.algorithm, std.ascii, std.conv,
|
|||
std.exception, std.range,
|
||||
std.system, std.traits, std.typetuple,
|
||||
std.utf;
|
||||
version (Win64) {
|
||||
version (CRuntime_Microsoft) {
|
||||
import std.math : isnan, isInfinity;
|
||||
}
|
||||
version(unittest) {
|
||||
|
@ -41,7 +41,7 @@ version(unittest) {
|
|||
import std.string;
|
||||
}
|
||||
|
||||
version (Win32) version (DigitalMars)
|
||||
version(CRuntime_DigitalMars)
|
||||
{
|
||||
version = DigitalMarsC;
|
||||
}
|
||||
|
@ -1598,7 +1598,7 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char))
|
|||
enforceFmt(std.algorithm.find("fgFGaAeEs", fs.spec).length,
|
||||
"floating");
|
||||
|
||||
version (Win64)
|
||||
version (CRuntime_Microsoft)
|
||||
{
|
||||
double tval = val; // convert early to get "inf" in case of overflow
|
||||
string s;
|
||||
|
@ -3421,7 +3421,7 @@ unittest
|
|||
assert(stream.data == "1.67 -0XA.3D70A3D70A3D8P-3 nan",
|
||||
stream.data);
|
||||
}
|
||||
else version (Win64)
|
||||
else version (CRuntime_Microsoft)
|
||||
{
|
||||
assert(stream.data == "1.67 -0X1.47AE14P+0 nan",
|
||||
stream.data);
|
||||
|
@ -3458,7 +3458,7 @@ unittest
|
|||
|
||||
formattedWrite(stream, "%a %A", 1.32, 6.78f);
|
||||
//formattedWrite(stream, "%x %X", 1.32);
|
||||
version (Win64)
|
||||
version (CRuntime_Microsoft)
|
||||
assert(stream.data == "0x1.51eb85p+0 0X1.B1EB86P+2");
|
||||
else version (Android)
|
||||
{
|
||||
|
@ -5147,7 +5147,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
|
|||
{
|
||||
sl = fbuf.length;
|
||||
int n;
|
||||
version (Win64)
|
||||
version (CRuntime_Microsoft)
|
||||
{
|
||||
if (isnan(v)) // snprintf writes 1.#QNAN
|
||||
n = snprintf(fbuf.ptr, sl, "nan");
|
||||
|
@ -5970,7 +5970,7 @@ unittest
|
|||
//else
|
||||
version (MinGW)
|
||||
assert(s == "1.67 -0XA.3D70A3D70A3D8P-3 nan", s);
|
||||
else version (Win64)
|
||||
else version (CRuntime_Microsoft)
|
||||
assert(s == "1.67 -0X1.47AE14P+0 nan", s);
|
||||
else version (Android)
|
||||
{
|
||||
|
|
115
std/math.d
115
std/math.d
|
@ -146,7 +146,7 @@ version(unittest)
|
|||
|
||||
int ix;
|
||||
int iy;
|
||||
version(Win64)
|
||||
version(CRuntime_Microsoft)
|
||||
alias double real_t;
|
||||
else
|
||||
alias real real_t;
|
||||
|
@ -1966,7 +1966,7 @@ unittest
|
|||
assert(feqrel(exp2(0.5L), SQRT2) >= real.mant_dig -1);
|
||||
assert(exp2(8.0L) == 256.0);
|
||||
assert(exp2(-9.0L)== 1.0L/512.0);
|
||||
version(Win64) {} else // aexp2/exp2f/exp2l not implemented
|
||||
version(CRuntime_Microsoft) {} else // aexp2/exp2f/exp2l not implemented
|
||||
{
|
||||
assert( core.stdc.math.exp2f(0.0f) == 1 );
|
||||
assert( core.stdc.math.exp2 (0.0) == 1 );
|
||||
|
@ -2343,17 +2343,49 @@ int ilogb(real x) @trusted nothrow @nogc
|
|||
mov EAX,8[RSP] ;
|
||||
ret ;
|
||||
|
||||
Lzeronan:
|
||||
Lzeronan:
|
||||
mov EAX,0x80000000 ;
|
||||
fstp ST(0) ;
|
||||
ret ;
|
||||
|
||||
Linfinity:
|
||||
Linfinity:
|
||||
mov EAX,0x7FFFFFFF ;
|
||||
fstp ST(0) ;
|
||||
ret ;
|
||||
}
|
||||
}
|
||||
else version (CRuntime_Microsoft)
|
||||
{
|
||||
int res;
|
||||
asm
|
||||
{
|
||||
naked ;
|
||||
fld real ptr [x] ;
|
||||
fxam ;
|
||||
fstsw AX ;
|
||||
and AH,0x45 ;
|
||||
cmp AH,0x40 ;
|
||||
jz Lzeronan ;
|
||||
cmp AH,5 ;
|
||||
jz Linfinity ;
|
||||
cmp AH,1 ;
|
||||
jz Lzeronan ;
|
||||
fxtract ;
|
||||
fstp ST(0) ;
|
||||
fistp res ;
|
||||
mov EAX,res ;
|
||||
jmp Ldone ;
|
||||
|
||||
Lzeronan:
|
||||
mov EAX,0x80000000 ;
|
||||
fstp ST(0) ;
|
||||
|
||||
Linfinity:
|
||||
mov EAX,0x7FFFFFFF ;
|
||||
fstp ST(0) ;
|
||||
Ldone: ;
|
||||
}
|
||||
}
|
||||
else
|
||||
return core.stdc.math.ilogbl(x);
|
||||
}
|
||||
|
@ -2883,6 +2915,15 @@ real logb(real x) @trusted nothrow @nogc
|
|||
ret ;
|
||||
}
|
||||
}
|
||||
else version (CRuntime_Microsoft)
|
||||
{
|
||||
asm
|
||||
{
|
||||
fld x ;
|
||||
fxtract ;
|
||||
fstp ST(0) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
return core.stdc.math.logbl(x);
|
||||
}
|
||||
|
@ -2903,7 +2944,7 @@ real logb(real x) @trusted nothrow @nogc
|
|||
*/
|
||||
real fmod(real x, real y) @trusted nothrow @nogc
|
||||
{
|
||||
version (Win64)
|
||||
version (CRuntime_Microsoft)
|
||||
{
|
||||
return x % y;
|
||||
}
|
||||
|
@ -2924,7 +2965,7 @@ real fmod(real x, real y) @trusted nothrow @nogc
|
|||
*/
|
||||
real modf(real x, ref real i) @trusted nothrow @nogc
|
||||
{
|
||||
version (Win64)
|
||||
version (CRuntime_Microsoft)
|
||||
{
|
||||
i = trunc(x);
|
||||
return copysign(isInfinity(x) ? 0.0 : x - i, x);
|
||||
|
@ -2994,7 +3035,7 @@ unittest
|
|||
*/
|
||||
real cbrt(real x) @trusted nothrow @nogc
|
||||
{
|
||||
version (Win64)
|
||||
version (CRuntime_Microsoft)
|
||||
{
|
||||
version (INLINE_YL2X)
|
||||
return copysign(exp2(yl2x(fabs(x), 1.0L/3.0L)), x);
|
||||
|
@ -3148,6 +3189,24 @@ real ceil(real x) @trusted pure nothrow @nogc
|
|||
ret ;
|
||||
}
|
||||
}
|
||||
else version(CRuntime_Microsoft)
|
||||
{
|
||||
short cw;
|
||||
asm
|
||||
{
|
||||
fld x ;
|
||||
fstcw cw ;
|
||||
mov AL,byte ptr cw+1 ;
|
||||
mov DL,AL ;
|
||||
and AL,0xC3 ;
|
||||
or AL,0x08 ; // round to +infinity
|
||||
mov byte ptr cw+1,AL ;
|
||||
fldcw cw ;
|
||||
frndint ;
|
||||
mov byte ptr cw+1,DL ;
|
||||
fldcw cw ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Special cases.
|
||||
|
@ -3257,6 +3316,24 @@ real floor(real x) @trusted pure nothrow @nogc
|
|||
ret ;
|
||||
}
|
||||
}
|
||||
else version(CRuntime_Microsoft)
|
||||
{
|
||||
short cw;
|
||||
asm
|
||||
{
|
||||
fld x ;
|
||||
fstcw cw ;
|
||||
mov AL,byte ptr cw+1 ;
|
||||
mov DL,AL ;
|
||||
and AL,0xC3 ;
|
||||
or AL,0x04 ; // round to -infinity
|
||||
mov byte ptr cw+1,AL ;
|
||||
fldcw cw ;
|
||||
frndint ;
|
||||
mov byte ptr cw+1,DL ;
|
||||
fldcw cw ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Special cases.
|
||||
|
@ -3338,7 +3415,7 @@ unittest
|
|||
*/
|
||||
real nearbyint(real x) @trusted nothrow @nogc
|
||||
{
|
||||
version (Win64)
|
||||
version (CRuntime_Microsoft)
|
||||
{
|
||||
assert(0); // not implemented in C library
|
||||
}
|
||||
|
@ -3521,7 +3598,7 @@ unittest
|
|||
*/
|
||||
real round(real x) @trusted nothrow @nogc
|
||||
{
|
||||
version (Win64)
|
||||
version (CRuntime_Microsoft)
|
||||
{
|
||||
auto old = FloatingPointControl.getControlState();
|
||||
FloatingPointControl.setControlState((old & ~FloatingPointControl.ROUNDING_MASK) | FloatingPointControl.roundToZero);
|
||||
|
@ -3583,6 +3660,24 @@ real trunc(real x) @trusted nothrow @nogc
|
|||
ret ;
|
||||
}
|
||||
}
|
||||
else version(CRuntime_Microsoft)
|
||||
{
|
||||
short cw;
|
||||
asm
|
||||
{
|
||||
fld x ;
|
||||
fstcw cw ;
|
||||
mov AL,byte ptr cw+1 ;
|
||||
mov DL,AL ;
|
||||
and AL,0xC3 ;
|
||||
or AL,0x0C ; // round to 0
|
||||
mov byte ptr cw+1,AL ;
|
||||
fldcw cw ;
|
||||
frndint ;
|
||||
mov byte ptr cw+1,DL ;
|
||||
fldcw cw ;
|
||||
}
|
||||
}
|
||||
else
|
||||
return core.stdc.math.truncl(x);
|
||||
}
|
||||
|
@ -3611,7 +3706,7 @@ real trunc(real x) @trusted nothrow @nogc
|
|||
*/
|
||||
real remainder(real x, real y) @trusted nothrow @nogc
|
||||
{
|
||||
version (Win64)
|
||||
version (CRuntime_Microsoft)
|
||||
{
|
||||
int n;
|
||||
return remquo(x, y, n);
|
||||
|
|
|
@ -111,7 +111,7 @@ import std.internal.processinit;
|
|||
|
||||
// When the DMC runtime is used, we have to use some custom functions
|
||||
// to convert between Windows file handles and FILE*s.
|
||||
version (Win32) version (DigitalMars) version = DMC_RUNTIME;
|
||||
version (Win32) version (CRuntime_DigitalMars) version = DMC_RUNTIME;
|
||||
|
||||
|
||||
// Some of the following should be moved to druntime.
|
||||
|
|
19
std/stdio.d
19
std/stdio.d
|
@ -26,18 +26,15 @@ import std.range;
|
|||
import std.traits : Unqual, isSomeChar, isAggregateType, isSomeString,
|
||||
isIntegral, isBoolean, ParameterTypeTuple;
|
||||
|
||||
version (DigitalMars)
|
||||
version (CRuntime_Microsoft)
|
||||
{
|
||||
version (Win32)
|
||||
{
|
||||
// Specific to the way Digital Mars C does stdio
|
||||
version = DIGITAL_MARS_STDIO;
|
||||
import std.c.stdio : __fhnd_info, FHND_WCHAR, FHND_TEXT;
|
||||
}
|
||||
else version (Win64)
|
||||
{
|
||||
version = MICROSOFT_STDIO;
|
||||
}
|
||||
version = MICROSOFT_STDIO;
|
||||
}
|
||||
else version (CRuntime_DigitalMars)
|
||||
{
|
||||
// Specific to the way Digital Mars C does stdio
|
||||
version = DIGITAL_MARS_STDIO;
|
||||
import std.c.stdio : __fhnd_info, FHND_WCHAR, FHND_TEXT;
|
||||
}
|
||||
|
||||
version (Posix)
|
||||
|
|
|
@ -69,7 +69,7 @@ DOC=..\..\html\d\phobos
|
|||
## Location of druntime tree
|
||||
|
||||
DRUNTIME=..\druntime
|
||||
DRUNTIMELIB=$(DRUNTIME)\lib\druntime64.lib
|
||||
DRUNTIMELIB=$(DRUNTIME)\lib\druntime$(MODEL).lib
|
||||
|
||||
## Zlib library
|
||||
|
||||
|
@ -458,7 +458,7 @@ html : $(DOCS)
|
|||
|
||||
$(ZLIB): $(SRC_ZLIB)
|
||||
cd etc\c\zlib
|
||||
$(MAKE) -f win$(MODEL).mak zlib$(MODEL).lib "CC=\$(CC)"\"" "LIB=\$(AR)"\"" "VCDIR=$(VCDIR)"
|
||||
$(MAKE) -f win64.mak MODEL=$(MODEL) zlib$(MODEL).lib "CC=\$(CC)"\"" "LIB=\$(AR)"\"" "VCDIR=$(VCDIR)"
|
||||
cd ..\..\..
|
||||
|
||||
################## DOCS ####################################
|
||||
|
@ -801,7 +801,7 @@ phobos.zip : zip
|
|||
|
||||
clean:
|
||||
cd etc\c\zlib
|
||||
$(MAKE) -f win$(MODEL).mak clean
|
||||
$(MAKE) -f win64.mak clean
|
||||
cd ..\..\..
|
||||
del $(DOCS)
|
||||
del $(UNITTEST_OBJS) unittest.obj unittest.exe
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue