Add bindings for -D_FILE_OFFSET_BITS=64

They're all added under the `foo64` names with the `foo64` types added as well,
so they still need to be explicitly chosen.
This commit is contained in:
Alex Crichton 2015-10-29 17:36:55 -07:00
parent 312b5bfb75
commit 74825222cf
11 changed files with 221 additions and 54 deletions

View file

@ -152,7 +152,7 @@ fn main() {
match field {
// Our stat *_nsec fields normally don't actually exist but are part
// of a timeval struct
s if s.ends_with("_nsec") && struct_ == "stat" => {
s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
if target2.contains("apple") {
s.replace("_nsec", "spec.tv_nsec")
} else if target2.contains("android") {
@ -203,6 +203,12 @@ fn main() {
// types on musl are defined a little differently
n if musl && n.contains("__SIZEOF_PTHREAD") => true,
// Skip constants not defined in MUSL but just passed down to the
// kernel regardless
"RLIMIT_NLIMITS" |
"TCP_COOKIE_TRANSACTIONS" |
"RLIMIT_RTTIME" if musl => true,
_ => false,
}
});
@ -215,8 +221,8 @@ fn main() {
"execvp" |
"execvpe" => true,
"getrlimit" | // non-int in 1st arg
"setrlimit" | // non-int in 1st arg
"getrlimit" | "getrlimit64" | // non-int in 1st arg
"setrlimit" | "setrlimit64" | // non-int in 1st arg
"strerror_r" if linux => true, // actually xpg-something-or-other
// typed 2nd arg on linux and android

View file

@ -100,7 +100,7 @@ pub type uintptr_t = usize;
pub type ssize_t = isize;
pub enum FILE {}
pub enum fpos_t {}
pub enum fpos_t {} // TODO: fill this out with a struct
extern {
pub fn isalnum(c: c_int) -> c_int;

View file

@ -174,7 +174,7 @@ extern {
pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
#[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
result: *mut *mut ::dirent) -> ::c_int;
result: *mut *mut ::dirent) -> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "closedir$UNIX2003")]
pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
@ -220,8 +220,7 @@ extern {
pub fn getuid() -> uid_t;
pub fn isatty(fd: ::c_int) -> ::c_int;
pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int)
-> off_t;
pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "pause$UNIX2003")]
@ -526,6 +525,10 @@ extern {
errorfds: *mut fd_set,
timeout: *const timespec,
sigmask: *const sigset_t) -> ::c_int;
pub fn fseeko(stream: *mut ::FILE,
offset: ::off_t,
whence: ::c_int) -> ::c_int;
pub fn ftello(stream: *mut ::FILE) -> ::off_t;
}
cfg_if! {

View file

@ -14,7 +14,7 @@ pub type nlink_t = u32;
s! {
pub struct stat {
pub st_dev: ::c_ulong,
pub st_pad1: [::c_long; 3],
st_pad1: [::c_long; 3],
pub st_ino: ::ino_t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
@ -23,7 +23,7 @@ s! {
pub st_rdev: ::c_ulong,
pub st_pad2: [::c_long; 2],
pub st_size: ::off_t,
pub st_pad3: ::c_long,
st_pad3: ::c_long,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
pub st_mtime: ::time_t,
@ -32,7 +32,30 @@ s! {
pub st_ctime_nsec: ::c_long,
pub st_blksize: ::blksize_t,
pub st_blocks: ::blkcnt_t,
pub st_pad5: [::c_long; 14],
st_pad5: [::c_long; 14],
}
pub struct stat64 {
pub st_dev: ::c_ulong,
st_pad1: [::c_long; 3],
pub st_ino: ::ino64_t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::c_ulong,
st_pad2: [::c_long; 2],
pub st_size: ::off64_t,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
pub st_blksize: ::blksize_t,
st_pad3: ::c_long,
pub st_blocks: ::blkcnt64_t,
st_pad5: [::c_long; 14],
}
pub struct pthread_attr_t {

View file

@ -5,6 +5,12 @@ pub type dev_t = u64;
pub type socklen_t = u32;
pub type pthread_t = c_ulong;
pub type mode_t = u32;
pub type ino64_t = u64;
pub type off64_t = i64;
pub type blkcnt64_t = i64;
pub type rlim64_t = u64;
pub enum fpos64_t {} // TODO: fill this out with a struct
s! {
pub struct dirent {
@ -15,6 +21,19 @@ s! {
pub d_name: [::c_char; 256],
}
pub struct dirent64 {
pub d_ino: ::ino64_t,
pub d_off: ::off64_t,
pub d_reclen: ::c_ushort,
pub d_type: ::c_uchar,
pub d_name: [::c_char; 256],
}
pub struct rlimit64 {
pub rlim_cur: rlim64_t,
pub rlim_max: rlim64_t,
}
pub struct glob_t {
pub gl_pathc: ::size_t,
pub gl_pathv: *mut *mut c_char,
@ -226,13 +245,47 @@ extern {
-> ::c_int;
pub fn __errno_location() -> *mut ::c_int;
pub fn fopen64(filename: *const c_char,
mode: *const c_char) -> *mut ::FILE;
pub fn freopen64(filename: *const c_char, mode: *const c_char,
file: *mut ::FILE) -> *mut ::FILE;
pub fn tmpfile64() -> *mut ::FILE;
pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int;
pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int;
pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int;
pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int;
pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t;
pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
offset: off64_t) -> ::ssize_t;
pub fn pwrite64(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
offset: off64_t) -> ::ssize_t;
pub fn mmap64(addr: *mut ::c_void,
len: ::size_t,
prot: ::c_int,
flags: ::c_int,
fd: ::c_int,
offset: off64_t)
-> *mut ::c_void;
pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int;
pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64,
result: *mut *mut ::dirent64) -> ::c_int;
pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int;
pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int;
pub fn fseeko64(stream: *mut ::FILE,
offset: ::off64_t,
whence: ::c_int) -> ::c_int;
pub fn ftello64(stream: *mut ::FILE) -> ::off64_t;
}
cfg_if! {
if #[cfg(any(target_env = "musl"))] {
pub const PTHREAD_STACK_MIN: ::size_t = 2048;
} else if #[cfg(any(target_arch = "arm", target_arch = "x86",
target_arch = "x86_64"))] {
target_arch = "x86_64"))] {
pub const PTHREAD_STACK_MIN: ::size_t = 16384;
} else {
pub const PTHREAD_STACK_MIN: ::size_t = 131072;
@ -241,38 +294,11 @@ cfg_if! {
cfg_if! {
if #[cfg(target_env = "musl")] {
pub const BUFSIZ: ::c_uint = 1024;
pub const TMP_MAX: ::c_uint = 10000;
pub const FOPEN_MAX: ::c_uint = 1000;
pub const POSIX_MADV_DONTNEED: ::c_int = 0;
pub const O_ACCMODE: ::c_int = 0o10000003;
pub const RUSAGE_CHILDREN: ::c_int = 1;
extern {
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
}
mod musl;
pub use self::musl::*;
} else {
pub const BUFSIZ: ::c_uint = 8192;
pub const TMP_MAX: ::c_uint = 238328;
pub const FOPEN_MAX: ::c_uint = 16;
pub const POSIX_MADV_DONTNEED: ::c_int = 4;
pub const _SC_2_C_VERSION: ::c_int = 96;
pub const RUSAGE_THREAD: ::c_int = 1;
pub const O_ACCMODE: ::c_int = 3;
pub const RUSAGE_CHILDREN: ::c_int = -1;
extern {
pub fn sysctl(name: *mut ::c_int,
namelen: ::c_int,
oldp: *mut ::c_void,
oldlenp: *mut ::size_t,
newp: *mut ::c_void,
newlen: ::size_t)
-> ::c_int;
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
pub fn backtrace(buf: *mut *mut ::c_void,
sz: ::c_int) -> ::c_int;
}
mod notmusl;
pub use self::notmusl::*;
}
}

View file

@ -0,0 +1,10 @@
pub const BUFSIZ: ::c_uint = 1024;
pub const TMP_MAX: ::c_uint = 10000;
pub const FOPEN_MAX: ::c_uint = 1000;
pub const POSIX_MADV_DONTNEED: ::c_int = 0;
pub const O_ACCMODE: ::c_int = 0o10000003;
pub const RUSAGE_CHILDREN: ::c_int = 1;
extern {
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
}

View file

@ -40,6 +40,28 @@ s! {
__unused5: ::c_long,
}
pub struct stat64 {
pub st_dev: ::dev_t,
__pad1: ::c_uint,
__st_ino: ::ino_t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::dev_t,
__pad2: ::c_uint,
pub st_size: ::off64_t,
pub st_blksize: ::blksize_t,
pub st_blocks: ::blkcnt64_t,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
pub st_ino: ::ino64_t,
}
pub struct pthread_attr_t {
__size: [u32; 9]
}

View file

@ -31,6 +31,28 @@ s! {
__unused: [::c_int; 2],
}
pub struct stat64 {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::dev_t,
__pad1: ::dev_t,
pub st_size: ::off64_t,
pub st_blksize: ::blksize_t,
__pad2: ::c_int,
pub st_blocks: ::blkcnt64_t,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
__unused: [::c_int; 2],
}
pub struct pthread_attr_t {
__size: [u64; 8]
}

View file

@ -30,6 +30,27 @@ s! {
__unused: [::c_long; 3],
}
pub struct stat64 {
pub st_dev: ::dev_t,
pub st_ino: ::ino64_t,
pub st_nlink: ::nlink_t,
pub st_mode: ::mode_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
__pad0: ::c_int,
pub st_rdev: ::dev_t,
pub st_size: ::off_t,
pub st_blksize: ::blksize_t,
pub st_blocks: ::blkcnt64_t,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
__reserved: [::c_long; 3],
}
pub struct pthread_attr_t {
__size: [u64; 7]
}

View file

@ -27,6 +27,8 @@ pub const RLIMIT_AS: ::c_int = 9;
pub const RLIMIT_NPROC: ::c_int = 6;
pub const RLIMIT_MEMLOCK: ::c_int = 8;
pub const RLIM_INFINITY: ::rlim_t = !0;
pub const RLIMIT_RTTIME: ::c_int = 15;
pub const RLIMIT_NLIMITS: ::c_int = 16;
pub const O_APPEND: ::c_int = 1024;
pub const O_CREAT: ::c_int = 64;
@ -148,12 +150,14 @@ pub const SO_RCVBUF: ::c_int = 8;
pub const SO_KEEPALIVE: ::c_int = 9;
pub const SO_OOBINLINE: ::c_int = 10;
pub const SO_LINGER: ::c_int = 13;
pub const SO_REUSEPORT: ::c_int = 15;
pub const SO_RCVLOWAT: ::c_int = 18;
pub const SO_SNDLOWAT: ::c_int = 19;
pub const SO_RCVTIMEO: ::c_int = 20;
pub const SO_SNDTIMEO: ::c_int = 21;
pub const SO_ACCEPTCONN: ::c_int = 30;
pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16;
pub const TCP_THIN_DUPACK: ::c_int = 17;
pub const TCP_USER_TIMEOUT: ::c_int = 18;
@ -164,8 +168,6 @@ pub const TCP_REPAIR_OPTIONS: ::c_int = 22;
pub const TCP_FASTOPEN: ::c_int = 23;
pub const TCP_TIMESTAMP: ::c_int = 24;
pub const SO_REUSEPORT: ::c_int = 15;
pub const FIOCLEX: ::c_ulong = 0x5451;
pub const FIONBIO: ::c_ulong = 0x5421;
@ -177,16 +179,6 @@ pub const SIGCHLD: ::c_int = 17;
pub const SIGBUS: ::c_int = 7;
pub const SIG_SETMASK: ::c_int = 2;
cfg_if! {
if #[cfg(target_env = "musl")] {
pub const RLIMIT_NLIMITS: ::c_int = 15;
} else {
pub const RLIMIT_NLIMITS: ::c_int = 16;
pub const RLIMIT_RTTIME: ::c_int = 15;
pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
}
}
cfg_if! {
if #[cfg(any(target_arch = "x86", target_arch = "arm"))] {
mod b32;

View file

@ -0,0 +1,42 @@
s! {
pub struct glob64_t {
pub gl_pathc: ::size_t,
pub gl_pathv: *mut *mut ::c_char,
pub gl_offs: ::size_t,
pub gl_flags: ::c_int,
__unused1: *mut ::c_void,
__unused2: *mut ::c_void,
__unused3: *mut ::c_void,
__unused4: *mut ::c_void,
__unused5: *mut ::c_void,
}
}
pub const BUFSIZ: ::c_uint = 8192;
pub const TMP_MAX: ::c_uint = 238328;
pub const FOPEN_MAX: ::c_uint = 16;
pub const POSIX_MADV_DONTNEED: ::c_int = 4;
pub const _SC_2_C_VERSION: ::c_int = 96;
pub const RUSAGE_THREAD: ::c_int = 1;
pub const O_ACCMODE: ::c_int = 3;
pub const RUSAGE_CHILDREN: ::c_int = -1;
extern {
pub fn sysctl(name: *mut ::c_int,
namelen: ::c_int,
oldp: *mut ::c_void,
oldlenp: *mut ::size_t,
newp: *mut ::c_void,
newlen: ::size_t)
-> ::c_int;
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
pub fn backtrace(buf: *mut *mut ::c_void,
sz: ::c_int) -> ::c_int;
pub fn glob64(pattern: *const ::c_char,
flags: ::c_int,
errfunc: ::dox::Option<extern "C" fn(epath: *const ::c_char,
errno: ::c_int) -> ::c_int>,
pglob: *mut glob64_t) -> ::c_int;
pub fn globfree64(pglob: *mut glob64_t);
}