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

Commit 3e9a1f2

Browse files
authored
Merge pull request #2325 from joakim-noah/android
Bionic: Add x64 declarations, switch to single TLS function, and define __USE_GNU merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2 parents d891e38 + 2a9dfa3 commit 3e9a1f2

File tree

11 files changed

+136
-342
lines changed

11 files changed

+136
-342
lines changed

src/core/stdc/fenv.d

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,24 @@ else version (CRuntime_Bionic)
322322

323323
alias uint fexcept_t;
324324
}
325+
else version (X86_64)
326+
{
327+
struct fenv_t
328+
{
329+
struct _x87
330+
{
331+
uint __control;
332+
uint __status;
333+
uint __tag;
334+
uint[4] __others;
335+
}
336+
_x87 __x87;
337+
338+
uint __mxcsr;
339+
}
340+
341+
alias uint fexcept_t;
342+
}
325343
else
326344
{
327345
static assert(false, "Architecture not supported.");

src/core/sys/posix/config.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ else version (CRuntime_UClibc)
107107
else
108108
enum __WORDSIZE=32;
109109
}
110+
else version (CRuntime_Bionic)
111+
{
112+
enum __USE_GNU = false;
113+
}
110114
else version (Solaris)
111115
{
112116
enum _FILE_OFFSET_BITS = 64;

src/core/sys/posix/fcntl.d

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -744,42 +744,21 @@ else version (CRuntime_Bionic)
744744
enum F_WRLCK = 1;
745745
enum F_UNLCK = 2;
746746

747-
version (X86)
748-
{
749-
enum O_CREAT = 0x40; // octal 0100
750-
enum O_EXCL = 0x80; // octal 0200
751-
enum O_NOCTTY = 0x100; // octal 0400
752-
enum O_TRUNC = 0x200; // octal 01000
747+
enum O_CREAT = 0x40; // octal 0100
748+
enum O_EXCL = 0x80; // octal 0200
749+
enum O_NOCTTY = 0x100; // octal 0400
750+
enum O_TRUNC = 0x200; // octal 01000
753751

754-
enum O_APPEND = 0x400; // octal 02000
755-
enum O_NONBLOCK = 0x800; // octal 04000
756-
enum O_SYNC = 0x1000; // octal 010000
757-
}
758-
else version (ARM)
759-
{
760-
enum O_CREAT = 0x40; // octal 0100
761-
enum O_EXCL = 0x80; // octal 0200
762-
enum O_NOCTTY = 0x100; // octal 0400
763-
enum O_TRUNC = 0x200; // octal 01000
752+
enum O_APPEND = 0x400; // octal 02000
753+
enum O_NONBLOCK = 0x800; // octal 04000
764754

765-
enum O_APPEND = 0x400; // octal 02000
766-
enum O_NONBLOCK = 0x800; // octal 04000
767-
enum O_SYNC = 0x1000; // octal 010000
768-
}
769-
else version (AArch64)
755+
version (D_LP64)
770756
{
771-
enum O_CREAT = 0x40; // octal 0100
772-
enum O_EXCL = 0x80; // octal 0200
773-
enum O_NOCTTY = 0x100; // octal 0400
774-
enum O_TRUNC = 0x200; // octal 01000
775-
776-
enum O_APPEND = 0x400; // octal 02000
777-
enum O_NONBLOCK = 0x800; // octal 04000
778-
enum O_SYNC = 0x101000; // octal 04010000
757+
enum O_SYNC = 0x101000; // octal 04010000
779758
}
780759
else
781760
{
782-
static assert(false, "Architecture not supported.");
761+
enum O_SYNC = 0x1000; // octal 010000
783762
}
784763

785764
enum O_ACCMODE = 0x3;

src/core/sys/posix/setjmp.d

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ else version (CRuntime_Bionic)
269269
{
270270
enum _JBLEN = 32;
271271
}
272+
else version (X86_64)
273+
{
274+
enum _JBLEN = 11;
275+
}
272276
else
273277
{
274278
static assert(false, "Architecture not supported.");
@@ -480,4 +484,4 @@ else version (CRuntime_UClibc)
480484
{
481485
int _setjmp(ref jmp_buf);
482486
void _longjmp(ref jmp_buf, int);
483-
}
487+
}

src/core/sys/posix/signal.d

Lines changed: 31 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -775,22 +775,22 @@ else version (CRuntime_UClibc)
775775
}
776776
else version (CRuntime_Bionic)
777777
{
778-
version (X86)
778+
version (D_LP64)
779779
{
780780
struct sigaction_t
781781
{
782+
int sa_flags;
782783
union
783784
{
784785
sigfn_t sa_handler;
785786
sigactfn_t sa_sigaction;
786787
}
787788

788789
sigset_t sa_mask;
789-
int sa_flags;
790790
void function() sa_restorer;
791791
}
792792
}
793-
else version (ARM)
793+
else
794794
{
795795
struct sigaction_t
796796
{
@@ -805,25 +805,6 @@ else version (CRuntime_Bionic)
805805
void function() sa_restorer;
806806
}
807807
}
808-
else version (AArch64)
809-
{
810-
struct sigaction_t
811-
{
812-
int sa_flags;
813-
union
814-
{
815-
sigfn_t sa_handler;
816-
sigactfn_t sa_sigaction;
817-
}
818-
819-
sigset_t sa_mask;
820-
void function() sa_restorer;
821-
}
822-
}
823-
else
824-
{
825-
static assert(false, "Architecture not supported.");
826-
}
827808
}
828809
else version (Darwin)
829810
{
@@ -1507,19 +1488,24 @@ else version (CRuntime_Bionic)
15071488

15081489
version (X86)
15091490
{
1510-
alias c_ulong sigset_t;
1491+
alias uint sigset_t;
15111492
enum int LONG_BIT = 32;
15121493
}
15131494
else version (ARM)
15141495
{
1515-
alias c_ulong sigset_t;
1496+
alias uint sigset_t;
15161497
enum int LONG_BIT = 32;
15171498
}
15181499
else version (AArch64)
15191500
{
15201501
struct sigset_t { ulong[1] sig; }
15211502
enum int LONG_BIT = 64;
15221503
}
1504+
else version (X86_64)
1505+
{
1506+
alias ulong sigset_t;
1507+
enum int LONG_BIT = 64;
1508+
}
15231509
else
15241510
{
15251511
static assert(false, "Architecture not supported.");
@@ -2995,93 +2981,30 @@ else version (Solaris)
29952981
}
29962982
else version (CRuntime_Bionic)
29972983
{
2998-
version (X86)
2999-
{
3000-
enum SIGPOLL = 29;
3001-
enum SIGPROF = 27;
3002-
enum SIGSYS = 31;
3003-
enum SIGTRAP = 5;
3004-
enum SIGVTALRM = 26;
3005-
enum SIGXCPU = 24;
3006-
enum SIGXFSZ = 25;
3007-
3008-
enum SA_ONSTACK = 0x08000000;
3009-
enum SA_RESETHAND = 0x80000000;
3010-
enum SA_RESTART = 0x10000000;
3011-
enum SA_SIGINFO = 4;
3012-
enum SA_NOCLDWAIT = 2;
3013-
enum SA_NODEFER = 0x40000000;
3014-
enum SS_ONSTACK = 1;
3015-
enum SS_DISABLE = 2;
3016-
enum MINSIGSTKSZ = 2048;
3017-
enum SIGSTKSZ = 8192;
2984+
enum SIGPOLL = 29;
2985+
enum SIGPROF = 27;
2986+
enum SIGSYS = 31;
2987+
enum SIGTRAP = 5;
2988+
enum SIGVTALRM = 26;
2989+
enum SIGXCPU = 24;
2990+
enum SIGXFSZ = 25;
30182991

3019-
struct stack_t
3020-
{
3021-
void* ss_sp;
3022-
int ss_flags;
3023-
size_t ss_size;
3024-
}
3025-
}
3026-
else version (ARM)
3027-
{
3028-
enum SIGPOLL = 29;
3029-
enum SIGPROF = 27;
3030-
enum SIGSYS = 31;
3031-
enum SIGTRAP = 5;
3032-
enum SIGVTALRM = 26;
3033-
enum SIGXCPU = 24;
3034-
enum SIGXFSZ = 25;
3035-
3036-
enum SA_ONSTACK = 0x08000000;
3037-
enum SA_RESETHAND = 0x80000000;
3038-
enum SA_RESTART = 0x10000000;
3039-
enum SA_SIGINFO = 4;
3040-
enum SA_NOCLDWAIT = 2;
3041-
enum SA_NODEFER = 0x40000000;
3042-
enum SS_ONSTACK = 1;
3043-
enum SS_DISABLE = 2;
3044-
enum MINSIGSTKSZ = 2048;
3045-
enum SIGSTKSZ = 8192;
3046-
3047-
struct stack_t
3048-
{
3049-
void* ss_sp;
3050-
int ss_flags;
3051-
size_t ss_size;
3052-
}
3053-
}
3054-
else version (AArch64)
3055-
{
3056-
enum SIGPOLL = 29;
3057-
enum SIGPROF = 27;
3058-
enum SIGSYS = 31;
3059-
enum SIGTRAP = 5;
3060-
enum SIGVTALRM = 26;
3061-
enum SIGXCPU = 24;
3062-
enum SIGXFSZ = 25;
3063-
3064-
enum SA_ONSTACK = 0x08000000;
3065-
enum SA_RESETHAND = 0x80000000;
3066-
enum SA_RESTART = 0x10000000;
3067-
enum SA_SIGINFO = 4;
3068-
enum SA_NOCLDWAIT = 2;
3069-
enum SA_NODEFER = 0x40000000;
3070-
enum SS_ONSTACK = 1;
3071-
enum SS_DISABLE = 2;
3072-
enum MINSIGSTKSZ = 2048;
3073-
enum SIGSTKSZ = 8192;
2992+
enum SA_ONSTACK = 0x08000000;
2993+
enum SA_RESETHAND = 0x80000000;
2994+
enum SA_RESTART = 0x10000000;
2995+
enum SA_SIGINFO = 4;
2996+
enum SA_NOCLDWAIT = 2;
2997+
enum SA_NODEFER = 0x40000000;
2998+
enum SS_ONSTACK = 1;
2999+
enum SS_DISABLE = 2;
3000+
enum MINSIGSTKSZ = 2048;
3001+
enum SIGSTKSZ = 8192;
30743002

3075-
struct stack_t
3076-
{
3077-
void* ss_sp;
3078-
int ss_flags;
3079-
size_t ss_size;
3080-
}
3081-
}
3082-
else
3003+
struct stack_t
30833004
{
3084-
static assert(false, "Architecture not supported.");
3005+
void* ss_sp;
3006+
int ss_flags;
3007+
size_t ss_size;
30853008
}
30863009

30873010
enum

src/core/sys/posix/sys/ipc.d

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,22 @@ else version (DragonFlyBSD)
176176
}
177177
else version (CRuntime_Bionic)
178178
{
179-
// All except ftok are from the linux kernel headers.
180-
version (X86)
179+
// All except ftok are from the linux kernel headers. Latest Bionic headers
180+
// don't use this legacy definition anymore, consider updating.
181+
version (D_LP64)
181182
{
182183
struct ipc_perm
183184
{
184185
key_t key;
185-
ushort uid;
186-
ushort gid;
187-
ushort cuid;
188-
ushort cgid;
186+
uint uid;
187+
uint gid;
188+
uint cuid;
189+
uint cgid;
189190
mode_t mode;
190191
ushort seq;
191192
}
192193
}
193-
else version (ARM)
194+
else
194195
{
195196
struct ipc_perm
196197
{
@@ -203,23 +204,6 @@ else version (CRuntime_Bionic)
203204
ushort seq;
204205
}
205206
}
206-
else version (AArch64)
207-
{
208-
struct ipc_perm
209-
{
210-
key_t key;
211-
uint uid;
212-
uint gid;
213-
uint cuid;
214-
uint cgid;
215-
mode_t mode;
216-
ushort seq;
217-
}
218-
}
219-
else
220-
{
221-
static assert(false, "Architecture not supported.");
222-
}
223207

224208
enum IPC_CREAT = 0x0200; // 01000
225209
enum IPC_EXCL = 0x0400; // 02000

src/core/sys/posix/sys/mman.d

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -465,23 +465,7 @@ else version (CRuntime_Bionic)
465465
enum MAP_SHARED = 0x0001;
466466
enum MAP_PRIVATE = 0x0002;
467467
enum MAP_FIXED = 0x0010;
468-
469-
version (X86)
470-
{
471-
enum MAP_ANON = 0x0020;
472-
}
473-
else version (ARM)
474-
{
475-
enum MAP_ANON = 0x0020;
476-
}
477-
else version (AArch64)
478-
{
479-
enum MAP_ANON = 0x0020;
480-
}
481-
else
482-
{
483-
static assert(false, "Architecture not supported.");
484-
}
468+
enum MAP_ANON = 0x0020;
485469

486470
enum MAP_FAILED = cast(void*)-1;
487471

0 commit comments

Comments
 (0)