Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit f2f1a0a

Browse files
authored
Merge pull request #2242 from joakim-noah/android
Add fixes to get Android/AArch64 working merged-on-behalf-of: Steven Schveighoffer <schveiguy@users.noreply.github.com>
2 parents 3574f0a + 9518c61 commit f2f1a0a

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

src/core/stdc/stdlib.d

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,9 @@ else version (MinGW)
135135
///
136136
alias __mingw_strtold strtold;
137137
}
138-
else version (CRuntime_Bionic)
139-
{
140-
///
141-
real strtold(scope inout(char)* nptr, scope inout(char)** endptr)
142-
{ // Fake it again till we make it
143-
return strtod(nptr, endptr);
144-
}
145-
}
146138
else
147139
{
148-
///
140+
/// Added to Bionic since Lollipop.
149141
real strtold(scope inout(char)* nptr, scope inout(char)** endptr);
150142
}
151143

src/core/sys/posix/sys/types.d

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,37 +1056,40 @@ else version( CRuntime_Bionic )
10561056
size_t guard_size;
10571057
int sched_policy;
10581058
int sched_priority;
1059-
version(AArch64) char[16] __reserved;
1059+
version(D_LP64) char[16] __reserved;
10601060
}
10611061

10621062
struct pthread_cond_t
10631063
{
1064-
int value; //volatile
1064+
version(D_LP64)
1065+
int[12] __private;
1066+
else
1067+
int[1] __private;
10651068
}
10661069

10671070
alias c_long pthread_condattr_t;
10681071
alias int pthread_key_t;
10691072

10701073
struct pthread_mutex_t
10711074
{
1072-
int value; //volatile
1075+
version(D_LP64)
1076+
int[10] __private;
1077+
else
1078+
int[1] __private;
10731079
}
10741080

10751081
alias c_long pthread_mutexattr_t;
1076-
alias int pthread_once_t; //volatile
1082+
alias int pthread_once_t;
10771083

10781084
struct pthread_rwlock_t
10791085
{
1080-
pthread_mutex_t lock;
1081-
pthread_cond_t cond;
1082-
int numLocks;
1083-
int writerThreadId;
1084-
int pendingReaders;
1085-
int pendingWriters;
1086-
void*[4] reserved;
1086+
version(D_LP64)
1087+
int[14] __private;
1088+
else
1089+
int[10] __private;
10871090
}
10881091

1089-
alias int pthread_rwlockattr_t;
1092+
alias c_long pthread_rwlockattr_t;
10901093
alias c_long pthread_t;
10911094
}
10921095
else version ( CRuntime_UClibc )

src/rt/sections_android.d

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ void initSections() nothrow @nogc
6969

7070
auto pbeg = cast(void*)&_tlsend;
7171
auto pend = cast(void*)&__bss_end__;
72+
// _tlsend is a 32-bit int and may not be 64-bit void*-aligned, so align pbeg.
73+
version(D_LP64) pbeg = cast(void*)(cast(size_t)(pbeg + 7) & ~cast(size_t)7);
7274
_sections._gcRanges[0] = pbeg[0 .. pend - pbeg];
7375
}
7476

@@ -129,6 +131,17 @@ else version(ARM)
129131
return tls.ptr + offset;
130132
}
131133
}
134+
else version(AArch64)
135+
{
136+
extern(C) void* __tls_get_addr( void* p ) nothrow @nogc
137+
{
138+
debug(PRINTF) printf(" __tls_get_addr input - %p\n", p);
139+
immutable offset = cast(size_t)(p - cast(void*)&_tlsstart);
140+
auto tls = getTLSBlockAlloc();
141+
assert(offset < tls.length);
142+
return tls.ptr + offset;
143+
}
144+
}
132145
else
133146
static assert( false, "Android architecture not supported." );
134147

@@ -182,7 +195,7 @@ extern(C)
182195

183196
size_t __bss_end__;
184197

185-
void* _tlsstart;
186-
void* _tlsend;
198+
int _tlsstart;
199+
int _tlsend;
187200
}
188201
}

0 commit comments

Comments
 (0)