pub type id_t = i64;
pub type vm_size_t = ::uintptr_t;
+// elf.h
+
+pub type Elf32_Addr = u32;
+pub type Elf32_Half = u16;
+pub type Elf32_Lword = u64;
+pub type Elf32_Off = u32;
+pub type Elf32_Sword = i32;
+pub type Elf32_Word = u32;
+
+pub type Elf64_Addr = u64;
+pub type Elf64_Half = u16;
+pub type Elf64_Lword = u64;
+pub type Elf64_Off = u64;
+pub type Elf64_Sword = i32;
+pub type Elf64_Sxword = i64;
+pub type Elf64_Word = u32;
+pub type Elf64_Xword = u64;
+
+pub type iconv_t = *mut ::c_void;
+
+cfg_if! {
+ if #[cfg(target_pointer_width = "64")] {
+ type Elf_Addr = Elf64_Addr;
+ type Elf_Half = Elf64_Half;
+ type Elf_Phdr = Elf64_Phdr;
+ } else if #[cfg(target_pointer_width = "32")] {
+ type Elf_Addr = Elf32_Addr;
+ type Elf_Half = Elf32_Half;
+ type Elf_Phdr = Elf32_Phdr;
+ }
+}
+
+// link.h
+
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
impl ::Copy for timezone {}
pub unsafe fn si_uid(&self) -> ::uid_t {
self.si_uid
}
+
+ pub unsafe fn si_status(&self) -> ::c_int {
+ self.si_status
+ }
}
s! {
pub piod_addr: *mut ::c_void,
pub piod_len: ::size_t,
}
+
+ // bpf.h
+
+ pub struct bpf_program {
+ pub bf_len: ::c_uint,
+ pub bf_insns: *mut bpf_insn,
+ }
+
+ pub struct bpf_stat {
+ pub bs_recv: ::c_uint,
+ pub bs_drop: ::c_uint,
+ }
+
+ pub struct bpf_version {
+ pub bv_major: ::c_ushort,
+ pub bv_minor: ::c_ushort,
+ }
+
+ pub struct bpf_hdr {
+ pub bh_tstamp: ::timeval,
+ pub bh_caplen: u32,
+ pub bh_datalen: u32,
+ pub bh_hdrlen: ::c_ushort,
+ }
+
+ pub struct bpf_insn {
+ pub code: ::c_ushort,
+ pub jt: ::c_uchar,
+ pub jf: ::c_uchar,
+ pub k: u32,
+ }
+
+ pub struct bpf_dltlist {
+ bfl_len: ::c_uint,
+ bfl_list: *mut ::c_uint,
+ }
+
+ // elf.h
+
+ pub struct Elf32_Phdr {
+ pub p_type: Elf32_Word,
+ pub p_offset: Elf32_Off,
+ pub p_vaddr: Elf32_Addr,
+ pub p_paddr: Elf32_Addr,
+ pub p_filesz: Elf32_Word,
+ pub p_memsz: Elf32_Word,
+ pub p_flags: Elf32_Word,
+ pub p_align: Elf32_Word,
+ }
+
+ pub struct Elf64_Phdr {
+ pub p_type: Elf64_Word,
+ pub p_flags: Elf64_Word,
+ pub p_offset: Elf64_Off,
+ pub p_vaddr: Elf64_Addr,
+ pub p_paddr: Elf64_Addr,
+ pub p_filesz: Elf64_Xword,
+ pub p_memsz: Elf64_Xword,
+ pub p_align: Elf64_Xword,
+ }
+
+ // link.h
+
+ pub struct dl_phdr_info {
+ pub dlpi_addr: Elf_Addr,
+ pub dlpi_name: *const ::c_char,
+ pub dlpi_phdr: *const Elf_Phdr,
+ pub dlpi_phnum: Elf_Half,
+ pub dlpi_adds: ::c_ulonglong,
+ pub dlpi_subs: ::c_ulonglong,
+ pub dlpi_tls_modid: usize,
+ pub dlpi_tls_data: *mut ::c_void,
+ }
}
s_no_extra_traits! {
}
}
+// Non-public helper constant
+cfg_if! {
+ if #[cfg(all(not(libc_const_size_of), target_pointer_width = "32"))] {
+ const SIZEOF_LONG: usize = 4;
+ } else if #[cfg(all(not(libc_const_size_of), target_pointer_width = "64"))] {
+ const SIZEOF_LONG: usize = 8;
+ } else if #[cfg(libc_const_size_of)] {
+ const SIZEOF_LONG: usize = ::mem::size_of::<::c_long>();
+ }
+}
+
#[deprecated(
since = "0.2.64",
note = "Can vary at runtime. Use sysconf(3) instead"
pub const SO_ERROR: ::c_int = 0x1007;
pub const SO_TYPE: ::c_int = 0x1008;
+pub const LOCAL_PEERCRED: ::c_int = 1;
+
pub const SHUT_RD: ::c_int = 0;
pub const SHUT_WR: ::c_int = 1;
pub const SHUT_RDWR: ::c_int = 2;
pub const NI_MAXHOST: ::size_t = 1025;
+pub const XU_NGROUPS: ::c_int = 16;
+pub const XUCRED_VERSION: ::c_uint = 0;
+
pub const RTLD_LOCAL: ::c_int = 0;
pub const RTLD_NODELETE: ::c_int = 0x1000;
pub const RTLD_NOLOAD: ::c_int = 0x2000;
pub const CMGROUP_MAX: usize = 16;
// https://github.com/freebsd/freebsd/blob/master/sys/net/bpf.h
-// sizeof(long)
-pub const BPF_ALIGNMENT: ::c_int = 8;
+pub const BPF_ALIGNMENT: usize = SIZEOF_LONG;
// Values for rtprio struct (prio field) and syscall (function argument)
pub const RTP_PRIO_MIN: ::c_ushort = 0;
extern "C" {
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
- pub fn sem_init(
- sem: *mut sem_t,
- pshared: ::c_int,
- value: ::c_uint,
- ) -> ::c_int;
+ pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int;
pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
- pub fn clock_settime(
- clk_id: ::clockid_t,
- tp: *const ::timespec,
- ) -> ::c_int;
- pub fn clock_getcpuclockid(
- pid: ::pid_t,
- clk_id: *mut ::clockid_t,
- ) -> ::c_int;
+ pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
+ pub fn clock_getcpuclockid(pid: ::pid_t, clk_id: *mut ::clockid_t) -> ::c_int;
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
pub fn duplocale(base: ::locale_t) -> ::locale_t;
timeout: *const ::timespec,
) -> ::c_int;
pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
- pub fn lio_listio(
- mode: ::c_int,
- aiocb_list: *const *mut aiocb,
- nitems: ::c_int,
- sevp: *mut sigevent,
- ) -> ::c_int;
pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
- pub fn memrchr(
- cx: *const ::c_void,
- c: ::c_int,
- n: ::size_t,
- ) -> *mut ::c_void;
- pub fn mkfifoat(
- dirfd: ::c_int,
- pathname: *const ::c_char,
- mode: ::mode_t,
- ) -> ::c_int;
+ pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
+ pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int;
#[cfg_attr(
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "mknodat@FBSD_1.1"
mode: ::mode_t,
dev: dev_t,
) -> ::c_int;
- pub fn mincore(
- addr: *const ::c_void,
- len: ::size_t,
- vec: *mut ::c_char,
- ) -> ::c_int;
- pub fn newlocale(
- mask: ::c_int,
- locale: *const ::c_char,
- base: ::locale_t,
- ) -> ::locale_t;
- pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t)
- -> *mut ::c_char;
+ pub fn mincore(addr: *const ::c_void, len: ::size_t, vec: *mut ::c_char) -> ::c_int;
+ pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t;
+ pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
pub fn ppoll(
fds: *mut ::pollfd,
timeout: *const ::timespec,
sigmask: *const sigset_t,
) -> ::c_int;
- pub fn preadv(
- fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t,
- ) -> ::ssize_t;
- pub fn pthread_attr_get_np(
- tid: ::pthread_t,
- attr: *mut ::pthread_attr_t,
- ) -> ::c_int;
+ pub fn preadv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t;
+ pub fn pthread_attr_get_np(tid: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int;
pub fn pthread_attr_getguardsize(
attr: *const ::pthread_attr_t,
guardsize: *mut ::size_t,
attr: *mut pthread_condattr_t,
clock_id: ::clockid_t,
) -> ::c_int;
- pub fn pthread_condattr_setpshared(
- attr: *mut pthread_condattr_t,
- pshared: ::c_int,
- ) -> ::c_int;
+ pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: ::c_int) -> ::c_int;
pub fn pthread_main_np() -> ::c_int;
pub fn pthread_mutex_timedlock(
lock: *mut pthread_mutex_t,
attr: *const pthread_rwlockattr_t,
val: *mut ::c_int,
) -> ::c_int;
- pub fn pthread_rwlockattr_setpshared(
- attr: *mut pthread_rwlockattr_t,
- val: ::c_int,
- ) -> ::c_int;
+ pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: ::c_int) -> ::c_int;
pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char);
- pub fn ptrace(
- request: ::c_int,
- pid: ::pid_t,
- addr: *mut ::c_char,
- data: ::c_int,
- ) -> ::c_int;
+ pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_char, data: ::c_int) -> ::c_int;
pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
- pub fn pwritev(
- fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t,
- ) -> ::ssize_t;
+ pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t)
+ -> ::ssize_t;
pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char;
- pub fn rtprio(
- function: ::c_int,
- pid: ::pid_t,
- rtp: *mut rtprio,
- ) -> ::c_int;
+ pub fn rtprio(function: ::c_int, pid: ::pid_t, rtp: *mut rtprio) -> ::c_int;
pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
pub fn sched_setscheduler(
pid: ::pid_t,
param: *const ::sched_param,
) -> ::c_int;
pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int;
- pub fn sem_timedwait(
- sem: *mut sem_t,
- abstime: *const ::timespec,
- ) -> ::c_int;
+ pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int;
pub fn sendfile(
fd: ::c_int,
s: ::c_int,
) -> ::c_int;
pub fn setdomainname(name: *const ::c_char, len: ::c_int) -> ::c_int;
pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int;
- pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int)
- -> ::c_int;
+ pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int;
pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
- pub fn settimeofday(
- tv: *const ::timeval,
- tz: *const ::timezone,
- ) -> ::c_int;
+ pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int;
pub fn setutxent();
- pub fn shm_open(
- name: *const ::c_char,
- oflag: ::c_int,
- mode: ::mode_t,
- ) -> ::c_int;
+ pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int;
pub fn sigtimedwait(
set: *const sigset_t,
info: *mut siginfo_t,
pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
+
+ // #include <link.h>
+ pub fn dl_iterate_phdr(
+ callback: ::Option<
+ unsafe extern "C" fn(
+ info: *mut dl_phdr_info,
+ size: usize,
+ data: *mut ::c_void,
+ ) -> ::c_int,
+ >,
+ data: *mut ::c_void,
+ ) -> ::c_int;
+
+ pub fn iconv_open(tocode: *const ::c_char, fromcode: *const ::c_char) -> iconv_t;
+ pub fn iconv(
+ cd: iconv_t,
+ inbuf: *mut *mut ::c_char,
+ inbytesleft: *mut ::size_t,
+ outbuf: *mut *mut ::c_char,
+ outbytesleft: *mut ::size_t,
+ ) -> ::size_t;
+ pub fn iconv_close(cd: iconv_t) -> ::c_int;
}
#[link(name = "rt")]
extern "C" {
- pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
- pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
- pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
- pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
- pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
- pub fn aio_suspend(
- aiocb_list: *const *const aiocb,
- nitems: ::c_int,
- timeout: *const ::timespec,
- ) -> ::c_int;
- pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
- pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent)
- -> ::c_int;
+ pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent) -> ::c_int;
pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
pub fn mq_receive(
mqd: ::mqd_t,
msg_len: ::size_t,
msg_prio: ::c_uint,
) -> ::c_int;
- pub fn mq_setattr(
- mqd: ::mqd_t,
- newattr: *const ::mq_attr,
- oldattr: *mut ::mq_attr,
- ) -> ::c_int;
+ pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int;
pub fn mq_timedreceive(
mqd: ::mqd_t,
msg_ptr: *mut ::c_char,