Joakim
6 years ago
committed by
Fredrik Fornwall
5 changed files with 95 additions and 153 deletions
@ -0,0 +1,30 @@ |
|||||
|
diff --git a/src/rt/sections_android.d b/src/rt/sections_android.d
|
||||
|
index cd8d5535..6a7fcd11 100644
|
||||
|
--- a/src/rt/sections_android.d
|
||||
|
+++ b/runtime/druntime/src/rt/sections_android.d
|
||||
|
@@ -76,7 +76,11 @@ void initSections() nothrow @nogc
|
||||
|
_sections.moduleGroup = ModuleGroup(mbeg[0 .. mend - mbeg]); |
||||
|
|
||||
|
auto pbeg = cast(void*)&_tlsend; |
||||
|
- auto pend = cast(void*)&__bss_end__;
|
||||
|
+ version(X86) auto pend = cast(void*)&_end;
|
||||
|
+ else version(X86_64) auto pend = cast(void*)& _end;
|
||||
|
+ else version(ARM) auto pend = cast(void*)& __bss_end__;
|
||||
|
+ else version(AArch64) auto pend = cast(void*)& __bss_end__;
|
||||
|
+ else static assert( false, "Android architecture not supported." );
|
||||
|
// _tlsend is a 32-bit int and may not be 64-bit void*-aligned, so align pbeg. |
||||
|
version(D_LP64) pbeg = cast(void*)(cast(size_t)(pbeg + 7) & ~cast(size_t)7); |
||||
|
_sections._gcRanges[0] = pbeg[0 .. pend - pbeg]; |
||||
|
@@ -209,7 +184,11 @@ extern(C)
|
||||
|
void* __stop_minfo; |
||||
|
} |
||||
|
|
||||
|
- size_t __bss_end__;
|
||||
|
+ version(X86) size_t _end;
|
||||
|
+ else version(X86_64) size_t _end;
|
||||
|
+ else version(ARM) size_t __bss_end__;
|
||||
|
+ else version(AArch64) size_t __bss_end__;
|
||||
|
+ else static assert( false, "Android architecture not supported." );
|
||||
|
|
||||
|
int _tlsstart; |
||||
|
int _tlsend; |
@ -1,80 +0,0 @@ |
|||||
diff --git a/src/rt/sections_android.d b/src/rt/sections_android.d
|
|
||||
index cd8d5535..6a7fcd11 100644
|
|
||||
--- a/runtime/druntime/src/rt/sections_android.d
|
|
||||
+++ b/runtime/druntime/src/rt/sections_android.d
|
|
||||
@@ -76,7 +76,11 @@ void initSections() nothrow @nogc
|
|
||||
_sections.moduleGroup = ModuleGroup(mbeg[0 .. mend - mbeg]); |
|
||||
|
|
||||
auto pbeg = cast(void*)&_tlsend; |
|
||||
- auto pend = cast(void*)&__bss_end__;
|
|
||||
+ version(X86) auto pend = cast(void*)&_end;
|
|
||||
+ else version(X86_64) auto pend = cast(void*)& _end;
|
|
||||
+ else version(ARM) auto pend = cast(void*)& __bss_end__;
|
|
||||
+ else version(AArch64) auto pend = cast(void*)& __bss_end__;
|
|
||||
+ else static assert( false, "Android architecture not supported." );
|
|
||||
// _tlsend is a 32-bit int and may not be 64-bit void*-aligned, so align pbeg. |
|
||||
version(D_LP64) pbeg = cast(void*)(cast(size_t)(pbeg + 7) & ~cast(size_t)7); |
|
||||
_sections._gcRanges[0] = pbeg[0 .. pend - pbeg]; |
|
||||
@@ -115,43 +119,14 @@ void scanTLSRanges(void[]* rng, scope void delegate(void* pbeg, void* pend) noth
|
|
||||
* the corresponding address in the TLS dynamic per-thread data. |
|
||||
*/ |
|
||||
|
|
||||
-version(X86)
|
|
||||
+extern(C) void* __tls_get_addr( void* p ) nothrow @nogc
|
|
||||
{ |
|
||||
- // NB: the compiler mangles this function as '___tls_get_addr'
|
|
||||
- // even though it is extern(D)
|
|
||||
- extern(D) void* ___tls_get_addr( void* p ) nothrow @nogc
|
|
||||
- {
|
|
||||
- debug(PRINTF) printf(" ___tls_get_addr input - %p\n", p);
|
|
||||
- immutable offset = cast(size_t)(p - cast(void*)&_tlsstart);
|
|
||||
- auto tls = getTLSBlockAlloc();
|
|
||||
- assert(offset < tls.length);
|
|
||||
- return tls.ptr + offset;
|
|
||||
- }
|
|
||||
-}
|
|
||||
-else version(ARM)
|
|
||||
-{
|
|
||||
- extern(C) void* __tls_get_addr( void** p ) nothrow @nogc
|
|
||||
- {
|
|
||||
- debug(PRINTF) printf(" __tls_get_addr input - %p\n", *p);
|
|
||||
- immutable offset = cast(size_t)(*p - cast(void*)&_tlsstart);
|
|
||||
- auto tls = getTLSBlockAlloc();
|
|
||||
- assert(offset < tls.length);
|
|
||||
- return tls.ptr + offset;
|
|
||||
- }
|
|
||||
-}
|
|
||||
-else version(AArch64)
|
|
||||
-{
|
|
||||
- extern(C) void* __tls_get_addr( void* p ) nothrow @nogc
|
|
||||
- {
|
|
||||
- debug(PRINTF) printf(" __tls_get_addr input - %p\n", p);
|
|
||||
- immutable offset = cast(size_t)(p - cast(void*)&_tlsstart);
|
|
||||
- auto tls = getTLSBlockAlloc();
|
|
||||
- assert(offset < tls.length);
|
|
||||
- return tls.ptr + offset;
|
|
||||
- }
|
|
||||
+ debug(PRINTF) printf(" __tls_get_addr input - %p\n", p);
|
|
||||
+ immutable offset = cast(size_t)(p - cast(void*)&_tlsstart);
|
|
||||
+ auto tls = getTLSBlockAlloc();
|
|
||||
+ assert(offset < tls.length);
|
|
||||
+ return tls.ptr + offset;
|
|
||||
} |
|
||||
-else
|
|
||||
- static assert( false, "Android architecture not supported." );
|
|
||||
|
|
||||
private: |
|
||||
|
|
||||
@@ -209,7 +184,11 @@ extern(C)
|
|
||||
void* __stop_minfo; |
|
||||
} |
|
||||
|
|
||||
- size_t __bss_end__;
|
|
||||
+ version(X86) size_t _end;
|
|
||||
+ else version(X86_64) size_t _end;
|
|
||||
+ else version(ARM) size_t __bss_end__;
|
|
||||
+ else version(AArch64) size_t __bss_end__;
|
|
||||
+ else static assert( false, "Android architecture not supported." );
|
|
||||
|
|
||||
int _tlsstart; |
|
||||
int _tlsend; |
|
@ -1,62 +0,0 @@ |
|||||
diff --git a/std/math.d b/std/math.d |
|
||||
index f6767b00e..efc726720 100644 |
|
||||
--- a/runtime/phobos/std/math.d |
|
||||
+++ b/runtime/phobos/std/math.d |
|
||||
@@ -140,7 +140,8 @@ version(LDC) |
|
||||
|
|
||||
version(CRuntime_Microsoft) version = LDC_MSVCRT; |
|
||||
|
|
||||
- version(LDC_MSVCRT) {} |
|
||||
+ version(LDC_MSVCRT) {} |
|
||||
+ else version(Android) {} |
|
||||
else |
|
||||
{ |
|
||||
version(X86) version = INLINE_YL2X; |
|
||||
@@ -172,7 +173,8 @@ else version(D_InlineAsm_X86_64) |
|
||||
} |
|
||||
|
|
||||
// define InlineAsm*_X87 versions if real is defined as 80-bit x87 |
|
||||
-version(LDC_MSVCRT) {} |
|
||||
+version(LDC_MSVCRT) {} |
|
||||
+else version(Android) {} |
|
||||
else |
|
||||
{ |
|
||||
version (D_InlineAsm_X86) version = InlineAsm_X86_X87; |
|
||||
@@ -7323,21 +7325,24 @@ Returns: |
|
||||
R copysign(R, X)(R to, X from) @trusted pure nothrow @nogc |
|
||||
if (isFloatingPoint!(R) && isFloatingPoint!(X)) |
|
||||
{ |
|
||||
- version(LDC) |
|
||||
- { |
|
||||
- pragma(inline, true); |
|
||||
- return llvm_copysign(to, cast(R) from); |
|
||||
- } |
|
||||
- else |
|
||||
+ version(Android) |
|
||||
{ |
|
||||
- ubyte* pto = cast(ubyte *)&to; |
|
||||
- const ubyte* pfrom = cast(ubyte *)&from; |
|
||||
+ version(X86_Any) |
|
||||
+ { |
|
||||
+ ubyte* pto = cast(ubyte *)&to; |
|
||||
+ const ubyte* pfrom = cast(ubyte *)&from; |
|
||||
|
|
||||
- alias T = floatTraits!(R); |
|
||||
- alias F = floatTraits!(X); |
|
||||
- pto[T.SIGNPOS_BYTE] &= 0x7F; |
|
||||
- pto[T.SIGNPOS_BYTE] |= pfrom[F.SIGNPOS_BYTE] & 0x80; |
|
||||
- return to; |
|
||||
+ alias T = floatTraits!(R); |
|
||||
+ alias F = floatTraits!(X); |
|
||||
+ pto[T.SIGNPOS_BYTE] &= 0x7F; |
|
||||
+ pto[T.SIGNPOS_BYTE] |= pfrom[F.SIGNPOS_BYTE] & 0x80; |
|
||||
+ return to; |
|
||||
+ } |
|
||||
+ else |
|
||||
+ { |
|
||||
+ pragma(inline, true); |
|
||||
+ return llvm_copysign(to, cast(R) from); |
|
||||
+ } |
|
||||
} |
|
||||
} |
|
||||
|
|
@ -0,0 +1,55 @@ |
|||||
|
diff --git a/dmd/globals.d b/dmd/globals.d
|
||||
|
index 464b8926..1d9befe1 100644
|
||||
|
--- a/dmd/globals.d
|
||||
|
+++ b/dmd/globals.d
|
||||
|
@@ -123,6 +123,7 @@ struct Param
|
||||
|
bool is64bit = (size_t.sizeof == 8); // generate 64 bit code; true by default for 64 bit dmd |
||||
|
bool isLP64; // generate code for LP64 |
||||
|
bool isLinux; // generate code for linux |
||||
|
+ bool isAndroid; // generate code for Android
|
||||
|
bool isOSX; // generate code for Mac OSX |
||||
|
bool isWindows; // generate code for Windows |
||||
|
bool isFreeBSD; // generate code for FreeBSD |
||||
|
diff --git a/dmd/globals.h b/dmd/globals.h
|
||||
|
index 24cd4912..df8a71bd 100644
|
||||
|
--- a/dmd/globals.h
|
||||
|
+++ b/dmd/globals.h
|
||||
|
@@ -100,6 +100,7 @@ struct Param
|
||||
|
bool is64bit; // generate 64 bit code |
||||
|
bool isLP64; // generate code for LP64 |
||||
|
bool isLinux; // generate code for linux |
||||
|
+ bool isAndroid; // generate code for Android
|
||||
|
bool isOSX; // generate code for Mac OSX |
||||
|
bool isWindows; // generate code for Windows |
||||
|
bool isFreeBSD; // generate code for FreeBSD |
||||
|
diff --git a/driver/main.cpp b/driver/main.cpp
|
||||
|
index 26c61e94..f9ec7f7b 100644
|
||||
|
--- a/driver/main.cpp
|
||||
|
+++ b/driver/main.cpp
|
||||
|
@@ -1023,6 +1023,7 @@ int cppmain(int argc, char **argv) {
|
||||
|
llvm::Triple *triple = new llvm::Triple(gTargetMachine->getTargetTriple()); |
||||
|
global.params.targetTriple = triple; |
||||
|
global.params.isLinux = triple->isOSLinux(); |
||||
|
+ global.params.isAndroid = triple->getEnvironment() == llvm::Triple::Android;
|
||||
|
global.params.isOSX = triple->isOSDarwin(); |
||||
|
global.params.isWindows = triple->isOSWindows(); |
||||
|
global.params.isFreeBSD = triple->isOSFreeBSD(); |
||||
|
diff --git a/dmd/dmangle.d b/dmd/dmangle.d
|
||||
|
index 9fa8593b..ae29e307 100644
|
||||
|
--- a/dmd/dmangle.d
|
||||
|
+++ b/dmd/dmangle.d
|
||||
|
@@ -911,9 +911,13 @@ public:
|
||||
|
buf.writestring(value < CTFloat.zero ? "NINF" : "INF"); |
||||
|
else |
||||
|
{ |
||||
|
+ version (IN_LLVM) import gen.llvmhelpers;
|
||||
|
enum BUFFER_LEN = 36; |
||||
|
char[BUFFER_LEN] buffer; |
||||
|
- const n = CTFloat.sprint(buffer.ptr, 'A', value);
|
||||
|
+ // sprintf/printf with hex formatting is broken for certain long
|
||||
|
+ // doubles on Android/x64, so use decimal format instead.
|
||||
|
+ char fmt = global.params.isAndroid && isArchx86_64() ? 'g' : 'A';
|
||||
|
+ const n = CTFloat.sprint(buffer.ptr, fmt, value);
|
||||
|
assert(n < BUFFER_LEN); |
||||
|
for (int i = 0; i < n; i++) |
||||
|
{ |
Loading…
Reference in new issue