Skip to content

Commit 3ee7182

Browse files
committed
Add correctly sized structs and types for Android aarch64.
1 parent a04a52a commit 3ee7182

File tree

3 files changed

+202
-122
lines changed

3 files changed

+202
-122
lines changed

src/unix/notbsd/android/b32.rs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
pub type c_long = i32;
2+
pub type c_ulong = u32;
13
pub type mode_t = u16;
4+
pub type off64_t = ::c_longlong;
25

36
s! {
47
pub struct sigaction {
@@ -7,9 +10,96 @@ s! {
710
pub sa_flags: ::c_ulong,
811
pub sa_restorer: ::dox::Option<extern fn()>,
912
}
13+
14+
pub struct stat64 {
15+
pub st_dev: ::c_ulonglong,
16+
__pad0: [::c_uchar; 4],
17+
__st_ino: ::ino_t,
18+
pub st_mode: ::c_uint,
19+
pub st_nlink: ::c_uint,
20+
pub st_uid: ::uid_t,
21+
pub st_gid: ::gid_t,
22+
pub st_rdev: ::c_ulonglong,
23+
__pad3: [::c_uchar; 4],
24+
pub st_size: ::c_longlong,
25+
pub st_blksize: ::blksize_t,
26+
pub st_blocks: ::c_ulonglong,
27+
pub st_atime: ::c_ulong,
28+
pub st_atime_nsec: ::c_ulong,
29+
pub st_mtime: ::c_ulong,
30+
pub st_mtime_nsec: ::c_ulong,
31+
pub st_ctime: ::c_ulong,
32+
pub st_ctime_nsec: ::c_ulong,
33+
pub st_ino: ::c_ulonglong,
34+
}
35+
36+
pub struct pthread_attr_t {
37+
pub flags: ::uint32_t,
38+
pub stack_base: *mut ::c_void,
39+
pub stack_size: ::size_t,
40+
pub guard_size: ::size_t,
41+
pub sched_policy: ::int32_t,
42+
pub sched_priority: ::int32_t,
43+
}
44+
45+
pub struct pthread_mutex_t { value: ::c_int }
46+
47+
pub struct pthread_cond_t { value: ::c_int }
48+
49+
pub struct pthread_rwlock_t {
50+
lock: pthread_mutex_t,
51+
cond: pthread_cond_t,
52+
numLocks: ::c_int,
53+
writerThreadId: ::c_int,
54+
pendingReaders: ::c_int,
55+
pendingWriters: ::c_int,
56+
attr: i32,
57+
__reserved: [::c_char; 12],
58+
}
59+
60+
pub struct passwd {
61+
pub pw_name: *mut ::c_char,
62+
pub pw_passwd: *mut ::c_char,
63+
pub pw_uid: ::uid_t,
64+
pub pw_gid: ::gid_t,
65+
pub pw_dir: *mut ::c_char,
66+
pub pw_shell: *mut ::c_char,
67+
}
68+
69+
pub struct statfs {
70+
pub f_type: ::uint32_t,
71+
pub f_bsize: ::uint32_t,
72+
pub f_blocks: ::uint64_t,
73+
pub f_bfree: ::uint64_t,
74+
pub f_bavail: ::uint64_t,
75+
pub f_files: ::uint64_t,
76+
pub f_ffree: ::uint64_t,
77+
pub f_fsid: ::__fsid_t,
78+
pub f_namelen: ::uint32_t,
79+
pub f_frsize: ::uint32_t,
80+
pub f_flags: ::uint32_t,
81+
pub f_spare: [::uint32_t; 4],
82+
}
1083
}
1184

1285
pub const SYS_gettid: ::c_long = 224;
86+
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
87+
value: 0,
88+
};
89+
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
90+
value: 0,
91+
};
92+
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
93+
lock: PTHREAD_MUTEX_INITIALIZER,
94+
cond: PTHREAD_COND_INITIALIZER,
95+
numLocks: 0,
96+
writerThreadId: 0,
97+
pendingReaders: 0,
98+
pendingWriters: 0,
99+
attr: 0,
100+
__reserved: [0; 12],
101+
};
102+
pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 2;
13103

