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

Commit

Permalink
Merge pull request #1490 from joakim-noah/android
Browse files Browse the repository at this point in the history
Android update
  • Loading branch information
dnadlinger committed Feb 23, 2016
2 parents a438c2c + 054a951 commit 123fca9
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 43 deletions.
6 changes: 4 additions & 2 deletions src/core/stdc/math.d
Expand Up @@ -1967,7 +1967,8 @@ else version(CRuntime_Bionic)
double ldexp(double x, int exp);
///
float ldexpf(float x, int exp);
// alias for double: real ldexpl(real x, int exp);
///
real ldexpl(real x, int exp);

///
double log(double x);
Expand Down Expand Up @@ -2009,7 +2010,8 @@ else version(CRuntime_Bionic)
double scalbn(double x, int n);
///
float scalbnf(float x, int n);
// alias for double: real scalbnl(real x, int n);
///
real scalbnl(real x, int n);

///
double scalbln(double x, c_long n);
Expand Down
3 changes: 3 additions & 0 deletions src/core/sys/linux/config.d
Expand Up @@ -23,3 +23,6 @@ enum __USE_BSD = _BSD_SOURCE;
enum __USE_SVID = _SVID_SOURCE;
enum __USE_ATFILE = _ATFILE_SOURCE;
enum __USE_GNU = _GNU_SOURCE;

// Available in bionic from API 21
version(CRuntime_Bionic) enum __WORDSIZE = 32;
4 changes: 2 additions & 2 deletions src/core/sys/posix/arpa/inet.d
Expand Up @@ -199,7 +199,7 @@ NOTE: The following must must be defined in core.sys.posix.arpa.inet to break
INET6_ADDRSTRLEN // from core.sys.posix.netinet.in_
*/

version( linux )
version( CRuntime_Glibc )
{
enum INET6_ADDRSTRLEN = 46;
}
Expand All @@ -215,7 +215,7 @@ else version( Solaris )
{
enum INET6_ADDRSTRLEN = 46;
}
else version( Android )
else version( CRuntime_Bionic )
{
enum INET6_ADDRSTRLEN = 46;
}
4 changes: 2 additions & 2 deletions src/core/sys/posix/grp.d
Expand Up @@ -38,7 +38,7 @@ group* getgrnam(in char*);
group* getgrgid(gid_t);
*/

