Skip to content

Commit fe7ccff

Browse files
committed
Auto merge of #1566 - mikehoyle:winapi-add, r=gnzlbg
Add a few functions & POSIX error codes to Windows API This change adds a few simple additional functions to the windows apis, as well as some additional error codes. Tests and style pass, as per contributing guidelines.
2 parents 779a08b + 3ecdafb commit fe7ccff

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/windows/mod.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,48 @@ pub const ENOTEMPTY: ::c_int = 41;
183183
pub const EILSEQ: ::c_int = 42;
184184
pub const STRUNCATE: ::c_int = 80;
185185

186+
// POSIX Supplement (from errno.h)
187+
pub const EADDRINUSE: ::c_int = 100;
188+
pub const EADDRNOTAVAIL: ::c_int = 101;
189+
pub const EAFNOSUPPORT: ::c_int = 102;
190+
pub const EALREADY: ::c_int = 103;
191+
pub const EBADMSG: ::c_int = 104;
192+
pub const ECANCELED: ::c_int = 105;
193+
pub const ECONNABORTED: ::c_int = 106;
194+
pub const ECONNREFUSED: ::c_int = 107;
195+
pub const ECONNRESET: ::c_int = 108;
196+
pub const EDESTADDRREQ: ::c_int = 109;
197+
pub const EHOSTUNREACH: ::c_int = 110;
198+
pub const EIDRM: ::c_int = 111;
199+
pub const EINPROGRESS: ::c_int = 112;
200+
pub const EISCONN: ::c_int = 113;
201+
pub const ELOOP: ::c_int = 114;
202+
pub const EMSGSIZE: ::c_int = 115;
203+
pub const ENETDOWN: ::c_int = 116;
204+
pub const ENETRESET: ::c_int = 117;
205+
pub const ENETUNREACH: ::c_int = 118;
206+
pub const ENOBUFS: ::c_int = 119;
207+
pub const ENODATA: ::c_int = 120;
208+
pub const ENOLINK: ::c_int = 121;
209+
pub const ENOMSG: ::c_int = 122;
210+
pub const ENOPROTOOPT: ::c_int = 123;
211+
pub const ENOSR: ::c_int = 124;
212+
pub const ENOSTR: ::c_int = 125;
213+
pub const ENOTCONN: ::c_int = 126;
214+
pub const ENOTRECOVERABLE: ::c_int = 127;
215+
pub const ENOTSOCK: ::c_int = 128;
216+
pub const ENOTSUP: ::c_int = 129;
217+
pub const EOPNOTSUPP: ::c_int = 130;
218+
pub const EOVERFLOW: ::c_int = 132;
219+
pub const EOWNERDEAD: ::c_int = 133;
220+
pub const EPROTO: ::c_int = 134;
221+
pub const EPROTONOSUPPORT: ::c_int = 135;
222+
pub const EPROTOTYPE: ::c_int = 136;
223+
pub const ETIME: ::c_int = 137;
224+
pub const ETIMEDOUT: ::c_int = 138;
225+
pub const ETXTBSY: ::c_int = 139;
226+
pub const EWOULDBLOCK: ::c_int = 140;
227+
186228
// signal codes
187229
pub const SIGINT: ::c_int = 2;
188230
pub const SIGILL: ::c_int = 4;
@@ -358,6 +400,8 @@ extern "C" {
358400
pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t;
359401
pub fn raise(signum: c_int) -> c_int;
360402

403+
#[link_name = "_time64"]
404+
pub fn time(destTime: *mut time_t) -> time_t;
361405
#[link_name = "_chmod"]
362406
pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int;
363407
#[link_name = "_wchmod"]
@@ -425,6 +469,12 @@ extern "C" {
425469
pub fn isatty(fd: ::c_int) -> ::c_int;
426470
#[link_name = "_lseek"]
427471
pub fn lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long;
472+
#[link_name = "_lseeki64"]
473+
pub fn lseek64(
474+
fd: ::c_int,
475+
offset: c_longlong,
476+
origin: ::c_int,
477+
) -> c_longlong;
428478
#[link_name = "_pipe"]
429479
pub fn pipe(
430480
fds: *mut ::c_int,

src/windows/msvc.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
pub const L_tmpnam: ::c_uint = 260;
22
pub const TMP_MAX: ::c_uint = 0x7fff_ffff;
33

4+
// POSIX Supplement (from errno.h)
5+
// This particular error code is only currently available in msvc toolchain
6+
pub const EOTHER: ::c_int = 131;
7+
48
extern "C" {
59
#[link_name = "_stricmp"]
610
pub fn stricmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int;

0 commit comments

Comments
 (0)