14104
extern {
15105
pub fn timegm64(tm: *const ::tm) -> ::time64_t;

src/unix/notbsd/android/b64.rs

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
// The following definitions are correct for aarch64 and may be wrong for x86_64
2+
3+
pub type c_long = i64;
4+
pub type c_ulong = u64;
15
pub type mode_t = u32;
6+
pub type off64_t = i64;
27

38
s! {
49
pub struct sigaction {
@@ -7,9 +12,103 @@ s! {
712
pub sa_mask: ::sigset_t,
813
_restorer: *mut ::c_void,
914
}
15+
16+
pub struct stat64 {
17+
pub st_dev: ::dev_t,
18+
pub st_ino: ::ino_t,
19+
pub st_mode: ::c_uint,
20+
pub st_nlink: ::c_uint,
21+
pub st_uid: ::uid_t,
22+
pub st_gid: ::gid_t,
23+
pub st_rdev: ::dev_t,
24+
__pad1: ::c_ulong,
25+
pub st_size: ::off64_t,
26+
pub st_blksize: ::c_int,
27+
__pad2: ::c_int,
28+
pub st_blocks: ::c_long,
29+
pub st_atime: ::time_t,
30+
pub st_atime_nsec: ::c_ulong,
31+
pub st_mtime: ::time_t,
32+
pub st_mtime_nsec: ::c_ulong,
33+
pub st_ctime: ::time_t,
34+
pub st_ctime_nsec: ::c_ulong,
35+
__unused4: ::c_uint,
36+
__unused5: ::c_uint,
37+
}
38+
39+
pub struct pthread_attr_t {
40+
pub flags: ::uint32_t,
41+
pub stack_base: *mut ::c_void,
42+
pub stack_size: ::size_t,
43+
pub guard_size: ::size_t,
44+
pub sched_policy: ::int32_t,
45+
pub sched_priority: ::int32_t,
46+
__reserved: [::c_char; 16],
47+
}
48+
49+
pub struct pthread_mutex_t {
50+
value: ::c_int,
51+
__reserved: [::c_char; 36],
52+
}
53+
54+
pub struct pthread_cond_t {
55+
value: ::c_int,
56+
__reserved: [::c_char; 44],
57+
}
58+
59+
pub struct pthread_rwlock_t {
60+
numLocks: ::c_int,
61+
writerThreadId: ::c_int,
62+
pendingReaders: ::c_int,
63+
pendingWriters: ::c_int,
64+
attr: i32,
65+
__reserved: [::c_char; 36],
66+
}
67+
68+
pub struct passwd {
69+
pub pw_name: *mut ::c_char,
70+
pub pw_passwd: *mut ::c_char,
71+
pub pw_uid: ::uid_t,
72+
pub pw_gid: ::gid_t,
73+
pub pw_gecos: *mut ::c_char,
74+
pub pw_dir: *mut ::c_char,
75+
pub pw_shell: *mut ::c_char,
76+
}
77+
78+
pub struct statfs {
79+
pub f_type: ::uint64_t,
80+
pub f_bsize: ::uint64_t,
81+
pub f_blocks: ::uint64_t,
82+
pub f_bfree: ::uint64_t,
83+
pub f_bavail: ::uint64_t,
84+
pub f_files: ::uint64_t,
85+
pub f_ffree: ::uint64_t,
86+
pub f_fsid: ::__fsid_t,
87+
pub f_namelen: ::uint64_t,
88+
pub f_frsize: ::uint64_t,
89+
pub f_flags: ::uint64_t,
90+
pub f_spare: [::uint64_t; 4],
91+
}
1092
}
1193

1294
pub const SYS_gettid: ::c_long = 178;
95+
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
96+
value: 0,
97+
__reserved: [0; 36],
98+
};
99+
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
100+
value: 0,
101+
__reserved: [0; 44],
102+
};
103+
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
104+
numLocks: 0,
105+
writerThreadId: 0,
106+
pendingReaders: 0,
107+
pendingWriters: 0,
108+
attr: 0,
109+
__reserved: [0; 36],
110+
};
111+
pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 4;
13112

