Skip to content

Commit 53e14e2

Browse files
committed
Auto merge of #282 - Nercury:correctly-sized-structs-and-types-for-android-aarch64, r=alexcrichton
Add correctly sized structs and types for Android aarch64. So far both android x86_64 and aarch64 configurations used incorrect types from 32-bit architecture. This PR updates only the aarch64, because it is more common. The x86_64 may be also incorrect, but is out of scope of this PR.
2 parents a04a52a + dad0dd2 commit 53e14e2

File tree

3 files changed

+246
-122
lines changed

3 files changed

+246
-122
lines changed

src/unix/notbsd/android/b32.rs

+112
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,118 @@ s! {
710
pub sa_flags: ::c_ulong,
811
pub sa_restorer: ::dox::Option<extern fn()>,
912
}
13+
14+
pub struct stat {
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 stat64 {
37+
pub st_dev: ::c_ulonglong,
38+
__pad0: [::c_uchar; 4],
39+
__st_ino: ::ino_t,
40+
pub st_mode: ::c_uint,
41+
pub st_nlink: ::c_uint,
42+
pub st_uid: ::uid_t,
43+
pub st_gid: ::gid_t,
44+
pub st_rdev: ::c_ulonglong,
45+
__pad3: [::c_uchar; 4],
46+
pub st_size: ::c_longlong,
47+
pub st_blksize: ::blksize_t,
48+
pub st_blocks: ::c_ulonglong,
49+
pub st_atime: ::c_ulong,
50+
pub st_atime_nsec: ::c_ulong,
51+
pub st_mtime: ::c_ulong,
52+
pub st_mtime_nsec: ::c_ulong,
53+
pub st_ctime: ::c_ulong,
54+
pub st_ctime_nsec: ::c_ulong,
55+
pub st_ino: ::c_ulonglong,
56+
}
57+
58+
pub struct pthread_attr_t {
59+
pub flags: ::uint32_t,
60+
pub stack_base: *mut ::c_void,
61+
pub stack_size: ::size_t,
62+
pub guard_size: ::size_t,
63+
pub sched_policy: ::int32_t,
64+
pub sched_priority: ::int32_t,
65+
}
66+
67+
pub struct pthread_mutex_t { value: ::c_int }
68+
69+
pub struct pthread_cond_t { value: ::c_int }
70+
71+
pub struct pthread_rwlock_t {
72+
lock: pthread_mutex_t,
73+
cond: pthread_cond_t,
74+
numLocks: ::c_int,
75+
writerThreadId: ::c_int,
76+
pendingReaders: ::c_int,
77+
pendingWriters: ::c_int,
78+
attr: i32,
79+
__reserved: [::c_char; 12],
80+
}
81+
82+
pub struct passwd {
83+
pub pw_name: *mut ::c_char,
84+
pub pw_passwd: *mut ::c_char,
85+
pub pw_uid: ::uid_t,
86+
pub pw_gid: ::gid_t,
87+
pub pw_dir: *mut ::c_char,
88+
pub pw_shell: *mut ::c_char,
89+
}
90+
91+
pub struct statfs {
92+
pub f_type: ::uint32_t,
93+
pub f_bsize: ::uint32_t,
94+
pub f_blocks: ::uint64_t,
95+
pub f_bfree: ::uint64_t,
96+
pub f_bavail: ::uint64_t,
97+
pub f_files: ::uint64_t,
98+
pub f_ffree: ::uint64_t,
99+
pub f_fsid: ::__fsid_t,
100+
pub f_namelen: ::uint32_t,
101+
pub f_frsize: ::uint32_t,
102+
pub f_flags: ::uint32_t,
103+
pub f_spare: [::uint32_t; 4],
104+
}
10105
}
11106

12107
pub const SYS_gettid: ::c_long = 224;
108+
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
109+
value: 0,
110+
};
111+
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
112+
value: 0,
113+
};
114+
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
115+
lock: PTHREAD_MUTEX_INITIALIZER,
116+
cond: PTHREAD_COND_INITIALIZER,
117+
numLocks: 0,
118+
writerThreadId: 0,
119+
pendingReaders: 0,
120+
pendingWriters: 0,
121+
attr: 0,
122+
__reserved: [0; 12],
123+
};
124+
pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 2;
13125

