| ... | @@ -54,8 +54,7 @@ pub const pthread_rwlock_t = extern struct { | ... | @@ -54,8 +54,7 @@ pub const pthread_rwlock_t = extern struct { |
| 54 | }; | 54 | }; |
| 55 | | 55 | |
| 56 | pub const pthread_attr_t = extern struct { | 56 | pub const pthread_attr_t = extern struct { |
| 57 | __size: [56]u8, | 57 | inner: ?*anyopaque = null, |
| 58 | __align: c_long, | | |
| 59 | }; | 58 | }; |
| 60 | | 59 | |
| 61 | pub const sem_t = extern struct { | 60 | pub const sem_t = extern struct { |
| ... | @@ -181,6 +180,7 @@ pub const AI = struct { | ... | @@ -181,6 +180,7 @@ pub const AI = struct { |
| 181 | pub const blksize_t = i32; | 180 | pub const blksize_t = i32; |
| 182 | pub const blkcnt_t = i64; | 181 | pub const blkcnt_t = i64; |
| 183 | pub const clockid_t = i32; | 182 | pub const clockid_t = i32; |
| | 183 | pub const fflags_t = u32; |
| 184 | pub const fsblkcnt_t = u64; | 184 | pub const fsblkcnt_t = u64; |
| 185 | pub const fsfilcnt_t = u64; | 185 | pub const fsfilcnt_t = u64; |
| 186 | pub const nlink_t = u64; | 186 | pub const nlink_t = u64; |
| ... | @@ -201,13 +201,20 @@ pub const suseconds_t = c_long; | ... | @@ -201,13 +201,20 @@ pub const suseconds_t = c_long; |
| 201 | | 201 | |
| 202 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | 202 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. |
| 203 | pub const Kevent = extern struct { | 203 | pub const Kevent = extern struct { |
| | 204 | /// Identifier for this event. |
| 204 | ident: usize, | 205 | ident: usize, |
| | 206 | /// Filter for event. |
| 205 | filter: i16, | 207 | filter: i16, |
| | 208 | /// Action flags for kqueue. |
| 206 | flags: u16, | 209 | flags: u16, |
| | 210 | /// Filter flag value. |
| 207 | fflags: u32, | 211 | fflags: u32, |
| | 212 | /// Filter data value. |
| 208 | data: i64, | 213 | data: i64, |
| | 214 | /// Opaque user data identifier. |
| 209 | udata: usize, | 215 | udata: usize, |
| 210 | // TODO ext | 216 | /// Future extensions. |
| | 217 | _ext: [4]u64 = [_]u64{0} ** 4, |
| 211 | }; | 218 | }; |
| 212 | | 219 | |
| 213 | // Modes and flags for dlopen() | 220 | // Modes and flags for dlopen() |
| ... | @@ -230,90 +237,108 @@ pub const RTLD = struct { | ... | @@ -230,90 +237,108 @@ pub const RTLD = struct { |
| 230 | /// Do not load if not already loaded. | 237 | /// Do not load if not already loaded. |
| 231 | pub const NOLOAD = 0x02000; | 238 | pub const NOLOAD = 0x02000; |
| 232 | }; | 239 | }; |
| | 240 | |
| 233 | pub const dl_phdr_info = extern struct { | 241 | pub const dl_phdr_info = extern struct { |
| 234 | dlpi_addr: usize, | 242 | /// Module relocation base. |
| | 243 | dlpi_addr: if (builtin.cpu.arch.ptrBitWidth() == 32) std.elf.Elf32_Addr else std.elf.Elf64_Addr, |
| | 244 | /// Module name. |
| 235 | dlpi_name: ?[*:0]const u8, | 245 | dlpi_name: ?[*:0]const u8, |
| | 246 | /// Pointer to module's phdr. |
| 236 | dlpi_phdr: [*]std.elf.Phdr, | 247 | dlpi_phdr: [*]std.elf.Phdr, |
| | 248 | /// Number of entries in phdr. |
| 237 | dlpi_phnum: u16, | 249 | dlpi_phnum: u16, |
| | 250 | /// Total number of loads. |
| | 251 | dlpi_adds: u64, |
| | 252 | /// Total number of unloads. |
| | 253 | dlpi_subs: u64, |
| | 254 | dlpi_tls_modid: usize, |
| | 255 | dlpi_tls_data: ?*anyopaque, |
| 238 | }; | 256 | }; |
| 239 | | 257 | |
| 240 | pub const Flock = extern struct { | 258 | pub const Flock = extern struct { |
| | 259 | /// Starting offset. |
| 241 | start: off_t, | 260 | start: off_t, |
| | 261 | /// Number of consecutive bytes to be locked. |
| | 262 | /// A value of 0 means to the end of the file. |
| 242 | len: off_t, | 263 | len: off_t, |
| | 264 | /// Lock owner. |
| 243 | pid: pid_t, | 265 | pid: pid_t, |
| 244 | type: i16, | 266 | /// Lock type. |
| | 267 | @"type": i16, |
| | 268 | /// Type of the start member. |
| 245 | whence: i16, | 269 | whence: i16, |
| | 270 | /// Remote system id or zero for local. |
| 246 | sysid: i32, | 271 | sysid: i32, |
| 247 | __unused: [4]u8, | | |
| 248 | }; | 272 | }; |
| 249 | | 273 | |
| 250 | pub const msghdr = extern struct { | 274 | pub const msghdr = extern struct { |
| 251 | /// optional address | 275 | /// Optional address. |
| 252 | msg_name: ?*sockaddr, | 276 | msg_name: ?*sockaddr, |
| 253 | | 277 | /// Size of address. |
| 254 | /// size of address | | |
| 255 | msg_namelen: socklen_t, | 278 | msg_namelen: socklen_t, |
| 256 | | 279 | /// Scatter/gather array. |
| 257 | /// scatter/gather array | | |
| 258 | msg_iov: [*]iovec, | 280 | msg_iov: [*]iovec, |
| 259 | | 281 | /// Number of elements in msg_iov. |
| 260 | /// # elements in msg_iov | | |
| 261 | msg_iovlen: i32, | 282 | msg_iovlen: i32, |
| 262 | | 283 | /// Ancillary data. |
| 263 | /// ancillary data | | |
| 264 | msg_control: ?*anyopaque, | 284 | msg_control: ?*anyopaque, |
| 265 | | 285 | /// Ancillary data buffer length. |
| 266 | /// ancillary data buffer len | | |
| 267 | msg_controllen: socklen_t, | 286 | msg_controllen: socklen_t, |
| 268 | | 287 | /// Flags on received message. |
| 269 | /// flags on received message | | |
| 270 | msg_flags: i32, | 288 | msg_flags: i32, |
| 271 | }; | 289 | }; |
| 272 | | 290 | |
| 273 | pub const msghdr_const = extern struct { | 291 | pub const msghdr_const = extern struct { |
| 274 | /// optional address | 292 | /// Optional address. |
| 275 | msg_name: ?*const sockaddr, | 293 | msg_name: ?*const sockaddr, |
| 276 | | 294 | /// Size of address. |
| 277 | /// size of address | | |
| 278 | msg_namelen: socklen_t, | 295 | msg_namelen: socklen_t, |
| 279 | | 296 | /// Scatter/gather array. |
| 280 | /// scatter/gather array | | |
| 281 | msg_iov: [*]iovec_const, | 297 | msg_iov: [*]iovec_const, |
| 282 | | 298 | /// Number of elements in msg_iov. |
| 283 | /// # elements in msg_iov | | |
| 284 | msg_iovlen: i32, | 299 | msg_iovlen: i32, |
| 285 | | 300 | /// Ancillary data. |
| 286 | /// ancillary data | | |
| 287 | msg_control: ?*anyopaque, | 301 | msg_control: ?*anyopaque, |
| 288 | | 302 | /// Ancillary data buffer length. |
| 289 | /// ancillary data buffer len | | |
| 290 | msg_controllen: socklen_t, | 303 | msg_controllen: socklen_t, |
| 291 | | 304 | /// Flags on received message. |
| 292 | /// flags on received message | | |
| 293 | msg_flags: i32, | 305 | msg_flags: i32, |
| 294 | }; | 306 | }; |
| 295 | | 307 | |
| 296 | pub const Stat = extern struct { | 308 | pub const Stat = extern struct { |
| | 309 | /// The inode's device. |
| 297 | dev: dev_t, | 310 | dev: dev_t, |
| | 311 | /// The inode's number. |
| 298 | ino: ino_t, | 312 | ino: ino_t, |
| | 313 | /// Number of hard links. |
| 299 | nlink: nlink_t, | 314 | nlink: nlink_t, |
| 300 | | 315 | /// Inode protection mode. |
| 301 | mode: mode_t, | 316 | mode: mode_t, |
| 302 | __pad0: u16, | 317 | __pad0: i16, |
| | 318 | /// User ID of the file's owner. |
| 303 | uid: uid_t, | 319 | uid: uid_t, |
| | 320 | /// Group ID of the file's group. |
| 304 | gid: gid_t, | 321 | gid: gid_t, |
| 305 | __pad1: u32, | 322 | __pad1: i32, |
| | 323 | /// Device type. |
| 306 | rdev: dev_t, | 324 | rdev: dev_t, |
| 307 | | 325 | /// Time of last access. |
| 308 | atim: timespec, | 326 | atim: timespec, |
| | 327 | /// Time of last data modification. |
| 309 | mtim: timespec, | 328 | mtim: timespec, |
| | 329 | /// Time of last file status change. |
| 310 | ctim: timespec, | 330 | ctim: timespec, |
| | 331 | /// Time of file creation. |
| 311 | birthtim: timespec, | 332 | birthtim: timespec, |
| 312 | | 333 | /// File size, in bytes. |
| 313 | size: off_t, | 334 | size: off_t, |
| 314 | blocks: i64, | 335 | /// Blocks allocated for file. |
| 315 | blksize: isize, | 336 | blocks: blkcnt_t, |
| 316 | flags: u32, | 337 | /// Optimal blocksize for I/O. |
| | 338 | blksize: blksize_t, |
| | 339 | /// User defined flags for file. |
| | 340 | flags: fflags_t, |
| | 341 | /// File generation number. |
| 317 | gen: u64, | 342 | gen: u64, |
| 318 | __spare: [10]u64, | 343 | __spare: [10]u64, |
| 319 | | 344 | |
| ... | @@ -347,14 +372,20 @@ pub const timeval = extern struct { | ... | @@ -347,14 +372,20 @@ pub const timeval = extern struct { |
| 347 | }; | 372 | }; |
| 348 | | 373 | |
| 349 | pub const dirent = extern struct { | 374 | pub const dirent = extern struct { |
| 350 | d_fileno: usize, | 375 | /// File number of entry. |
| 351 | d_off: i64, | 376 | d_fileno: ino_t, |
| | 377 | /// Directory offset of entry. |
| | 378 | d_off: off_t, |
| | 379 | /// Length of this record. |
| 352 | d_reclen: u16, | 380 | d_reclen: u16, |
| | 381 | /// File type, one of DT_. |
| 353 | d_type: u8, | 382 | d_type: u8, |
| 354 | d_pad0: u8, | 383 | _d_pad0: u8, |
| | 384 | /// Length of the d_name member. |
| 355 | d_namlen: u16, | 385 | d_namlen: u16, |
| 356 | d_pad1: u16, | 386 | _d_pad1: u16, |
| 357 | d_name: [256]u8, | 387 | /// Name of entry. |
| | 388 | d_name: [255:0]u8, |
| 358 | | 389 | |
| 359 | pub fn reclen(self: dirent) u16 { | 390 | pub fn reclen(self: dirent) u16 { |
| 360 | return self.d_reclen; | 391 | return self.d_reclen; |
| ... | @@ -1192,16 +1223,30 @@ pub const Sigaction = extern struct { | ... | @@ -1192,16 +1223,30 @@ pub const Sigaction = extern struct { |
| 1192 | }; | 1223 | }; |
| 1193 | | 1224 | |
| 1194 | pub const siginfo_t = extern struct { | 1225 | pub const siginfo_t = extern struct { |
| | 1226 | // Signal number. |
| 1195 | signo: c_int, | 1227 | signo: c_int, |
| | 1228 | // Errno association. |
| 1196 | errno: c_int, | 1229 | errno: c_int, |
| | 1230 | /// Signal code. |
| | 1231 | /// |
| | 1232 | /// Cause of signal, one of the SI_ macros or signal-specific values, i.e. |
| | 1233 | /// one of the FPE_... values for SIGFPE. |
| | 1234 | /// This value is equivalent to the second argument to an old-style FreeBSD |
| | 1235 | /// signal handler. |
| 1197 | code: c_int, | 1236 | code: c_int, |
| | 1237 | /// Sending process. |
| 1198 | pid: pid_t, | 1238 | pid: pid_t, |
| | 1239 | /// Sender's ruid. |
| 1199 | uid: uid_t, | 1240 | uid: uid_t, |
| | 1241 | /// Exit value. |
| 1200 | status: c_int, | 1242 | status: c_int, |
| | 1243 | /// Faulting instruction. |
| 1201 | addr: ?*anyopaque, | 1244 | addr: ?*anyopaque, |
| | 1245 | /// Signal value. |
| 1202 | value: sigval, | 1246 | value: sigval, |
| 1203 | reason: extern union { | 1247 | reason: extern union { |
| 1204 | fault: extern struct { | 1248 | fault: extern struct { |
| | 1249 | /// Machine specific trap code. |
| 1205 | trapno: c_int, | 1250 | trapno: c_int, |
| 1206 | }, | 1251 | }, |
| 1207 | timer: extern struct { | 1252 | timer: extern struct { |
| ... | @@ -1212,6 +1257,7 @@ pub const siginfo_t = extern struct { | ... | @@ -1212,6 +1257,7 @@ pub const siginfo_t = extern struct { |
| 1212 | mqd: c_int, | 1257 | mqd: c_int, |
| 1213 | }, | 1258 | }, |
| 1214 | poll: extern struct { | 1259 | poll: extern struct { |
| | 1260 | /// Band event for SIGPOLL. UNUSED. |
| 1215 | band: c_long, | 1261 | band: c_long, |
| 1216 | }, | 1262 | }, |
| 1217 | spare: extern struct { | 1263 | spare: extern struct { |
| ... | @@ -1263,6 +1309,15 @@ pub usingnamespace switch (builtin.cpu.arch) { | ... | @@ -1263,6 +1309,15 @@ pub usingnamespace switch (builtin.cpu.arch) { |
| 1263 | rflags: u64, | 1309 | rflags: u64, |
| 1264 | rsp: u64, | 1310 | rsp: u64, |
| 1265 | ss: u64, | 1311 | ss: u64, |
| | 1312 | len: u64, |
| | 1313 | fpformat: u64, |
| | 1314 | ownedfp: u64, |
| | 1315 | fpstate: [64]u64 align(16), |
| | 1316 | fsbase: u64, |
| | 1317 | gsbase: u64, |
| | 1318 | xfpustate: u64, |
| | 1319 | xfpustate_len: u64, |
| | 1320 | spare: [4]u64, |
| 1266 | }; | 1321 | }; |
| 1267 | }, | 1322 | }, |
| 1268 | else => struct {}, | 1323 | else => struct {}, |
| ... | @@ -1408,8 +1463,11 @@ pub const SS_ONSTACK = 1; | ... | @@ -1408,8 +1463,11 @@ pub const SS_ONSTACK = 1; |
| 1408 | pub const SS_DISABLE = 4; | 1463 | pub const SS_DISABLE = 4; |
| 1409 | | 1464 | |
| 1410 | pub const stack_t = extern struct { | 1465 | pub const stack_t = extern struct { |
| 1411 | sp: [*]u8, | 1466 | /// Signal stack base. |
| 1412 | size: isize, | 1467 | sp: *anyopaque, |
| | 1468 | /// Signal stack length. |
| | 1469 | size: usize, |
| | 1470 | /// SS_DISABLE and/or SS_ONSTACK. |
| 1413 | flags: i32, | 1471 | flags: i32, |
| 1414 | }; | 1472 | }; |
| 1415 | | 1473 | |