diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-10-27 15:37:28 +0100 |
|---|---|---|
| committer | LemonBoy <thatlemon@gmail.com> | 2020-10-27 21:52:47 +0100 |
| commit | 8044ed4c66840503186fc3bbeac4328c6cf76349 (patch) | |
| tree | e2292041959ea606e7f0d97b087d11a428534aa6 /lib/std/os | |
| parent | 194e29adfccbd5076a3523572c7e119d4bfa647d (diff) | |
| download | zig-8044ed4c66840503186fc3bbeac4328c6cf76349.tar.gz zig-8044ed4c66840503186fc3bbeac4328c6cf76349.zip | |
std: Add basic smoke test for net functionality
Diffstat (limited to 'lib/std/os')
| -rw-r--r-- | lib/std/os/bits/windows.zig | 35 | ||||
| -rw-r--r-- | lib/std/os/linux.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/test.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/windows/ws2_32.zig | 42 |
4 files changed, 79 insertions, 2 deletions
diff --git a/lib/std/os/bits/windows.zig b/lib/std/os/bits/windows.zig index a92961881e..dda57208f8 100644 --- a/lib/std/os/bits/windows.zig +++ b/lib/std/os/bits/windows.zig @@ -256,6 +256,41 @@ pub const POLLERR = ws2_32.POLLERR; pub const POLLHUP = ws2_32.POLLHUP; pub const POLLNVAL = ws2_32.POLLNVAL; +pub const SOL_SOCKET = ws2_32.SOL_SOCKET; + +pub const SO_DEBUG = ws2_32.SO_DEBUG; +pub const SO_ACCEPTCONN = ws2_32.SO_ACCEPTCONN; +pub const SO_REUSEADDR = ws2_32.SO_REUSEADDR; +pub const SO_KEEPALIVE = ws2_32.SO_KEEPALIVE; +pub const SO_DONTROUTE = ws2_32.SO_DONTROUTE; +pub const SO_BROADCAST = ws2_32.SO_BROADCAST; +pub const SO_USELOOPBACK = ws2_32.SO_USELOOPBACK; +pub const SO_LINGER = ws2_32.SO_LINGER; +pub const SO_OOBINLINE = ws2_32.SO_OOBINLINE; + +pub const SO_DONTLINGER = ws2_32.SO_DONTLINGER; +pub const SO_EXCLUSIVEADDRUSE = ws2_32.SO_EXCLUSIVEADDRUSE; + +pub const SO_SNDBUF = ws2_32.SO_SNDBUF; +pub const SO_RCVBUF = ws2_32.SO_RCVBUF; +pub const SO_SNDLOWAT = ws2_32.SO_SNDLOWAT; +pub const SO_RCVLOWAT = ws2_32.SO_RCVLOWAT; +pub const SO_SNDTIMEO = ws2_32.SO_SNDTIMEO; +pub const SO_RCVTIMEO = ws2_32.SO_RCVTIMEO; +pub const SO_ERROR = ws2_32.SO_ERROR; +pub const SO_TYPE = ws2_32.SO_TYPE; + +pub const SO_GROUP_ID = ws2_32.SO_GROUP_ID; +pub const SO_GROUP_PRIORITY = ws2_32.SO_GROUP_PRIORITY; +pub const SO_MAX_MSG_SIZE = ws2_32.SO_MAX_MSG_SIZE; +pub const SO_PROTOCOL_INFOA = ws2_32.SO_PROTOCOL_INFOA; +pub const SO_PROTOCOL_INFOW = ws2_32.SO_PROTOCOL_INFOW; + +pub const PVD_CONFIG = ws2_32.PVD_CONFIG; +pub const SO_CONDITIONAL_ACCEPT = ws2_32.SO_CONDITIONAL_ACCEPT; + +pub const TCP_NODELAY = ws2_32.TCP_NODELAY; + pub const O_RDONLY = 0o0; pub const O_WRONLY = 0o1; pub const O_RDWR = 0o2; diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index e38d9bc10d..357660a05a 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -1279,7 +1279,7 @@ pub fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: ?*const rlimit, @bitCast(usize, @as(isize, pid)), @bitCast(usize, @as(isize, @enumToInt(resource))), @ptrToInt(new_limit), - @ptrToInt(old_limit) + @ptrToInt(old_limit), ); } diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index 58c2b311b1..7df05df2cc 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -594,7 +594,7 @@ test "fsync" { test "getrlimit and setrlimit" { // TODO enable for other systems when implemented - if(builtin.os.tag != .linux){ + if (builtin.os.tag != .linux) { return error.SkipZigTest; } diff --git a/lib/std/os/windows/ws2_32.zig b/lib/std/os/windows/ws2_32.zig index cfd48e4ff5..f0bbf75854 100644 --- a/lib/std/os/windows/ws2_32.zig +++ b/lib/std/os/windows/ws2_32.zig @@ -718,6 +718,41 @@ const IOC_WS2 = 0x08000000; pub const SIO_BASE_HANDLE = IOC_OUT | IOC_WS2 | 34; +pub const SOL_SOCKET = 0xffff; + +pub const SO_DEBUG = 0x0001; +pub const SO_ACCEPTCONN = 0x0002; +pub const SO_REUSEADDR = 0x0004; +pub const SO_KEEPALIVE = 0x0008; +pub const SO_DONTROUTE = 0x0010; +pub const SO_BROADCAST = 0x0020; +pub const SO_USELOOPBACK = 0x0040; +pub const SO_LINGER = 0x0080; +pub const SO_OOBINLINE = 0x0100; + +pub const SO_DONTLINGER = ~@as(u32, SO_LINGER); +pub const SO_EXCLUSIVEADDRUSE = ~@as(u32, SO_REUSEADDR); + +pub const SO_SNDBUF = 0x1001; +pub const SO_RCVBUF = 0x1002; +pub const SO_SNDLOWAT = 0x1003; +pub const SO_RCVLOWAT = 0x1004; +pub const SO_SNDTIMEO = 0x1005; +pub const SO_RCVTIMEO = 0x1006; +pub const SO_ERROR = 0x1007; +pub const SO_TYPE = 0x1008; + +pub const SO_GROUP_ID = 0x2001; +pub const SO_GROUP_PRIORITY = 0x2002; +pub const SO_MAX_MSG_SIZE = 0x2003; +pub const SO_PROTOCOL_INFOA = 0x2004; +pub const SO_PROTOCOL_INFOW = 0x2005; + +pub const PVD_CONFIG = 0x3001; +pub const SO_CONDITIONAL_ACCEPT = 0x3002; + +pub const TCP_NODELAY = 0x0001; + pub extern "ws2_32" fn WSAStartup( wVersionRequired: WORD, lpWSAData: *WSADATA, @@ -835,3 +870,10 @@ pub extern "ws2_32" fn getsockname( name: *sockaddr, namelen: *c_int, ) callconv(.Stdcall) c_int; +pub extern "ws2_32" fn setsockopt( + s: SOCKET, + level: u32, + optname: u32, + optval: ?*const c_void, + optlen: socklen_t, +) callconv(.Stdcall) c_int; |