14126
extern {
15127
pub fn timegm64(tm: *const ::tm) -> ::time64_t;

src/unix/notbsd/android/b64.rs

+122
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,126 @@ s! {
712
pub sa_mask: ::sigset_t,
813
_restorer: *mut ::c_void,
914
}
15+
16+
pub struct stat {
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 stat64 {
40+
pub st_dev: ::dev_t,
41+
pub st_ino: ::ino_t,
42+
pub st_mode: ::c_uint,
43+
pub st_nlink: ::c_uint,
44+
pub st_uid: ::uid_t,
45+
pub st_gid: ::gid_t,
46+
pub st_rdev: ::dev_t,
47+
__pad1: ::c_ulong,
48+
pub st_size: ::off64_t,
49+
pub st_blksize: ::c_int,
50+
__pad2: ::c_int,
51+
pub st_blocks: ::c_long,
52+
pub st_atime: ::time_t,
53+
pub st_atime_nsec: ::c_ulong,
54+
pub st_mtime: ::time_t,
55+
pub st_mtime_nsec: ::c_ulong,
56+
pub st_ctime: ::time_t,
57+
pub st_ctime_nsec: ::c_ulong,
58+
__unused4: ::c_uint,
59+
__unused5: ::c_uint,
60+
}
61+
62+
pub struct pthread_attr_t {
63+
pub flags: ::uint32_t,
64+
pub stack_base: *mut ::c_void,
65+
pub stack_size: ::size_t,
66+
pub guard_size: ::size_t,
67+
pub sched_policy: ::int32_t,
68+
pub sched_priority: ::int32_t,
69+
__reserved: [::c_char; 16],
70+
}
71+
72+
pub struct pthread_mutex_t {
73+
value: ::c_int,
74+
__reserved: [::c_char; 36],
75+
}
76+
77+
pub struct pthread_cond_t {
78+
value: ::c_int,
79+
__reserved: [::c_char; 44],
80+
}
81+
82+
pub struct pthread_rwlock_t {
83+
numLocks: ::c_int,
84+
writerThreadId: ::c_int,
85+
pendingReaders: ::c_int,
86+
pendingWriters: ::c_int,
87+
attr: i32,
88+
__reserved: [::c_char; 36],
89+
}
90+
91+
pub struct passwd {
92+
pub pw_name: *mut ::c_char,
93+
pub pw_passwd: *mut ::c_char,
94+
pub pw_uid: ::uid_t,
95+
pub pw_gid: ::gid_t,
96+
pub pw_gecos: *mut ::c_char,
97+
pub pw_dir: *mut ::c_char,
98+
pub pw_shell: *mut ::c_char,
99+
}
100+
101+
pub struct statfs {
102+
pub f_type: ::uint64_t,
103+
pub f_bsize: ::uint64_t,
104+
pub f_blocks: ::uint64_t,
105+
pub f_bfree: ::uint64_t,
106+
pub f_bavail: ::uint64_t,
107+
pub f_files: ::uint64_t,
108+
pub f_ffree: ::uint64_t,
109+
pub f_fsid: ::__fsid_t,
110+
pub f_namelen: ::uint64_t,
111+
pub f_frsize: ::uint64_t,
112+
pub f_flags: ::uint64_t,
113+
pub f_spare: [::uint64_t; 4],
114+
}
10115
}
11116

12117
pub const SYS_gettid: ::c_long = 178;
118+
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
119+
value: 0,
120+
__reserved: [0; 36],
121+
};
122+
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
123+
value: 0,
124+
__reserved: [0; 44],
125+
};
126+
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
127+
numLocks: 0,
128+
writerThreadId: 0,
129+
pendingReaders: 0,
130+
pendingWriters: 0,
131+
attr: 0,
132+
__reserved: [0; 36],
133+
};
134+
pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 4;
13135

14136
extern {
15137
pub fn timegm(tm: *const ::tm) -> ::time64_t;

0 commit comments

Comments
 (0)