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