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

Commit 551cbef

Browse files
authored
Merge pull request #2148 from joakim-noah/aarch64
Bionic bindings for AArch64 and a Glibc/AArch64 fix merged-on-behalf-of: David Nadlinger <code@klickverbot.at>
2 parents 52f2367 + df4cafb commit 551cbef

File tree

12 files changed

+201
-34
lines changed

12 files changed

+201
-34
lines changed

src/core/stdc/fenv.d

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,16 @@ else version( CRuntime_Bionic )
302302
alias uint fenv_t;
303303
alias uint fexcept_t;
304304
}
305+
else version(AArch64)
306+
{
307+
struct fenv_t
308+
{
309+
uint __control;
310+
uint __status;
311+
}
312+
313+
alias uint fexcept_t;
314+
}
305315
else
306316
{
307317
static assert(false, "Architecture not supported.");

src/core/stdc/stdlib.d

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,10 @@ else
151151
// No unsafe pointer manipulation.
152152
@trusted
153153
{
154-
version(CRuntime_Bionic)
155-
{
156-
import core.sys.posix.stdlib: lrand48, srand48;
157-
///
158-
alias core.sys.posix.stdlib.lrand48 rand;
159-
///
160-
alias core.sys.posix.stdlib.srand48 srand;
161-
}
162-
else
163-
{
164-
///
165-
int rand();
166-
///
167-
void srand(uint seed);
168-
}
154+
/// These two were added to Bionic in Lollipop.
155+
int rand();
156+
///
157+
void srand(uint seed);
169158
}
170159

171160
// We don't mark these @trusted. Given that they return a void*, one has

src/core/sys/posix/fcntl.d

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ version( CRuntime_Glibc )
9898
enum F_SETLK = 6;
9999
enum F_SETLKW = 7;
100100
}
101+
else version(AArch64)
102+
{
103+
enum F_GETLK = 5;
104+
enum F_SETLK = 6;
105+
enum F_SETLKW = 7;
106+
}
101107
else
102108
static if( __USE_FILE_OFFSET64 )
103109
{
@@ -760,6 +766,17 @@ else version( CRuntime_Bionic )
760766
enum O_NONBLOCK = 0x800; // octal 04000
761767
enum O_SYNC = 0x1000; // octal 010000
762768
}
769+
else version (AArch64)
770+
{
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
779+
}
763780
else
764781
{
765782
static assert(false, "Architecture not supported.");

src/core/sys/posix/setjmp.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ else version( CRuntime_Bionic )
259259
{
260260
enum _JBLEN = 64;
261261
}
262+
else version( AArch64 )
263+
{
264+
enum _JBLEN = 32;
265+
}
262266
else
263267
{
264268
static assert(false, "Architecture not supported.");

src/core/sys/posix/signal.d

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,28 @@ else version(NetBSD)
175175
}
176176
else version (CRuntime_Bionic)
177177
{
178-
enum SIGRTMIN = 32;
179-
version(ARM)
180-
enum SIGRTMAX = 64;
181-
else version(X86)
182-
enum SIGRTMAX = 64;
183-
else version(MIPS32)
184-
enum SIGRTMAX = 128;
185-
else
186-
static assert(false, "Architecture not supported.");
178+
// Switched to calling these functions since Lollipop
179+
private extern (C) nothrow @nogc
180+
{
181+
int __libc_current_sigrtmin();
182+
int __libc_current_sigrtmax();
183+
}
184+
185+
@property int SIGRTMIN() nothrow @nogc {
186+
__gshared static int sig = -1;
187+
if (sig == -1) {
188+
sig = __libc_current_sigrtmin();
189+
}
190+
return sig;
191+
}
192+
193+
@property int SIGRTMAX() nothrow @nogc {
194+
__gshared static int sig = -1;
195+
if (sig == -1) {
196+
sig = __libc_current_sigrtmax();
197+
}
198+
return sig;
199+
}
187200
}
188201
else version( CRuntime_UClibc )
189202
{
@@ -760,7 +773,7 @@ else version( CRuntime_UClibc )
760773
static assert(false, "Architecture not supported.");
761774
}
762775
}
763-
else version (linux)
776+
else version (CRuntime_Bionic)
764777
{
765778
version (X86)
766779
{
@@ -773,7 +786,7 @@ else version (linux)
773786
}
774787

775788
sigset_t sa_mask;
776-
c_ulong sa_flags;
789+
int sa_flags;
777790
void function() sa_restorer;
778791
}
779792
}
@@ -788,7 +801,22 @@ else version (linux)
788801
}
789802