14113
extern {
15114
pub fn timegm(tm: *const ::tm) -> ::time64_t;

src/unix/notbsd/android/mod.rs

Lines changed: 13 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,29 @@
11
//! Android-specific definitions for linux-like values
22
33
pub type c_char = u8;
4-
pub type c_long = i32;
5-
pub type c_ulong = u32;
6-
pub type clock_t = i32;
7-
pub type time_t = i32;
8-
pub type suseconds_t = i32;
4+
pub type clock_t = ::c_long;
5+
pub type time_t = ::c_long;
6+
pub type suseconds_t = ::c_long;
97
pub type wchar_t = u32;
10-
pub type off_t = i32;
11-
pub type off64_t = i64;
12-
pub type ino_t = u32;
13-
pub type blkcnt_t = u32;
14-
pub type blksize_t = u32;
15-
pub type dev_t = u32;
8+
pub type off_t = ::c_long;
9+
pub type blkcnt_t = ::c_ulong;
10+
pub type blksize_t = ::c_ulong;
1611
pub type nlink_t = u32;
1712
pub type useconds_t = u32;
1813
pub type socklen_t = i32;
19-
pub type pthread_t = c_long;
14+
pub type pthread_t = ::c_long;
2015
pub type pthread_mutexattr_t = ::c_long;
21-
pub type sigset_t = c_ulong;
22-
pub type time64_t = i64;
16+
pub type sigset_t = ::c_ulong;
17+
pub type time64_t = i64; // N/A on android
2318
pub type fsfilcnt_t = ::c_ulong;
2419
pub type fsblkcnt_t = ::c_ulong;
2520
pub type nfds_t = ::c_uint;
26-
pub type rlim_t = c_ulong;
21+
pub type rlim_t = ::c_ulong;
22+
pub type dev_t = ::c_ulong;
23+
pub type ino_t = ::c_ulong;
24+
pub type stat = ::stat64;
2725

2826
s! {
29-
pub struct stat {
30-
pub st_dev: ::c_ulonglong,
31-
__pad0: [::c_uchar; 4],
32-
__st_ino: ::ino_t,
33-
pub st_mode: ::c_uint,
34-
pub st_nlink: ::c_uint,
35-
pub st_uid: ::uid_t,
36-
pub st_gid: ::gid_t,
37-
pub st_rdev: ::c_ulonglong,
38-
__pad3: [::c_uchar; 4],
39-
pub st_size: ::c_longlong,
40-
pub st_blksize: blksize_t,
41-
pub st_blocks: ::c_ulonglong,
42-
pub st_atime: ::c_ulong,
43-
pub st_atime_nsec: ::c_ulong,
44-
pub st_mtime: ::c_ulong,
45-
pub st_mtime_nsec: ::c_ulong,
46-
pub st_ctime: ::c_ulong,
47-
pub st_ctime_nsec: ::c_ulong,
48-
pub st_ino: ::c_ulonglong,
49-
}
50-
51-
pub struct stat64 {
52-
pub st_dev: ::c_ulonglong,
53-
__pad0: [::c_uchar; 4],
54-
__st_ino: ::ino_t,
55-
pub st_mode: ::c_uint,
56-
pub st_nlink: ::c_uint,
57-
pub st_uid: ::uid_t,
58-
pub st_gid: ::gid_t,
59-
pub st_rdev: ::c_ulonglong,
60-
__pad3: [::c_uchar; 4],
61-
pub st_size: ::c_longlong,
62-
pub st_blksize: blksize_t,
63-
pub st_blocks: ::c_ulonglong,
64-
pub st_atime: ::c_ulong,
65-
pub st_atime_nsec: ::c_ulong,
66-
pub st_mtime: ::c_ulong,
67-
pub st_mtime_nsec: ::c_ulong,
68-
pub st_ctime: ::c_ulong,
69-
pub st_ctime_nsec: ::c_ulong,
70-
pub st_ino: ::c_ulonglong,
71-
}
72-
7327
pub struct dirent {
7428
pub d_ino: u64,
7529
pub d_off: i64,
@@ -91,38 +45,6 @@ s! {
9145
pub rlim_max: u64,
9246
}
9347

94-
pub struct pthread_attr_t {
95-
pub flags: ::uint32_t,
96-
pub stack_base: *mut ::c_void,
97-
pub stack_size: ::size_t,
98-
pub guard_size: ::size_t,
99-
pub sched_policy: ::int32_t,
100-
pub sched_priority: ::int32_t,
101-
}
102-
103-
pub struct pthread_mutex_t { value: ::c_int }
104-
105-
pub struct pthread_cond_t { value: ::c_int }
106-
107-
pub struct pthread_rwlock_t {
108-
lock: pthread_mutex_t,
109-
cond: pthread_cond_t,
110-
numLocks: ::c_int,
111-
writerThreadId: ::c_int,
112-
pendingReaders: ::c_int,
113-
pendingWriters: ::c_int,
114-
reserved: [*mut ::c_void; 4],
115-
}
116-
117-
pub struct passwd {
118-
pub pw_name: *mut ::c_char,
119-
pub pw_passwd: *mut ::c_char,
120-
pub pw_uid: ::uid_t,
121-
pub pw_gid: ::gid_t,
122-
pub pw_dir: *mut ::c_char,
123-
pub pw_shell: *mut ::c_char,
124-
}
125-
12648
pub struct stack_t {
12749
pub ss_sp: *mut ::c_void,
12850
pub ss_flags: ::c_int,
@@ -136,21 +58,6 @@ s! {
13658
pub _pad: [::c_int; 29],
13759
}
13860

139-
pub struct statfs {
140-
pub f_type: ::uint32_t,
141-
pub f_bsize: ::uint32_t,
142-
pub f_blocks: ::uint64_t,
143-
pub f_bfree: ::uint64_t,
144-
pub f_bavail: ::uint64_t,
145-
pub f_files: ::uint64_t,
146-
pub f_ffree: ::uint64_t,
147-
pub f_fsid: ::__fsid_t,
148-
pub f_namelen: ::uint32_t,
149-
pub f_frsize: ::uint32_t,
150-
pub f_flags: ::uint32_t,
151-
pub f_spare: [::uint32_t; 4],
152-
}
153-
15461
pub struct __fsid_t {
15562
__val: [::c_int; 2],
15663
}
@@ -251,22 +158,6 @@ pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 84;
251158
pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 85;
252159
pub const _SC_NPROCESSORS_ONLN: ::c_int = 97;
253160

254-
pub const PTHREAD_STACK_MIN: ::size_t = 8192;
255-
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
256-
value: 0,
257-
};
258-
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
259-
value: 0,
260-
};
261-
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
262-
lock: PTHREAD_MUTEX_INITIALIZER,
263-
cond: PTHREAD_COND_INITIALIZER,
264-
numLocks: 0,
265-
writerThreadId: 0,
266-
pendingReaders: 0,
267-
pendingWriters: 0,
268-
reserved: [0 as *mut _; 4],
269-
};
270161
pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
271162

272163
pub const FIOCLEX: ::c_int = 0x5451;

0 commit comments

Comments
 (0)