Skip to content

Commit a5a12f8

Browse files
authored
Importc: fix glibc aarch64 math.h (dlang#21772)
* importc: Support math.h on glibc aarch64 Signed-off-by: Andrei Horodniceanu <[email protected]> * compiler/test/compilable/stdcheaders: Reenable math.h on linux aarch64 Signed-off-by: Andrei Horodniceanu <[email protected]> --------- Signed-off-by: Andrei Horodniceanu <[email protected]>
1 parent e8a67c0 commit a5a12f8

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

compiler/test/compilable/stdcheaders.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
#include <limits.h>
2020
#include <locale.h>
2121

22-
#if !(defined(__linux__) && defined(__aarch64__)) // /usr/include/bits/math-vector.h(162): Error: undefined identifier `__Float32x4_t`
2322
#include <math.h>
2423
#ifndef _MSC_VER // C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt\corecrt_math.h(93): Error: reinterpretation through overlapped field `f` is not allowed in CTFE
2524
float x = NAN;
2625
#endif
27-
#endif
2826

2927
#ifndef _MSC_VER // setjmp.h(51): Error: missing tag `identifier` after `struct
3028
#include <setjmp.h>
@@ -64,11 +62,9 @@ float x = NAN;
6462
// Apple: /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/tgmath.h(39): Error: named parameter required before `...`
6563
// OpenBSD: /usr/lib/clang/13.0.0/include/tgmath.h(34): Error: named parameter required before `...`
6664
// Linux: /tmp/clang/lib/clang/15.0.3/include/tgmath.h(34): Error: named parameter required before `...`
67-
#if !(defined(__linux__) && defined(__aarch64__)) // /usr/include/bits/math-vector.h(162): Error: undefined identifier `__Float32x4_t`
6865
#include <tgmath.h>
6966
#endif
7067
#endif
71-
#endif
7268

7369
#ifndef __linux__
7470
#ifndef __APPLE__

druntime/src/__importc_builtins.di

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,10 @@ version (DigitalMars)
111111
ulong a, b;
112112
}
113113
}
114+
115+
version (CRuntime_Glibc) version (AArch64)
116+
{
117+
// math.h needs these
118+
alias __Float32x4_t = __vector(float[4]);
119+
alias __Float64x2_t = __vector(double[2]);
120+
}

druntime/src/importc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,16 @@ typedef unsigned long long __uint64_t;
186186
#define _Float128 long double
187187
#define __float128 long double
188188
#endif
189+
190+
#ifdef __aarch64__
191+
// glibc's math.h needs these types to be defined
192+
typedef struct {} __SVBool_t;
193+
typedef struct {} __SVFloat32_t;
194+
typedef struct {} __SVFloat64_t;
189195
#endif
190196

197+
#endif // __linux__
198+
191199
#if __APPLE__
192200
#undef __SIZEOF_INT128__
193201
#endif

0 commit comments

Comments
 (0)