Skip to content

Commit afaaca9

Browse files
committed
math: add LDC restritions on usage of x87 extensions
This patch adds some restrictions if the library is compiled with LDC compiler targeting MSVC C runtime. Signed-off-by: Luís Ferreira <[email protected]>
1 parent 5d0cfcd commit afaaca9

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

std/math/exponential.d

+16-2
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,29 @@ import std.traits : isFloatingPoint, isIntegral, isSigned, isUnsigned, Largest,
3737
static import core.math;
3838
static import core.stdc.math;
3939

40-
version (DigitalMars)
40+
version (LDC)
41+
{
42+
version (CRuntime_Microsoft) version = LDC_MSVCRT;
43+
44+
version (LDC_MSVCRT) {}
45+
else version (Android) {}
46+
else
47+
{
48+
version (X86) version = INLINE_YL2X;
49+
version (X86_64) version = INLINE_YL2X;
50+
}
51+
}
52+
else version (DigitalMars)
4153
{
4254
version = INLINE_YL2X; // x87 has opcodes for these
4355
}
4456

4557
version (D_InlineAsm_X86) version = InlineAsm_X86_Any;
4658
version (D_InlineAsm_X86_64) version = InlineAsm_X86_Any;
4759

48-
version (InlineAsm_X86_Any) version = InlineAsm_X87;
60+
version (LDC_MSVCRT) {}
61+
else version (Android) {}
62+
else version (InlineAsm_X86_Any) version = InlineAsm_X87;
4963
version (InlineAsm_X87)
5064
{
5165
static assert(real.mant_dig == 64);

std/math/rounding.d

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,17 @@ static import core.stdc.math;
2525

2626
import std.traits : isFloatingPoint, isIntegral, Unqual;
2727

28+
version (LDC)
29+
{
30+
version (CRuntime_Microsoft) version = LDC_MSVCRT;
31+
}
32+
2833
version (D_InlineAsm_X86) version = InlineAsm_X86_Any;
2934
version (D_InlineAsm_X86_64) version = InlineAsm_X86_Any;
3035

31-
version (InlineAsm_X86_Any) version = InlineAsm_X87;
36+
version (LDC_MSVCRT) {}
37+
else version (Android) {}
38+
else version (InlineAsm_X86_Any) version = InlineAsm_X87;
3239
version (InlineAsm_X87)
3340
{
3441
static assert(real.mant_dig == 64);

std/math/trigonometry.d

+8-1
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,17 @@ module std.math.trigonometry;
4242

4343
static import core.math;
4444

45+
version (LDC)
46+
{
47+
version (CRuntime_Microsoft) version = LDC_MSVCRT;
48+
}
49+
4550
version (D_InlineAsm_X86) version = InlineAsm_X86_Any;
4651
version (D_InlineAsm_X86_64) version = InlineAsm_X86_Any;
4752

48-
version (InlineAsm_X86_Any) version = InlineAsm_X87;
53+
version (LDC_MSVCRT) {}
54+
else version (Android) {}
55+
else version (InlineAsm_X86_Any) version = InlineAsm_X87;
4956
version (InlineAsm_X87)
5057
{
5158
static assert(real.mant_dig == 64);

0 commit comments

Comments
 (0)