summaryrefslogtreecommitdiff
path: root/libc/src/windows/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src/windows/mod.rs')
-rw-r--r--libc/src/windows/mod.rs67
1 files changed, 58 insertions, 9 deletions
diff --git a/libc/src/windows/mod.rs b/libc/src/windows/mod.rs
index f46eb36..4bea459 100644
--- a/libc/src/windows/mod.rs
+++ b/libc/src/windows/mod.rs
@@ -27,6 +27,7 @@ pub type ptrdiff_t = isize;
pub type intptr_t = isize;
pub type uintptr_t = usize;
pub type ssize_t = isize;
+pub type sighandler_t = usize;
pub type c_char = i8;
pub type c_long = i32;
@@ -49,6 +50,8 @@ pub type ino_t = u16;
pub enum timezone {}
pub type time64_t = i64;
+pub type SOCKET = ::uintptr_t;
+
s! {
// note this is the struct called stat64 in Windows. Not stat, nor stati64.
pub struct stat {
@@ -72,15 +75,15 @@ s! {
}
pub struct tm {
- tm_sec: ::c_int,
- tm_min: ::c_int,
- tm_hour: ::c_int,
- tm_mday: ::c_int,
- tm_mon: ::c_int,
- tm_year: ::c_int,
- tm_wday: ::c_int,
- tm_yday: ::c_int,
- tm_isdst: ::c_int,
+ pub tm_sec: ::c_int,
+ pub tm_min: ::c_int,
+ pub tm_hour: ::c_int,
+ pub tm_mday: ::c_int,
+ pub tm_mon: ::c_int,
+ pub tm_year: ::c_int,
+ pub tm_wday: ::c_int,
+ pub tm_yday: ::c_int,
+ pub tm_isdst: ::c_int,
}
pub struct timeval {
@@ -92,6 +95,11 @@ s! {
pub tv_sec: time_t,
pub tv_nsec: c_long,
}
+
+ pub struct sockaddr {
+ pub sa_family: c_ushort,
+ pub sa_data: [c_char; 14],
+ }
}
pub const INT_MIN: c_int = -2147483648;
@@ -177,6 +185,16 @@ pub const ENOTEMPTY: ::c_int = 41;
pub const EILSEQ: ::c_int = 42;
pub const STRUNCATE: ::c_int = 80;
+// signal codes
+pub const SIGINT: ::c_int = 2;
+pub const SIGILL: ::c_int = 4;
+pub const SIGFPE: ::c_int = 8;
+pub const SIGSEGV: ::c_int = 11;
+pub const SIGTERM: ::c_int = 15;
+pub const SIGABRT: ::c_int = 22;
+pub const NSIG: ::c_int = 23;
+pub const SIG_ERR: ::c_int = -1;
+
// inline comment below appeases style checker
#[cfg(all(target_env = "msvc", feature = "rustc-dep-of-std"))] // " if "
#[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))]
@@ -287,6 +305,9 @@ extern {
pub fn rand() -> c_int;
pub fn srand(seed: c_uint);
+ pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t;
+ pub fn raise(signum: c_int) -> c_int;
+
#[link_name = "_chmod"]
pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int;
#[link_name = "_wchmod"]
@@ -369,6 +390,34 @@ extern {
locale: *const wchar_t) -> *mut wchar_t;
}
+extern "system" {
+ pub fn listen(s: SOCKET, backlog: ::c_int) -> ::c_int;
+ pub fn accept(s: SOCKET, addr: *mut ::sockaddr,
+ addrlen: *mut ::c_int) -> SOCKET;
+ pub fn bind(s: SOCKET, name: *const ::sockaddr,
+ namelen: ::c_int) -> ::c_int;
+ pub fn connect(s: SOCKET, name: *const ::sockaddr,
+ namelen: ::c_int) -> ::c_int;
+ pub fn getpeername(s: SOCKET, name: *mut ::sockaddr,
+ nameln: *mut ::c_int) -> ::c_int;
+ pub fn getsockname(s: SOCKET, name: *mut ::sockaddr,
+ nameln: *mut ::c_int) -> ::c_int;
+ pub fn getsockopt(s: SOCKET, level: ::c_int, optname: ::c_int,
+ optval: *mut ::c_char,
+ optlen: *mut ::c_int) -> ::c_int;
+ pub fn recvfrom(s: SOCKET, buf: *mut ::c_char, len: ::c_int,
+ flags: ::c_int, from: *mut ::sockaddr,
+ fromlen: *mut ::c_int) -> ::c_int;
+ pub fn sendto(s: SOCKET, buf: *const ::c_char, len: ::c_int,
+ flags: ::c_int, to: *const ::sockaddr,
+ tolen: ::c_int) -> ::c_int;
+ pub fn setsockopt(s: SOCKET, level: ::c_int, optname: ::c_int,
+ optval: *const ::c_char,
+ optlen: ::c_int) -> ::c_int;
+ pub fn socket(af: ::c_int, socket_type: ::c_int,
+ protocol: ::c_int) -> SOCKET;
+}
+
cfg_if! {
if #[cfg(core_cvoid)] {
pub use core::ffi::c_void;