Skip to content

Commit

Permalink
Update libc crate to 0.2.47
Browse files Browse the repository at this point in the history
This change updates the libc crate to version 0.2.47.

Import subrepo libc/:libc at ce1dfcbf81bd74662b5cd02a9214818a0bfbbffa
  • Loading branch information
d-e-s-o committed Jan 23, 2019
1 parent 8b2d881 commit 4fcdf20
Show file tree
Hide file tree
Showing 20 changed files with 234 additions and 32 deletions.
47 changes: 32 additions & 15 deletions libc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libc"
version = "0.2.46"
version = "0.2.47"
authors = ["The Rust Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
5 changes: 4 additions & 1 deletion libc/libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ fn main() {
cfg.header("mqueue.h");
cfg.header("ufs/ufs/quota.h");
cfg.header("pthread_np.h");
cfg.header("sys/ioctl_compat.h");
cfg.header("sys/rtprio.h");
}

Expand Down Expand Up @@ -858,6 +857,10 @@ fn main() {
// to be removed now
"system" | "ptrace" if ios => true,

// Removed in OpenBSD 6.5
// https://marc.info/?l=openbsd-cvs&m=154723400730318
"mincore" if openbsd => true,

_ => false,
}
});
Expand Down
110 changes: 102 additions & 8 deletions libc/src/redox/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

pub type int8_t = i8;
pub type int16_t = i16;
pub type int32_t = i32;
Expand Down Expand Up @@ -31,18 +30,66 @@ pub type c_char = i8;
pub type c_long = i64;
pub type c_ulong = u64;

pub type wchar_t = i16;
pub type wchar_t = i32;
pub type wint_t = u32;
pub type wctype_t = i64;

pub type regoff_t = size_t;
pub type off_t = c_long;
pub type mode_t = u16;
pub type time_t = i64;
pub type pid_t = usize;
pub type gid_t = usize;
pub type uid_t = usize;
pub type mode_t = c_int;
pub type time_t = c_long;
pub type pid_t = c_int;
pub type id_t = c_uint;
pub type gid_t = c_int;
pub type uid_t = c_int;
pub type dev_t = c_long;
pub type ino_t = c_ulong;
pub type nlink_t = c_ulong;
pub type blksize_t = c_long;
pub type blkcnt_t = c_ulong;

pub type fsblkcnt_t = c_ulong;
pub type fsfilcnt_t = c_ulong;

pub type useconds_t = c_uint;
pub type suseconds_t = c_int;

pub type suseconds_t = i64;
pub type clock_t = c_long;
pub type clockid_t = c_int;
pub type timer_t = *mut c_void;

pub type nfds_t = c_ulong;

s! {
pub struct fd_set {
fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
}

pub struct pollfd {
pub fd: ::c_int,
pub events: ::c_short,
pub revents: ::c_short,
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::nlink_t,
pub st_mode: ::mode_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::dev_t,
pub st_size: ::off_t,
pub st_blksize: ::blksize_t,
pub st_blocks: ::blkcnt_t,

pub st_atime: ::timespec,
pub st_mtime: ::timespec,
pub st_ctime: ::timespec,

_pad: [c_char; 24],
}

pub struct timeval {
pub tv_sec: time_t,
pub tv_usec: suseconds_t,
Expand All @@ -64,6 +111,27 @@ pub const STDERR_FILENO: ::c_int = 2;
pub const EXIT_FAILURE: ::c_int = 1;
pub const EXIT_SUCCESS: ::c_int = 0;

pub const FD_SETSIZE: usize = 1024;

pub const MAP_SHARED: ::c_int = 1;
pub const MAP_PRIVATE: ::c_int = 2;
pub const MAP_ANONYMOUS: ::c_int = 4;
pub const MAP_ANON: ::c_int = MAP_ANONYMOUS;

pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;

pub const POLLIN: ::c_short = 0x001;
pub const POLLPRI: ::c_short = 0x002;
pub const POLLOUT: ::c_short = 0x004;
pub const POLLERR: ::c_short = 0x008;
pub const POLLHUP: ::c_short = 0x010;
pub const POLLNVAL: ::c_short = 0x020;

pub const PROT_NONE: ::c_int = 0;
pub const PROT_EXEC: ::c_int = 1;
pub const PROT_WRITE: ::c_int = 2;
pub const PROT_READ: ::c_int = 4;

pub const S_ISUID: ::c_int = 0x800;
pub const S_ISGID: ::c_int = 0x400;
pub const S_ISVTX: ::c_int = 0x200;
Expand Down Expand Up @@ -98,6 +166,8 @@ pub const F_SETFD: ::c_int = 2;
pub const F_GETFL: ::c_int = 3;
pub const F_SETFL: ::c_int = 4;

pub const FD_CLOEXEC: ::c_int = 0x0100_0000;

pub const O_RDONLY: ::c_int = 0x0001_0000;
pub const O_WRONLY: ::c_int = 0x0002_0000;
pub const O_RDWR: ::c_int = 0x0003_0000;
Expand Down Expand Up @@ -152,6 +222,17 @@ pub const SIGSYS: ::c_int = 31;
pub enum FILE {}
pub enum fpos_t {} // TODO: fill this out with a struct

// intentionally not public, only used for fd_set
cfg_if! {
if #[cfg(target_pointer_width = "32")] {
const ULONG_SIZE: usize = 32;
} else if #[cfg(target_pointer_width = "64")] {
const ULONG_SIZE: usize = 64;
} else {
// Unknown target_pointer_width
}
}

