| author | |
| committer | |
| log | e1f04b8d5976437f814e129486719d6e6043c04f |
| tree | 9c438cdc9ad33e3de8ae27095ebbb87cc24384cc |
| parent | 326939960399088e4fc89464eab2bfebca83793e |
| signature | Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw |
5 files changed, 95 insertions(+), 54 deletions(-)
darwin.zig+5-5| ... | ... | @@ -235,19 +235,19 @@ pub const errno = struct { |
| 235 | 235 | // assert Enum is sequential |
| 236 | 236 | var value: c_ushort = 0; // SUCCESS |
| 237 | 237 | for (std.enums.values(Enum)) |val| { |
| 238 | std.debug.assert(@intFromEnum(val) > value); | |
| 239 | value = @intFromEnum(val); | |
| 238 | std.debug.assert(@backingInt(val) > value); | |
| 239 | value = @backingInt(val); | |
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | comptime { |
| 243 | 243 | // sanity test |
| 244 | std.debug.assert(@intFromEnum(Enum.EPERM) == 1); | |
| 244 | std.debug.assert(@backingInt(Enum.EPERM) == 1); | |
| 245 | 245 | } |
| 246 | 246 | const list = blk: { |
| 247 | 247 | const values = std.enums.values(Enum); |
| 248 | const len = @intFromEnum(values[values.len - 1]) + 1; | |
| 248 | const len = @backingInt(values[values.len - 1]) + 1; | |
| 249 | 249 | var errors: [len]Error = @splat(error.Unexpected); |
| 250 | for (values) |f| errors[@intFromEnum(f)] = @field(Error, @tagName(f)); | |
| 250 | for (values) |f| errors[@backingInt(f)] = @field(Error, @tagName(f)); | |
| 251 | 251 | const final = errors; |
| 252 | 252 | break :blk final; |
| 253 | 253 | }; |
freebsd.zig+10-12| ... | ... | @@ -216,19 +216,19 @@ pub const errno = struct { |
| 216 | 216 | // assert Enum is sequential |
| 217 | 217 | var value: c_ushort = 0; // SUCCESS |
| 218 | 218 | for (std.enums.values(Enum)) |val| { |
| 219 | std.debug.assert(@intFromEnum(val) > value); | |
| 220 | value = @intFromEnum(val); | |
| 219 | std.debug.assert(@backingInt(val) > value); | |
| 220 | value = @backingInt(val); | |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | comptime { |
| 224 | 224 | // sanity test |
| 225 | std.debug.assert(@intFromEnum(Enum.EPERM) == 1); | |
| 225 | std.debug.assert(@backingInt(Enum.EPERM) == 1); | |
| 226 | 226 | } |
| 227 | 227 | const list = blk: { |
| 228 | 228 | const values = std.enums.values(Enum); |
| 229 | const len = @intFromEnum(values[values.len - 1]) + 1; | |
| 229 | const len = @backingInt(values[values.len - 1]) + 1; | |
| 230 | 230 | var errors: [len]Error = @splat(error.Unexpected); |
| 231 | for (values) |f| errors[@intFromEnum(f)] = @field(Error, @tagName(f)); | |
| 231 | for (values) |f| errors[@backingInt(f)] = @field(Error, @tagName(f)); | |
| 232 | 232 | const final = errors; |
| 233 | 233 | break :blk final; |
| 234 | 234 | }; |
| ... | ... | @@ -279,7 +279,7 @@ pub const eai = struct { |
| 279 | 279 | }; |
| 280 | 280 | |
| 281 | 281 | pub fn fromInt(code: c_int) Error { |
| 282 | return switch (@as(Enum, @enumFromInt(code))) { | |
| 282 | return switch (@as(Enum, @fromBackingInt(@intCast(code)))) { | |
| 283 | 283 | .EAI_ADDRFAMILY => error.EAI_ADDRFAMILY, |
| 284 | 284 | .EAI_AGAIN => error.EAI_AGAIN, |
| 285 | 285 | .EAI_BADFLAGS => error.EAI_BADFLAGS, |
| ... | ... | @@ -423,9 +423,7 @@ pub const struct_addrinfo = extern struct { flags: c_int, family: c_int, socktyp |
| 423 | 423 | pub const struct_dirent = extern struct { fileno: ino_t, off: off_t, reclen: u16, type: DT, pad0: u8, namlen: u16, pad1: u16, name: [NAME_MAX + 1]u8 }; |
| 424 | 424 | pub const struct_timeval = extern struct { sec: time_t, usec: suseconds_t }; |
| 425 | 425 | |
| 426 | const impdef = @cImport({ | |
| 427 | @cInclude("pthread.h"); | |
| 428 | }); | |
| 426 | const impdef = @import("c"); | |
| 429 | 427 | pub const pthread_t = impdef.pthread_t; |
| 430 | 428 | pub const pthread_attr_t = impdef.pthread_attr_t; |
| 431 | 429 | pub const pthread_mutexattr_t = impdef.pthread_mutexattr_t; |
| ... | ... | @@ -1085,7 +1083,7 @@ pub fn freeaddrinfo(ai: *const struct_addrinfo) void { |
| 1085 | 1083 | return libc.freeaddrinfo(ai); |
| 1086 | 1084 | } |
| 1087 | 1085 | pub fn socket(domain: AF, ty: c_int, protocol: c_int) errno.Error!c_uint { |
| 1088 | const rc = libc.socket(@intFromEnum(domain), ty, protocol); | |
| 1086 | const rc = libc.socket(@backingInt(domain), ty, protocol); | |
| 1089 | 1087 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 1090 | 1088 | std.debug.assert(rc > 0); |
| 1091 | 1089 | return @intCast(rc); |
| ... | ... | @@ -1103,7 +1101,7 @@ pub fn getrandom(buf: []u8, flags: c_uint) ![]u8 { |
| 1103 | 1101 | } |
| 1104 | 1102 | pub fn clock_gettime(clock_id: CLOCK) !struct_timespec { |
| 1105 | 1103 | var tp: struct_timespec = undefined; |
| 1106 | const rc = libc.clock_gettime(@intFromEnum(clock_id), &tp); | |
| 1104 | const rc = libc.clock_gettime(@backingInt(clock_id), &tp); | |
| 1107 | 1105 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 1108 | 1106 | std.debug.assert(rc == 0); |
| 1109 | 1107 | return tp; |
| ... | ... | @@ -1200,7 +1198,7 @@ pub fn accept4(socketfd: c_uint, noalias address: ?*struct_sockaddr, noalias add |
| 1200 | 1198 | return @intCast(rc); |
| 1201 | 1199 | } |
| 1202 | 1200 | pub fn shutdown(socketfd: c_uint, how: SHUT) errno.Error!void { |
| 1203 | const rc = libc.shutdown(@intCast(socketfd), @intFromEnum(how)); | |
| 1201 | const rc = libc.shutdown(@intCast(socketfd), @backingInt(how)); | |
| 1204 | 1202 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 1205 | 1203 | std.debug.assert(rc == 0); |
| 1206 | 1204 | } |
linux.zig+12-13| ... | ... | @@ -894,6 +894,9 @@ pub const errno = struct { |
| 894 | 894 | .hppa, |
| 895 | 895 | .hppa64, |
| 896 | 896 | .kvx, |
| 897 | .ez80, | |
| 898 | .m88k, | |
| 899 | .spork8, | |
| 897 | 900 | => unreachable, |
| 898 | 901 | }; |
| 899 | 902 | |
| ... | ... | @@ -910,19 +913,19 @@ pub const errno = struct { |
| 910 | 913 | // assert Enum is sequential |
| 911 | 914 | var value: c_ushort = 0; // SUCCESS |
| 912 | 915 | for (std.enums.values(Enum)) |val| { |
| 913 | std.debug.assert(@intFromEnum(val) > value); | |
| 914 | value = @intFromEnum(val); | |
| 916 | std.debug.assert(@backingInt(val) > value); | |
| 917 | value = @backingInt(val); | |
| 915 | 918 | } |
| 916 | 919 | } |
| 917 | 920 | comptime { |
| 918 | 921 | // sanity test |
| 919 | std.debug.assert(@intFromEnum(Enum.EPERM) == 1); | |
| 922 | std.debug.assert(@backingInt(Enum.EPERM) == 1); | |
| 920 | 923 | } |
| 921 | 924 | const list = blk: { |
| 922 | 925 | const values = std.enums.values(Enum); |
| 923 | const len = @intFromEnum(values[values.len - 1]) + 1; | |
| 926 | const len = @backingInt(values[values.len - 1]) + 1; | |
| 924 | 927 | var errors: [len]Error = @splat(error.Unexpected); |
| 925 | for (values) |f| errors[@intFromEnum(f)] = @field(Error, @tagName(f)); | |
| 928 | for (values) |f| errors[@backingInt(f)] = @field(Error, @tagName(f)); | |
| 926 | 929 | const final = errors; |
| 927 | 930 | break :blk final; |
| 928 | 931 | }; |
| ... | ... | @@ -969,7 +972,7 @@ pub const eai = struct { |
| 969 | 972 | }; |
| 970 | 973 | |
| 971 | 974 | pub fn fromInt(code: c_int) Error { |
| 972 | return switch (@as(Enum, @enumFromInt(code))) { | |
| 975 | return switch (@as(Enum, @fromBackingInt(@intCast(code)))) { | |
| 973 | 976 | .EAI_BADFLAGS => error.EAI_BADFLAGS, |
| 974 | 977 | .EAI_NONAME => error.EAI_NONAME, |
| 975 | 978 | .EAI_AGAIN => error.EAI_AGAIN, |
| ... | ... | @@ -2906,10 +2909,7 @@ pub const nfds_t = c_ulong; |
| 2906 | 2909 | pub const struct_pollfd = extern struct { fd: c_int, events: c_short, revents: c_short }; |
| 2907 | 2910 | pub const struct_tm = extern struct { sec: c_int, min: c_int, hour: c_int, mday: c_int, mon: c_int, year: c_int, wday: c_int, yday: c_int, isdst: c_int, gmtoff: c_long, zone: [*:0]const u8 }; |
| 2908 | 2911 | |
| 2909 | const impdef = @cImport({ | |
| 2910 | @cInclude("pthread.h"); | |
| 2911 | @cInclude("termios.h"); | |
| 2912 | }); | |
| 2912 | const impdef = @import("c"); | |
| 2913 | 2913 | pub const pthread_t = impdef.pthread_t; |
| 2914 | 2914 | pub const pthread_attr_t = impdef.pthread_attr_t; |
| 2915 | 2915 | pub const pthread_mutexattr_t = impdef.pthread_mutexattr_t; |
| ... | ... | @@ -2918,7 +2918,6 @@ pub const pthread_condattr_t = impdef.pthread_condattr_t; |
| 2918 | 2918 | pub const pthread_cond_t = impdef.pthread_cond_t; |
| 2919 | 2919 | pub const pthread_rwlockattr_t = impdef.pthread_rwlockattr_t; |
| 2920 | 2920 | pub const pthread_rwlock_t = impdef.pthread_rwlock_t; |
| 2921 | pub const struct_termios = impdef.struct_termios; | |
| 2922 | 2921 | |
| 2923 | 2922 | pub const AT = struct { |
| 2924 | 2923 | pub const FDCWD = -100; |
| ... | ... | @@ -3480,7 +3479,7 @@ pub fn fstatat(fd: c_int, path: [*:0]const u8, flag: c_int) errno.Error!struct_s |
| 3480 | 3479 | return buf; |
| 3481 | 3480 | } |
| 3482 | 3481 | pub fn socket(domain: AF, ty: c_int, protocol: c_int) errno.Error!c_uint { |
| 3483 | const rc = libc.socket(@intFromEnum(domain), ty, protocol); | |
| 3482 | const rc = libc.socket(@backingInt(domain), ty, protocol); | |
| 3484 | 3483 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 3485 | 3484 | std.debug.assert(rc > 0); |
| 3486 | 3485 | return @intCast(rc); |
| ... | ... | @@ -3501,7 +3500,7 @@ pub fn connect(socketfd: c_uint, address: *const struct_sockaddr, address_len: s |
| 3501 | 3500 | std.debug.assert(rc == 0); |
| 3502 | 3501 | } |
| 3503 | 3502 | pub fn shutdown(socketfd: c_uint, how: SHUT) errno.Error!void { |
| 3504 | const rc = libc.shutdown(@intCast(socketfd), @intFromEnum(how)); | |
| 3503 | const rc = libc.shutdown(@intCast(socketfd), @backingInt(how)); | |
| 3505 | 3504 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 3506 | 3505 | std.debug.assert(rc == 0); |
| 3507 | 3506 | } |
netbsd.zig+58-12| ... | ... | @@ -217,19 +217,19 @@ pub const errno = struct { |
| 217 | 217 | // assert Enum is sequential |
| 218 | 218 | var value: c_ushort = 0; // SUCCESS |
| 219 | 219 | for (std.enums.values(Enum)) |val| { |
| 220 | std.debug.assert(@intFromEnum(val) > value); | |
| 221 | value = @intFromEnum(val); | |
| 220 | std.debug.assert(@backingInt(val) > value); | |
| 221 | value = @backingInt(val); | |
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | comptime { |
| 225 | 225 | // sanity test |
| 226 | std.debug.assert(@intFromEnum(Enum.EPERM) == 1); | |
| 226 | std.debug.assert(@backingInt(Enum.EPERM) == 1); | |
| 227 | 227 | } |
| 228 | 228 | const list = blk: { |
| 229 | 229 | const values = std.enums.values(Enum); |
| 230 | const len = @intFromEnum(values[values.len - 1]) + 1; | |
| 230 | const len = @backingInt(values[values.len - 1]) + 1; | |
| 231 | 231 | var errors: [len]Error = @splat(error.Unexpected); |
| 232 | for (values) |f| errors[@intFromEnum(f)] = @field(Error, @tagName(f)); | |
| 232 | for (values) |f| errors[@backingInt(f)] = @field(Error, @tagName(f)); | |
| 233 | 233 | const final = errors; |
| 234 | 234 | break :blk final; |
| 235 | 235 | }; |
| ... | ... | @@ -280,7 +280,7 @@ pub const eai = struct { |
| 280 | 280 | }; |
| 281 | 281 | |
| 282 | 282 | pub fn fromInt(code: c_int) Error { |
| 283 | return switch (@as(Enum, @enumFromInt(code))) { | |
| 283 | return switch (@as(Enum, @fromBackingInt(@intCast(code)))) { | |
| 284 | 284 | .EAI_ADDRFAMILY => error.EAI_ADDRFAMILY, |
| 285 | 285 | .EAI_AGAIN => error.EAI_AGAIN, |
| 286 | 286 | .EAI_BADFLAGS => error.EAI_BADFLAGS, |
| ... | ... | @@ -368,6 +368,7 @@ pub const libc = struct { |
| 368 | 368 | pub extern fn accept4(socket: c_int, noalias address: ?*struct_sockaddr, noalias address_len: *socklen_t, flags: c_int) c_int; |
| 369 | 369 | pub extern fn shutdown(socket: c_int, how: c_int) c_int; |
| 370 | 370 | pub extern fn unlinkat(fd: c_int, name: [*:0]const u8, flag: c_int) c_int; |
| 371 | pub extern fn lseek(fd: c_int, offset: off_t, whence: c_int) off_t; | |
| 371 | 372 | }; |
| 372 | 373 | |
| 373 | 374 | pub const pid_t = i32; |
| ... | ... | @@ -420,9 +421,7 @@ pub const struct_timeval = extern struct { sec: time_t, usec: suseconds_t }; |
| 420 | 421 | pub const suseconds_t = c_int; |
| 421 | 422 | pub const useconds_t = c_uint; |
| 422 | 423 | |
| 423 | const impdef = @cImport({ | |
| 424 | @cInclude("pthread.h"); | |
| 425 | }); | |
| 424 | const impdef = @import("c"); | |
| 426 | 425 | pub const pthread_t = impdef.pthread_t; |
| 427 | 426 | pub const pthread_attr_t = impdef.pthread_attr_t; |
| 428 | 427 | pub const pthread_mutexattr_t = impdef.pthread_mutexattr_t; |
| ... | ... | @@ -816,6 +815,48 @@ pub const PROT = struct { |
| 816 | 815 | pub const EXEC = 0x04; |
| 817 | 816 | }; |
| 818 | 817 | |
| 818 | pub const IPV6 = struct { | |
| 819 | pub const SOCKOPT_RESERVED1 = 3; | |
| 820 | pub const UNICAST_HOPS = 4; | |
| 821 | pub const MULTICAST_IF = 9; | |
| 822 | pub const MULTICAST_HOPS = 10; | |
| 823 | pub const MULTICAST_LOOP = 11; | |
| 824 | pub const JOIN_GROUP = 12; | |
| 825 | pub const LEAVE_GROUP = 13; | |
| 826 | pub const PORTRANGE = 14; | |
| 827 | pub const PORTALGO = 17; | |
| 828 | pub const CHECKSUM = 26; | |
| 829 | pub const V6ONLY = 27; | |
| 830 | pub const IPSEC_POLICY = 28; | |
| 831 | pub const FAITH = 29; | |
| 832 | pub const RTHDRDSTOPTS = 35; | |
| 833 | pub const RECVPKTINFO = 36; | |
| 834 | pub const RECVHOPLIMIT = 37; | |
| 835 | pub const RECVRTHDR = 38; | |
| 836 | pub const RECVHOPOPTS = 39; | |
| 837 | pub const RECVDSTOPTS = 40; | |
| 838 | pub const USE_MIN_MTU = 42; | |
| 839 | pub const RECVPATHMTU = 43; | |
| 840 | pub const PATHMTU = 44; | |
| 841 | pub const PKTINFO = 46; | |
| 842 | pub const HOPLIMIT = 47; | |
| 843 | pub const NEXTHOP = 48; | |
| 844 | pub const HOPOPTS = 49; | |
| 845 | pub const DSTOPTS = 50; | |
| 846 | pub const RTHDR = 51; | |
| 847 | pub const RECVTCLASS = 57; | |
| 848 | pub const TCLASS = 61; | |
| 849 | pub const DONTFRAG = 62; | |
| 850 | pub const PREFER_TEMPADDR = 63; | |
| 851 | pub const BINDANY = 64; | |
| 852 | }; | |
| 853 | ||
| 854 | pub const SEEK = struct { | |
| 855 | pub const SET = 0; | |
| 856 | pub const CUR = 1; | |
| 857 | pub const END = 2; | |
| 858 | }; | |
| 859 | ||
| 819 | 860 | pub fn pipe2(flag: c_int) ![2]c_int { |
| 820 | 861 | var fildes: [2]c_int = @splat(-1); |
| 821 | 862 | const rc = libc.pipe2(&fildes, flag); |
| ... | ... | @@ -920,7 +961,7 @@ pub fn freeaddrinfo(ai: *const struct_addrinfo) void { |
| 920 | 961 | return libc.freeaddrinfo(ai); |
| 921 | 962 | } |
| 922 | 963 | pub fn socket(domain: AF, ty: c_int, protocol: c_int) errno.Error!c_uint { |
| 923 | const rc = libc.socket(@intFromEnum(domain), ty, protocol); | |
| 964 | const rc = libc.socket(@backingInt(domain), ty, protocol); | |
| 924 | 965 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 925 | 966 | std.debug.assert(rc > 0); |
| 926 | 967 | return @intCast(rc); |
| ... | ... | @@ -938,7 +979,7 @@ pub fn getrandom(buf: []u8, flags: c_uint) ![]u8 { |
| 938 | 979 | } |
| 939 | 980 | pub fn clock_gettime(clock_id: CLOCK) !struct_timespec { |
| 940 | 981 | var tp: struct_timespec = undefined; |
| 941 | const rc = libc.clock_gettime(@intFromEnum(clock_id), &tp); | |
| 982 | const rc = libc.clock_gettime(@backingInt(clock_id), &tp); | |
| 942 | 983 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 943 | 984 | std.debug.assert(rc == 0); |
| 944 | 985 | return tp; |
| ... | ... | @@ -1034,7 +1075,7 @@ pub fn accept4(socketfd: c_uint, noalias address: ?*struct_sockaddr, noalias add |
| 1034 | 1075 | return @intCast(rc); |
| 1035 | 1076 | } |
| 1036 | 1077 | pub fn shutdown(socketfd: c_uint, how: SHUT) errno.Error!void { |
| 1037 | const rc = libc.shutdown(@intCast(socketfd), @intFromEnum(how)); | |
| 1078 | const rc = libc.shutdown(@intCast(socketfd), @backingInt(how)); | |
| 1038 | 1079 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 1039 | 1080 | std.debug.assert(rc == 0); |
| 1040 | 1081 | } |
| ... | ... | @@ -1043,3 +1084,8 @@ pub fn unlinkat(fd: c_int, name: [*:0]const u8, flag: c_int) !void { |
| 1043 | 1084 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 1044 | 1085 | std.debug.assert(rc == 0); |
| 1045 | 1086 | } |
| 1087 | pub fn lseek(fd: c_int, offset: off_t, whence: c_int) !void { | |
| 1088 | const rc = libc.lseek(fd, offset, whence); | |
| 1089 | if (rc == -1) return errno.fromInt(errno.fromLibC()); | |
| 1090 | std.debug.assert(rc >= 0); | |
| 1091 | } |
openbsd.zig+10-12| ... | ... | @@ -211,19 +211,19 @@ pub const errno = struct { |
| 211 | 211 | // assert Enum is sequential |
| 212 | 212 | var value: c_ushort = 0; // SUCCESS |
| 213 | 213 | for (std.enums.values(Enum)) |val| { |
| 214 | std.debug.assert(@intFromEnum(val) > value); | |
| 215 | value = @intFromEnum(val); | |
| 214 | std.debug.assert(@backingInt(val) > value); | |
| 215 | value = @backingInt(val); | |
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | comptime { |
| 219 | 219 | // sanity test |
| 220 | std.debug.assert(@intFromEnum(Enum.EPERM) == 1); | |
| 220 | std.debug.assert(@backingInt(Enum.EPERM) == 1); | |
| 221 | 221 | } |
| 222 | 222 | const list = blk: { |
| 223 | 223 | const values = std.enums.values(Enum); |
| 224 | const len = @intFromEnum(values[values.len - 1]) + 1; | |
| 224 | const len = @backingInt(values[values.len - 1]) + 1; | |
| 225 | 225 | var errors: [len]Error = @splat(error.Unexpected); |
| 226 | for (values) |f| errors[@intFromEnum(f)] = @field(Error, @tagName(f)); | |
| 226 | for (values) |f| errors[@backingInt(f)] = @field(Error, @tagName(f)); | |
| 227 | 227 | const final = errors; |
| 228 | 228 | break :blk final; |
| 229 | 229 | }; |
| ... | ... | @@ -274,7 +274,7 @@ pub const eai = struct { |
| 274 | 274 | }; |
| 275 | 275 | |
| 276 | 276 | pub fn fromInt(code: c_int) Error { |
| 277 | return switch (@as(Enum, @enumFromInt(code))) { | |
| 277 | return switch (@as(Enum, @fromBackingInt(@intCast(code)))) { | |
| 278 | 278 | .EAI_BADFLAGS => error.EAI_BADFLAGS, |
| 279 | 279 | .EAI_NONAME => error.EAI_NONAME, |
| 280 | 280 | .EAI_AGAIN => error.EAI_AGAIN, |
| ... | ... | @@ -412,9 +412,7 @@ pub const struct_addrinfo = extern struct { flags: c_int, family: c_int, socktyp |
| 412 | 412 | pub const struct_dirent = extern struct { fileno: ino_t, off: off_t, reclen: u16, type: DT, namlen: u8, padding: [4]u8, name: [NAME_MAX + 1]u8 }; |
| 413 | 413 | pub const struct_timeval = extern struct { sec: time_t, usec: suseconds_t }; |
| 414 | 414 | |
| 415 | const impdef = @cImport({ | |
| 416 | @cInclude("pthread.h"); | |
| 417 | }); | |
| 415 | const impdef = @import("c"); | |
| 418 | 416 | pub const pthread_t = impdef.pthread_t; |
| 419 | 417 | pub const pthread_attr_t = impdef.pthread_attr_t; |
| 420 | 418 | pub const pthread_mutexattr_t = impdef.pthread_mutexattr_t; |
| ... | ... | @@ -931,7 +929,7 @@ pub fn freeaddrinfo(ai: *const struct_addrinfo) void { |
| 931 | 929 | return libc.freeaddrinfo(ai); |
| 932 | 930 | } |
| 933 | 931 | pub fn socket(domain: AF, ty: c_int, protocol: c_int) errno.Error!c_uint { |
| 934 | const rc = libc.socket(@intFromEnum(domain), ty, protocol); | |
| 932 | const rc = libc.socket(@backingInt(domain), ty, protocol); | |
| 935 | 933 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 936 | 934 | std.debug.assert(rc > 0); |
| 937 | 935 | return @intCast(rc); |
| ... | ... | @@ -943,7 +941,7 @@ pub fn connect(socketfd: c_uint, address: *const struct_sockaddr, address_len: s |
| 943 | 941 | } |
| 944 | 942 | pub fn clock_gettime(clock_id: CLOCK) !struct_timespec { |
| 945 | 943 | var tp: struct_timespec = undefined; |
| 946 | const rc = libc.clock_gettime(@intFromEnum(clock_id), &tp); | |
| 944 | const rc = libc.clock_gettime(@backingInt(clock_id), &tp); | |
| 947 | 945 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 948 | 946 | std.debug.assert(rc == 0); |
| 949 | 947 | return tp; |
| ... | ... | @@ -1039,7 +1037,7 @@ pub fn accept4(socketfd: c_uint, noalias address: ?*struct_sockaddr, noalias add |
| 1039 | 1037 | return @intCast(rc); |
| 1040 | 1038 | } |
| 1041 | 1039 | pub fn shutdown(socketfd: c_uint, how: SHUT) errno.Error!void { |
| 1042 | const rc = libc.shutdown(@intCast(socketfd), @intFromEnum(how)); | |
| 1040 | const rc = libc.shutdown(@intCast(socketfd), @backingInt(how)); | |
| 1043 | 1041 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 1044 | 1042 | std.debug.assert(rc == 0); |
| 1045 | 1043 | } |