790803
sigset_t sa_mask;
791-
c_ulong sa_flags;
804+
int sa_flags;
805+
void function() sa_restorer;
806+
}
807+
}
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;
792820
void function() sa_restorer;
793821
}
794822
}
@@ -1487,6 +1515,11 @@ else version( CRuntime_Bionic )
14871515
alias c_ulong sigset_t;
14881516
enum int LONG_BIT = 32;
14891517
}
1518+
else version (AArch64)
1519+
{
1520+
struct sigset_t { ulong[1] sig; }
1521+
enum int LONG_BIT = 64;
1522+
}
14901523
else
14911524
{
14921525
static assert(false, "Architecture not supported.");
@@ -3018,6 +3051,34 @@ else version (CRuntime_Bionic)
30183051
size_t ss_size;
30193052
}
30203053
}
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;
3074+
3075+
struct stack_t
3076+
{
3077+
void* ss_sp;
3078+
int ss_flags;
3079+
size_t ss_size;
3080+
}
3081+
}
30213082
else
30223083
{
30233084
static assert(false, "Architecture not supported.");

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,19 @@ else version( CRuntime_Bionic )
203203
ushort seq;
204204
}
205205
}
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+
}
206219
else
207220
{
208221
static assert(false, "Architecture not supported.");

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,10 @@ else version (CRuntime_Bionic)
474474
{
475475
enum MAP_ANON = 0x0020;
476476
}
477+
else version (AArch64)
478+
{
479+
enum MAP_ANON = 0x0020;
480+
}
477481
else
478482
{
479483
static assert(false, "Architecture not supported.");

src/core/sys/posix/sys/socket.d

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,42 @@ else version( CRuntime_Bionic )
17681768
SO_TYPE = 3
17691769
}
17701770
}
1771+
else version (AArch64)
1772+
{
1773+
alias ulong __kernel_size_t;
1774+
1775+
enum
1776+
{
1777+
SOCK_DGRAM = 2,
1778+
SOCK_SEQPACKET = 5,
1779+
SOCK_STREAM = 1
1780+
}
1781+
1782+
enum
1783+
{
1784+
SOL_SOCKET = 1
1785+
}
1786+
1787+
enum
1788+
{
1789+
SO_ACCEPTCONN = 30,
1790+
SO_BROADCAST = 6,
1791+
SO_DEBUG = 1,
1792+
SO_DONTROUTE = 5,
1793+
SO_ERROR = 4,
1794+
SO_KEEPALIVE = 9,
1795+
SO_LINGER = 13,
1796+
SO_OOBINLINE = 10,
1797+
SO_RCVBUF = 8,
1798+
SO_RCVLOWAT = 18,
1799+
SO_RCVTIMEO = 20,
1800+
SO_REUSEADDR = 2,
1801+
SO_SNDBUF = 7,
1802+
SO_SNDLOWAT = 19,
1803+
SO_SNDTIMEO = 21,
1804+
SO_TYPE = 3
1805+
}
1806+
}
17711807
else
17721808
{
17731809
static assert(false, "Architecture not supported.");

src/core/sys/posix/sys/stat.d

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,33 @@ else version( CRuntime_Bionic )
12121212
ulong st_ino;
12131213
}
12141214
}
1215+
else version (AArch64)
1216+
{
1217+
struct stat_t
1218+
{
1219+
ulong st_dev;
1220+
ulong st_ino;
1221+
uint st_mode;
1222+
uint st_nlink;
1223+
uid_t st_uid;
1224+
gid_t st_gid;
1225+
ulong st_rdev;
1226+
ulong __pad1;
1227+
1228+
long st_size;
1229+
int st_blksize;
1230+
int __pad2;
1231+
long st_blocks;
1232+
long st_atime;
1233+
ulong st_atime_nsec;
1234+
long st_mtime;
1235+
ulong st_mtime_nsec;
1236+
long st_ctime;
1237+
ulong st_ctime_nsec;
1238+
uint __unused4;
1239+
uint __unused5;
1240+
}
1241+
}
12151242
else
12161243
{
12171244
static assert(false, "Architecture not supported.");

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,12 @@ else version( CRuntime_Bionic )
238238
{
239239
alias c_ulong blkcnt_t;
240240
alias c_ulong blksize_t;
241-
alias uint dev_t;
241+
alias size_t dev_t;
242242
alias uint gid_t;
243243
alias c_ulong ino_t;
244244
alias c_long off_t;
245245
alias int pid_t;
246-
alias int ssize_t;
246+
alias c_long ssize_t;
247247
alias c_long time_t;
248248
alias uint uid_t;
249249

@@ -262,6 +262,11 @@ else version( CRuntime_Bionic )
262262
alias ushort mode_t;
263263
alias ushort nlink_t;
264264
}
265+
else version(AArch64)
266+
{
267+
alias uint mode_t;
268+
alias uint nlink_t;
269+
}
265270
else version(MIPS32)
266271
{
267272
alias uint mode_t;
@@ -418,7 +423,7 @@ else version( CRuntime_Bionic )
418423
alias uint id_t;
419424
alias int key_t;
420425
alias c_long suseconds_t;
421-
alias c_long useconds_t;
426+
alias uint useconds_t; // Updated in Lollipop
422427
}
423428
else version( CRuntime_Musl )
424429
{
@@ -1051,6 +1056,7 @@ else version( CRuntime_Bionic )
10511056
size_t guard_size;
10521057
int sched_policy;
10531058
int sched_priority;
1059+
version(AArch64) char[16] __reserved;
10541060
}
10551061

10561062
struct pthread_cond_t

0 commit comments

Comments
 (0)