extern {
pub fn isalnum(c: c_int) -> c_int;
pub fn isalpha(c: c_int) -> c_int;
Expand Down Expand Up @@ -262,9 +343,22 @@ extern {
pub fn close(fd: ::c_int) -> ::c_int;
pub fn fchown(fd: ::c_int, uid: ::uid_t, gid: ::gid_t) -> ::c_int;
pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
pub fn fstat(fd: ::c_int, buf: *mut stat) -> ::c_int;
pub fn fsync(fd: ::c_int) -> ::c_int;
pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn getpid() -> pid_t;
pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
pub fn mmap(addr: *mut ::c_void,
len: ::size_t,
prot: ::c_int,
flags: ::c_int,
fd: ::c_int,
offset: off_t)
-> *mut ::c_void;
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) -> ::ssize_t;
pub fn setenv(name: *const c_char, val: *const c_char, overwrite: ::c_int)
-> ::c_int;
Expand Down
1 change: 1 addition & 0 deletions libc/src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2659,6 +2659,7 @@ extern {
fd: ::c_int,
newfd: ::c_int,
) -> ::c_int;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}

cfg_if! {
Expand Down
1 change: 1 addition & 0 deletions libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,4 +801,5 @@ extern {

pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
20 changes: 20 additions & 0 deletions libc/src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,19 @@ pub const TIOCSIG: ::c_uint = 0x2004745f;
pub const TIOCM_DCD: ::c_int = 0x40;
pub const H4DISC: ::c_int = 0x7;

pub const FIONCLEX: ::c_ulong = 0x20006602;
pub const FIONREAD: ::c_ulong = 0x4004667f;
pub const FIOASYNC: ::c_ulong = 0x8004667d;
pub const FIOSETOWN: ::c_ulong = 0x8004667c;
pub const FIOGETOWN: ::c_ulong = 0x4004667b;
pub const FIODTYPE: ::c_ulong = 0x4004667a;
pub const FIOGETLBA: ::c_ulong = 0x40046679;
pub const FIODGNAME: ::c_ulong = 0x80106678;
pub const FIONWRITE: ::c_ulong = 0x40046677;
pub const FIONSPACE: ::c_ulong = 0x40046676;
pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;
pub const FIOSEEKHOLE: ::c_ulong = 0xc0086662;

pub const JAIL_API_VERSION: u32 = 2;
pub const JAIL_CREATE: ::c_int = 0x01;
pub const JAIL_UPDATE: ::c_int = 0x02;
Expand Down Expand Up @@ -949,6 +962,12 @@ pub const UF_READONLY: ::c_ulong = 0x00001000;
pub const UF_HIDDEN: ::c_ulong = 0x00008000;
pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;

f! {
pub fn uname(buf: *mut ::utsname) -> ::c_int {
__xuname(256, buf as *mut ::c_void)
}
}

extern {
pub fn __error() -> *mut ::c_int;

Expand Down Expand Up @@ -1135,6 +1154,7 @@ extern {
pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;

pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
pub fn __xuname(nmln: ::c_int, buf: *mut ::c_void) -> ::c_int;
}

#[link(name = "util")]
Expand Down
1 change: 1 addition & 0 deletions libc/src/unix/bsd/netbsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ extern {
-> ::c_int;
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}

cfg_if! {
Expand Down
Loading

0 comments on commit 4fcdf20

Please sign in to comment.