version( linux )
version( CRuntime_Glibc )
{
struct group
{
Expand Down Expand Up @@ -78,7 +78,7 @@ else version( Solaris )
char** gr_mem;
}
}
else version( Android )
else version( CRuntime_Bionic )
{
struct group
{
Expand Down
5 changes: 3 additions & 2 deletions src/core/sys/posix/netinet/in_.d
Expand Up @@ -265,6 +265,7 @@ else version( linux )
{
INADDR_ANY = 0x00000000,
INADDR_BROADCAST = 0xffffffff,
INADDR_LOOPBACK = 0x7f000001,
INADDR_NONE = 0xFFFFFFFF
}
}
Expand Down Expand Up @@ -976,7 +977,7 @@ else version( CRuntime_Bionic )
IPPROTO_RAW
*/

version( linux )
version( CRuntime_Glibc )
{
enum uint IPPROTO_RAW = 255;
}
Expand All @@ -992,7 +993,7 @@ else version( Solaris )
{
enum uint IPPROTO_RAW = 255;
}
else version( Android )
else version( linux )
{
enum uint IPPROTO_RAW = 255;
}
4 changes: 2 additions & 2 deletions src/core/sys/posix/netinet/tcp.d
Expand Up @@ -26,7 +26,7 @@ extern (C):
TCP_NODELAY
*/

version( linux )
version( CRuntime_Glibc )
{
enum TCP_NODELAY = 1;
}
Expand All @@ -42,7 +42,7 @@ else version( Solaris )
{
enum TCP_NODELAY = 1;
}
else version( Android )
else version( linux )
{
enum TCP_NODELAY = 1;
}
4 changes: 2 additions & 2 deletions src/core/sys/posix/pthread.d
Expand Up @@ -988,7 +988,7 @@ int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
*/

version (linux)
version (CRuntime_Glibc)
{
int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
int pthread_condattr_setpshared(pthread_condattr_t*, int);
Expand Down Expand Up @@ -1024,7 +1024,7 @@ else version (Solaris)
int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
}
else version (Android)
else version (CRuntime_Bionic)
{
int pthread_condattr_getpshared(pthread_condattr_t*, int*);
int pthread_condattr_setpshared(pthread_condattr_t*, int);
Expand Down
4 changes: 2 additions & 2 deletions src/core/sys/posix/sched.d
Expand Up @@ -132,7 +132,7 @@ int sched_setscheduler(pid_t, int, in sched_param*);
int sched_yield();
*/

version( linux )
version( CRuntime_Glibc )
{
int sched_yield();
}
Expand All @@ -148,7 +148,7 @@ else version (Solaris)
{
int sched_yield();
}
else version (Android)
else version (CRuntime_Bionic)
{
int sched_yield();
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/sys/posix/semaphore.d
Expand Up @@ -125,7 +125,7 @@ int sem_wait(sem_t*);
int sem_timedwait(sem_t*, in timespec*);
*/

version( linux )
version( CRuntime_Glibc )
{
int sem_timedwait(sem_t*, in timespec*);
}
Expand All @@ -141,7 +141,7 @@ else version (Solaris)
{
int sem_timedwait(sem_t*, in timespec*);
}
else version( Android )
else version( CRuntime_Bionic )
{
int sem_timedwait(sem_t*, in timespec*);
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/sys/posix/signal.d
Expand Up @@ -125,7 +125,7 @@ version( Solaris )
return sig;
}
}
else version( linux )
else version( CRuntime_Glibc )
{
private extern (C) nothrow @nogc
{
Expand Down Expand Up @@ -2112,7 +2112,7 @@ int pthread_kill(pthread_t, int);
int pthread_sigmask(int, in sigset_t*, sigset_t*);
*/

version( linux )
version( CRuntime_Glibc )
{
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, in sigset_t*, sigset_t*);
Expand All @@ -2132,7 +2132,7 @@ else version (Solaris)
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, in sigset_t*, sigset_t*);
}
else version( Android )
else version( CRuntime_Bionic )
{
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, in sigset_t*, sigset_t*);
Expand Down
4 changes: 2 additions & 2 deletions src/core/sys/posix/stdlib.d
Expand Up @@ -104,7 +104,7 @@ int setenv(in char*, in char*, int);
int unsetenv(in char*);
*/

version( linux )
version( CRuntime_Glibc )
{
int setenv(in char*, in char*, int);
int unsetenv(in char*);
Expand All @@ -125,7 +125,7 @@ else version( FreeBSD )

void* valloc(size_t); // LEGACY non-standard
}
else version( Android )
else version( CRuntime_Bionic )
{
int setenv(in char*, in char*, int);
int unsetenv(in char*);
Expand Down
8 changes: 4 additions & 4 deletions src/core/sys/posix/sys/mman.d
Expand Up @@ -97,7 +97,7 @@ PROT_EXEC
PROT_NONE
*/

version( linux )
version( CRuntime_Glibc )
{
enum PROT_NONE = 0x0;
enum PROT_READ = 0x1;
Expand Down Expand Up @@ -125,7 +125,7 @@ else version (Solaris)
enum PROT_WRITE = 0x02;
enum PROT_EXEC = 0x04;
}
else version (Android)
else version (CRuntime_Bionic)
{
enum PROT_NONE = 0x00;
enum PROT_READ = 0x01;
Expand Down Expand Up @@ -458,7 +458,7 @@ int mlock(in void*, size_t);
int munlock(in void*, size_t);
*/

version( linux )
version( CRuntime_Glibc )
{
int mlock(in void*, size_t);
int munlock(in void*, size_t);
Expand All @@ -478,7 +478,7 @@ else version (Solaris)
int mlock(in void*, size_t);
int munlock(in void*, size_t);
}
else version (Android)
else version (CRuntime_Bionic)
{
int mlock(in void*, size_t);
int munlock(in void*, size_t);
Expand Down
4 changes: 2 additions & 2 deletions src/core/sys/posix/time.d
Expand Up @@ -317,7 +317,7 @@ tm* gmtime_r(in time_t*, tm*);
tm* localtime_r(in time_t*, tm*);
*/

version( linux )
version( CRuntime_Glibc )
{
char* asctime_r(in tm*, char*);
char* ctime_r(in time_t*, char*);
Expand Down Expand Up @@ -345,7 +345,7 @@ else version (Solaris)
tm* gmtime_r(in time_t*, tm*);
tm* localtime_r(in time_t*, tm*);
}
else version (Android)
else version (CRuntime_Bionic)
{
char* asctime_r(in tm*, char*);
char* ctime_r(in time_t*, char*);
Expand Down
4 changes: 2 additions & 2 deletions src/core/sys/posix/unistd.d
Expand Up @@ -1094,7 +1094,7 @@ else version( Solaris )
int fsync(int);
*/

version( linux )
version( CRuntime_Glibc )
{
int fsync(int) @trusted;
}
Expand All @@ -1106,7 +1106,7 @@ else version( FreeBSD )
{
int fsync(int) @trusted;
}
else version( Android )
else version( CRuntime_Bionic )
{
int fsync(int) @trusted;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/sys/posix/utime.d
Expand Up @@ -35,7 +35,7 @@ struct utimbuf
int utime(in char*, in utimbuf*);
*/

version( linux )
version( CRuntime_Glibc )
{
struct utimbuf
{
Expand Down Expand Up @@ -75,7 +75,7 @@ else version( Solaris )

int utime(in char*, in utimbuf*);
}
else version( Android )
else version( CRuntime_Bionic )
{
struct utimbuf
{
Expand Down
2 changes: 1 addition & 1 deletion src/rt/backtrace/dwarf.d
Expand Up @@ -12,7 +12,7 @@

module rt.backtrace.dwarf;

version(linux) version = linux_or_freebsd;
version(CRuntime_Glibc) version = linux_or_freebsd;
else version(FreeBSD) version = linux_or_freebsd;

version(linux_or_freebsd):
Expand Down
38 changes: 27 additions & 11 deletions src/rt/sections_android.d
Expand Up @@ -67,8 +67,8 @@ void initSections()
auto mend = cast(immutable ModuleInfo**)&__stop_minfo;
_sections.moduleGroup = ModuleGroup(mbeg[0 .. mend - mbeg]);

auto pbeg = cast(void*)&etext;
auto pend = cast(void*)&_end;
auto pbeg = cast(void*)&_tls_end;
auto pend = cast(void*)&__bss_end__;
_sections._gcRanges[0] = pbeg[0 .. pend - pbeg];
}

Expand Down Expand Up @@ -105,15 +105,32 @@ void scanTLSRanges(void[]* rng, scope void delegate(void* pbeg, void* pend) noth
* the corresponding address in the TLS dynamic per-thread data.
*/

// NB: the compiler mangles this function as '___tls_get_addr' even though it is extern(D)
extern(D) void* ___tls_get_addr( void* p )
version(X86)
{
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;
// NB: the compiler mangles this function as '___tls_get_addr'
// even though it is extern(D)
extern(D) void* ___tls_get_addr( void* p )
{
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 )
{
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:

Expand Down Expand Up @@ -163,8 +180,7 @@ extern(C)
void* __start_minfo;
void* __stop_minfo;

size_t etext;
size_t _end;
size_t __bss_end__;

void* _tlsstart;
void* _tlsend;
Expand Down

0 comments on commit 123fca9

Please sign in to comment.