Skip to content

Commit 773aab8

Browse files
committed
Add musl definitions for x86, arm and asmjs
I've tested x86 against C locally, but not arm or asmjs. I added the arm definitions because asmjs's C is derived from arms. Mysteriously, my locally-built musl does not contain a definition for _SC_2_C_VERSION, so I just removed it.
1 parent 8266465 commit 773aab8

File tree

12 files changed

+231
-97
lines changed

12 files changed

+231
-97
lines changed

libc-test/build.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ fn main() {
402402
// just insert some padding.
403403
(struct_ == "siginfo_t" && field == "_pad") ||
404404
// musl names this __dummy1 but it's still there
405-
(musl && struct_ == "glob_t" && field == "gl_flags")
405+
(musl && struct_ == "glob_t" && field == "gl_flags") ||
406+
// musl seems to define this as an *anonymous* bitfield
407+
(musl && struct_ == "statvfs" && field == "__f_unused")
406408
});
407409

408410
cfg.fn_cname(move |name, cname| {

src/unix/notbsd/android/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub type time64_t = i64;
2323
pub type fsfilcnt_t = ::c_ulong;
2424
pub type fsblkcnt_t = ::c_ulong;
2525
pub type nfds_t = ::c_uint;
26+
pub type rlim_t = c_ulong;
2627

2728
s! {
2829
pub struct stat {
@@ -468,6 +469,8 @@ pub const EFD_NONBLOCK: ::c_int = 0x800;
468469
pub const F_GETLK: ::c_int = 5;
469470
pub const F_GETOWN: ::c_int = 9;
470471
pub const F_SETOWN: ::c_int = 8;
472+
pub const F_SETLK: ::c_int = 6;
473+
pub const F_SETLKW: ::c_int = 7;
471474

472475
pub const TCGETS: ::c_int = 0x5401;
473476
pub const TCSETS: ::c_int = 0x5402;

src/unix/notbsd/linux/mips.rs

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ pub type ino_t = u32;
1010
pub type blkcnt_t = i32;
1111
pub type blksize_t = i32;
1212
pub type nlink_t = u32;
13+
pub type fsblkcnt_t = ::c_ulong;
14+
pub type fsfilcnt_t = ::c_ulong;
15+
pub type rlim_t = c_ulong;
1316

1417
s! {
1518
pub struct stat {
@@ -428,6 +431,8 @@ pub const EFD_NONBLOCK: ::c_int = 0x80;
428431
pub const F_GETLK: ::c_int = 14;
429432
pub const F_GETOWN: ::c_int = 23;
430433
pub const F_SETOWN: ::c_int = 24;
434+
pub const F_SETLK: ::c_int = 6;
435+
pub const F_SETLKW: ::c_int = 7;
431436

432437
pub const SFD_NONBLOCK: ::c_int = 0x80;
433438

src/unix/notbsd/linux/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ pub type ino64_t = u64;
99
pub type off64_t = i64;
1010
pub type blkcnt64_t = i64;
1111
pub type rlim64_t = u64;
12-
pub type fsblkcnt_t = ::c_ulong;
13-
pub type fsfilcnt_t = ::c_ulong;
1412
pub type key_t = ::c_int;
1513
pub type shmatt_t = ::c_ulong;
1614
pub type mqd_t = ::c_int;

src/unix/notbsd/linux/musl/b32/arm.rs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub type c_char = u8;
2+
pub type wchar_t = u32;
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub type c_char = u8;
2+
pub type wchar_t = u32;

src/unix/notbsd/linux/musl/b32/mod.rs

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
pub type c_long = i32;
2+
pub type c_ulong = u32;
3+
4+
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
5+
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
6+
7+
pub const F_GETLK: ::c_int = 12;
8+
pub const F_SETLK: ::c_int = 13;
9+
pub const F_SETLKW: ::c_int = 14;
10+
11+
12+
s! {
13+
pub struct stat {
14+
pub st_dev: ::dev_t,
15+
__st_dev_padding: ::c_int,
16+
__st_ino_truncated: ::c_long,
17+
pub st_mode: ::mode_t,
18+
pub st_nlink: ::nlink_t,
19+
pub st_uid: ::uid_t,
20+
pub st_gid: ::gid_t,
21+
pub st_rdev: ::dev_t,
22+
__st_rdev_padding: ::c_int,
23+
pub st_size: ::off_t,
24+
pub st_blksize: ::blksize_t,
25+
pub st_blocks: ::blkcnt_t,
26+
pub st_atim: ::timespec,
27+
pub st_mtim: ::timespec,
28+
pub st_ctim: ::timespec,
29+
pub st_ino: ::ino_t,
30+
}
31+
32+
pub struct stat64 {
33+
pub st_dev: ::dev_t,
34+
__st_dev_padding: ::c_int,
35+
__st_ino_truncated: ::c_long,
36+
pub st_mode: ::mode_t,
37+
pub st_nlink: ::nlink_t,
38+
pub st_uid: ::uid_t,
39+
pub st_gid: ::gid_t,
40+
pub st_rdev: ::dev_t,
41+
__st_rdev_padding: ::c_int,
42+
pub st_size: ::off_t,
43+
pub st_blksize: ::blksize_t,
44+
pub st_blocks: ::blkcnt_t,
45+
pub st_atim: ::timespec,
46+
pub st_mtim: ::timespec,
47+
pub st_ctim: ::timespec,
48+
pub st_ino: ::ino_t,
49+
}
50+
51+
pub struct pthread_attr_t {
52+
__size: [u32; 9]
53+
}
54+
55+
pub struct sigset_t {
56+
__val: [::c_ulong; 32],
57+
}
58+
59+
pub struct shmid_ds {
60+
pub shm_perm: ::ipc_perm,
61+
pub shm_segsz: ::size_t,
62+
pub shm_atime: ::time_t,
63+
__unused1: ::c_int,
64+
pub shm_dtime: ::time_t,
65+
__unused2: ::c_int,
66+
pub shm_ctime: ::time_t,
67+
__unused3: ::c_int,
68+
pub shm_cpid: ::pid_t,
69+
pub shm_lpid: ::pid_t,
70+
pub shm_nattch: ::c_ulong,
71+
__pad1: ::c_ulong,
72+
__pad2: ::c_ulong,
73+
}
74+
75+
pub struct msghdr {
76+
pub msg_name: *mut ::c_void,
77+
pub msg_namelen: ::socklen_t,
78+
pub msg_iov: *mut ::iovec,
79+
pub msg_iovlen: ::c_int,
80+
pub msg_control: *mut ::c_void,
81+
pub msg_controllen: ::socklen_t,
82+
pub msg_flags: ::c_int,
83+
}
84+
}
85+
86+
cfg_if! {
87+
if #[cfg(any(target_arch = "x86"))] {
88+
mod x86;
89+
pub use self::x86::*;
90+
} else if #[cfg(any(target_arch = "arm"))] {
91+
mod arm;
92+
pub use self::arm::*;
93+
} else if #[cfg(any(target_arch = "asmjs"))] {
94+
mod asmjs;
95+
pub use self::asmjs::*;
96+
} else { }
97+
}

src/unix/notbsd/linux/musl/b32/x86.rs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub type c_char = i8;
2+
pub type wchar_t = i32;

src/unix/notbsd/linux/musl/b64/mod.rs

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
pub type c_char = i8;
2+
pub type wchar_t = i32;
3+
pub type c_long = i64;
4+
pub type c_ulong = u64;
5+
6+
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
7+
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
8+
9+
pub const F_GETLK: ::c_int = 5;
10+
pub const F_SETLK: ::c_int = 6;
11+
pub const F_SETLKW: ::c_int = 7;
12+
13+
s! {
14+
pub struct stat {
15+
pub st_dev: ::dev_t,
16+
pub st_ino: ::ino_t,
17+
pub st_nlink: ::nlink_t,
18+
pub st_mode: ::mode_t,
19+
pub st_uid: ::uid_t,
20+
pub st_gid: ::gid_t,
21+
__pad0: ::c_int,
22+
pub st_rdev: ::dev_t,
23+
pub st_size: ::off_t,
24+
pub st_blksize: ::blksize_t,
25+
pub st_blocks: ::blkcnt_t,
26+
pub st_atime: ::time_t,
27+
pub st_atime_nsec: ::c_long,
28+
pub st_mtime: ::time_t,
29+
pub st_mtime_nsec: ::c_long,
30+
pub st_ctime: ::time_t,
31+
pub st_ctime_nsec: ::c_long,
32+
__unused: [::c_long; 3],
33+
}
34+
35+
pub struct stat64 {
36+
pub st_dev: ::dev_t,
37+
pub st_ino: ::ino64_t,
38+
pub st_nlink: ::nlink_t,
39+
pub st_mode: ::mode_t,
40+
pub st_uid: ::uid_t,
41+
pub st_gid: ::gid_t,
42+
__pad0: ::c_int,
43+
pub st_rdev: ::dev_t,
44+
pub st_size: ::off_t,
45+
pub st_blksize: ::blksize_t,
46+
pub st_blocks: ::blkcnt64_t,
47+
pub st_atime: ::time_t,
48+
pub st_atime_nsec: ::c_long,
49+
pub st_mtime: ::time_t,
50+
pub st_mtime_nsec: ::c_long,
51+
pub st_ctime: ::time_t,
52+
pub st_ctime_nsec: ::c_long,
53+
__reserved: [::c_long; 3],
54+
}
55+
56+
pub struct pthread_attr_t {
57+
__size: [u64; 7]
58+
}
59+
60+
pub struct sigset_t {
61+
__val: [::c_ulong; 16],
62+
}
63+
64+
pub struct shmid_ds {
65+
pub shm_perm: ::ipc_perm,
66+
pub shm_segsz: ::size_t,
67+
pub shm_atime: ::time_t,
68+
pub shm_dtime: ::time_t,
69+
pub shm_ctime: ::time_t,
70+
pub shm_cpid: ::pid_t,
71+
pub shm_lpid: ::pid_t,
72+
pub shm_nattch: ::c_ulong,
73+
__pad1: ::c_ulong,
74+
__pad2: ::c_ulong,
75+
}
76+
77+
pub struct msghdr {
78+
pub msg_name: *mut ::c_void,
79+
pub msg_namelen: ::socklen_t,
80+
pub msg_iov: *mut ::iovec,
81+
pub msg_iovlen: ::c_int,
82+
__pad1: ::c_int,
83+
pub msg_control: *mut ::c_void,
84+
pub msg_controllen: ::socklen_t,
85+
__pad2: ::socklen_t,
86+
pub msg_flags: ::c_int,
87+
}
88+
}

0 commit comments

Comments
 (0)