| ... | ... | @@ -264,17 +264,32 @@ pub const SIGUSR1 = 30; |
| 264 | 264 | /// user defined signal 2 |
| 265 | 265 | pub const SIGUSR2 = 31; |
| 266 | 266 | |
| 267 | | pub const KEVENT_FLAG_NONE = 0x000; /// no flag value |
| 268 | | pub const KEVENT_FLAG_IMMEDIATE = 0x001; /// immediate timeout |
| 269 | | pub const KEVENT_FLAG_ERROR_EVENTS = 0x002; /// output events only include change |
| 267 | /// no flag value |
| 268 | pub const KEVENT_FLAG_NONE = 0x000; |
| 270 | 269 | |
| 271 | | pub const EV_ADD = 0x0001; /// add event to kq (implies enable) |
| 272 | | pub const EV_DELETE = 0x0002; /// delete event from kq |
| 273 | | pub const EV_ENABLE = 0x0004; /// enable event |
| 274 | | pub const EV_DISABLE = 0x0008; /// disable event (not reported) |
| 270 | /// immediate timeout |
| 271 | pub const KEVENT_FLAG_IMMEDIATE = 0x001; |
| 275 | 272 | |
| 276 | | pub const EV_ONESHOT = 0x0010; /// only report one occurrence |
| 277 | | pub const EV_CLEAR = 0x0020; /// clear event state after reporting |
| 273 | /// output events only include change |
| 274 | pub const KEVENT_FLAG_ERROR_EVENTS = 0x002; |
| 275 | |
| 276 | /// add event to kq (implies enable) |
| 277 | pub const EV_ADD = 0x0001; |
| 278 | |
| 279 | /// delete event from kq |
| 280 | pub const EV_DELETE = 0x0002; |
| 281 | |
| 282 | /// enable event |
| 283 | pub const EV_ENABLE = 0x0004; |
| 284 | |
| 285 | /// disable event (not reported) |
| 286 | pub const EV_DISABLE = 0x0008; |
| 287 | |
| 288 | /// only report one occurrence |
| 289 | pub const EV_ONESHOT = 0x0010; |
| 290 | |
| 291 | /// clear event state after reporting |
| 292 | pub const EV_CLEAR = 0x0020; |
| 278 | 293 | |
| 279 | 294 | /// force immediate event output |
| 280 | 295 | /// ... with or without EV_ERROR |
| ... | ... | @@ -282,8 +297,11 @@ pub const EV_CLEAR = 0x0020; /// clear event state after reporting |
| 282 | 297 | /// on syscalls supporting flags |
| 283 | 298 | pub const EV_RECEIPT = 0x0040; |
| 284 | 299 | |
| 285 | | pub const EV_DISPATCH = 0x0080; /// disable event after reporting |
| 286 | | pub const EV_UDATA_SPECIFIC = 0x0100; /// unique kevent per udata value |
| 300 | /// disable event after reporting |
| 301 | pub const EV_DISPATCH = 0x0080; |
| 302 | |
| 303 | /// unique kevent per udata value |
| 304 | pub const EV_UDATA_SPECIFIC = 0x0100; |
| 287 | 305 | |
| 288 | 306 | /// ... in combination with EV_DELETE |
| 289 | 307 | /// will defer delete until udata-specific |
| ... | ... | @@ -291,91 +309,178 @@ pub const EV_UDATA_SPECIFIC = 0x0100; /// unique kevent per udata value |
| 291 | 309 | /// returned to indicate the deferral |
| 292 | 310 | pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC; |
| 293 | 311 | |
| 294 | | /// report that source has vanished |
| 312 | /// report that source has vanished |
| 295 | 313 | /// ... only valid with EV_DISPATCH2 |
| 296 | 314 | pub const EV_VANISHED = 0x0200; |
| 297 | 315 | |
| 298 | | pub const EV_SYSFLAGS = 0xF000; /// reserved by system |
| 299 | | pub const EV_FLAG0 = 0x1000; /// filter-specific flag |
| 300 | | pub const EV_FLAG1 = 0x2000; /// filter-specific flag |
| 301 | | pub const EV_EOF = 0x8000; /// EOF detected |
| 302 | | pub const EV_ERROR = 0x4000; /// error, data contains errno |
| 316 | /// reserved by system |
| 317 | pub const EV_SYSFLAGS = 0xF000; |
| 318 | |
| 319 | /// filter-specific flag |
| 320 | pub const EV_FLAG0 = 0x1000; |
| 321 | |
| 322 | /// filter-specific flag |
| 323 | pub const EV_FLAG1 = 0x2000; |
| 324 | |
| 325 | /// EOF detected |
| 326 | pub const EV_EOF = 0x8000; |
| 327 | |
| 328 | /// error, data contains errno |
| 329 | pub const EV_ERROR = 0x4000; |
| 303 | 330 | |
| 304 | 331 | pub const EV_POLL = EV_FLAG0; |
| 305 | 332 | pub const EV_OOBAND = EV_FLAG1; |
| 306 | 333 | |
| 307 | 334 | pub const EVFILT_READ = -1; |
| 308 | 335 | pub const EVFILT_WRITE = -2; |
| 309 | | pub const EVFILT_AIO = -3; /// attached to aio requests |
| 310 | | pub const EVFILT_VNODE = -4; /// attached to vnodes |
| 311 | | pub const EVFILT_PROC = -5; /// attached to struct proc |
| 312 | | pub const EVFILT_SIGNAL = -6; /// attached to struct proc |
| 313 | | pub const EVFILT_TIMER = -7; /// timers |
| 314 | | pub const EVFILT_MACHPORT = -8; /// Mach portsets |
| 315 | | pub const EVFILT_FS = -9; /// Filesystem events |
| 316 | | pub const EVFILT_USER = -10; /// User events |
| 317 | | pub const EVFILT_VM = -12; /// Virtual memory events |
| 318 | | |
| 319 | | pub const EVFILT_EXCEPT = -15; /// Exception events |
| 336 | |
| 337 | /// attached to aio requests |
| 338 | pub const EVFILT_AIO = -3; |
| 339 | |
| 340 | /// attached to vnodes |
| 341 | pub const EVFILT_VNODE = -4; |
| 342 | |
| 343 | /// attached to struct proc |
| 344 | pub const EVFILT_PROC = -5; |
| 345 | |
| 346 | /// attached to struct proc |
| 347 | pub const EVFILT_SIGNAL = -6; |
| 348 | |
| 349 | /// timers |
| 350 | pub const EVFILT_TIMER = -7; |
| 351 | |
| 352 | /// Mach portsets |
| 353 | pub const EVFILT_MACHPORT = -8; |
| 354 | |
| 355 | /// Filesystem events |
| 356 | pub const EVFILT_FS = -9; |
| 357 | |
| 358 | /// User events |
| 359 | pub const EVFILT_USER = -10; |
| 360 | |
| 361 | /// Virtual memory events |
| 362 | pub const EVFILT_VM = -12; |
| 363 | |
| 364 | /// Exception events |
| 365 | pub const EVFILT_EXCEPT = -15; |
| 320 | 366 | |
| 321 | 367 | pub const EVFILT_SYSCOUNT = 17; |
| 322 | 368 | |
| 323 | 369 | /// On input, NOTE_TRIGGER causes the event to be triggered for output. |
| 324 | 370 | pub const NOTE_TRIGGER = 0x01000000; |
| 325 | 371 | |
| 326 | | pub const NOTE_FFNOP = 0x00000000; /// ignore input fflags |
| 327 | | pub const NOTE_FFAND = 0x40000000; /// and fflags |
| 328 | | pub const NOTE_FFOR = 0x80000000; /// or fflags |
| 329 | | pub const NOTE_FFCOPY = 0xc0000000; /// copy fflags |
| 330 | | pub const NOTE_FFCTRLMASK = 0xc0000000; /// mask for operations |
| 372 | /// ignore input fflags |
| 373 | pub const NOTE_FFNOP = 0x00000000; |
| 374 | |
| 375 | /// and fflags |
| 376 | pub const NOTE_FFAND = 0x40000000; |
| 377 | |
| 378 | /// or fflags |
| 379 | pub const NOTE_FFOR = 0x80000000; |
| 380 | |
| 381 | /// copy fflags |
| 382 | pub const NOTE_FFCOPY = 0xc0000000; |
| 383 | |
| 384 | /// mask for operations |
| 385 | pub const NOTE_FFCTRLMASK = 0xc0000000; |
| 331 | 386 | pub const NOTE_FFLAGSMASK = 0x00ffffff; |
| 332 | 387 | |
| 333 | | pub const NOTE_LOWAT = 0x00000001; /// low water mark |
| 388 | /// low water mark |
| 389 | pub const NOTE_LOWAT = 0x00000001; |
| 390 | |
| 391 | /// OOB data |
| 392 | pub const NOTE_OOB = 0x00000002; |
| 393 | |
| 394 | /// vnode was removed |
| 395 | pub const NOTE_DELETE = 0x00000001; |
| 396 | |
| 397 | /// data contents changed |
| 398 | pub const NOTE_WRITE = 0x00000002; |
| 399 | |
| 400 | /// size increased |
| 401 | pub const NOTE_EXTEND = 0x00000004; |
| 402 | |
| 403 | /// attributes changed |
| 404 | pub const NOTE_ATTRIB = 0x00000008; |
| 405 | |
| 406 | /// link count changed |
| 407 | pub const NOTE_LINK = 0x00000010; |
| 408 | |
| 409 | /// vnode was renamed |
| 410 | pub const NOTE_RENAME = 0x00000020; |
| 411 | |
| 412 | /// vnode access was revoked |
| 413 | pub const NOTE_REVOKE = 0x00000040; |
| 414 | |
| 415 | /// No specific vnode event: to test for EVFILT_READ activation |
| 416 | pub const NOTE_NONE = 0x00000080; |
| 417 | |
| 418 | /// vnode was unlocked by flock(2) |
| 419 | pub const NOTE_FUNLOCK = 0x00000100; |
| 420 | |
| 421 | /// process exited |
| 422 | pub const NOTE_EXIT = 0x80000000; |
| 334 | 423 | |
| 335 | | pub const NOTE_OOB = 0x00000002; /// OOB data |
| 424 | /// process forked |
| 425 | pub const NOTE_FORK = 0x40000000; |
| 336 | 426 | |
| 337 | | pub const NOTE_DELETE = 0x00000001; /// vnode was removed |
| 338 | | pub const NOTE_WRITE = 0x00000002; /// data contents changed |
| 339 | | pub const NOTE_EXTEND = 0x00000004; /// size increased |
| 340 | | pub const NOTE_ATTRIB = 0x00000008; /// attributes changed |
| 341 | | pub const NOTE_LINK = 0x00000010; /// link count changed |
| 342 | | pub const NOTE_RENAME = 0x00000020; /// vnode was renamed |
| 343 | | pub const NOTE_REVOKE = 0x00000040; /// vnode access was revoked |
| 344 | | pub const NOTE_NONE = 0x00000080; /// No specific vnode event: to test for EVFILT_READ activation |
| 345 | | pub const NOTE_FUNLOCK = 0x00000100; /// vnode was unlocked by flock(2) |
| 427 | /// process exec'd |
| 428 | pub const NOTE_EXEC = 0x20000000; |
| 346 | 429 | |
| 347 | | pub const NOTE_EXIT = 0x80000000; /// process exited |
| 348 | | pub const NOTE_FORK = 0x40000000; /// process forked |
| 349 | | pub const NOTE_EXEC = 0x20000000; /// process exec'd |
| 350 | | pub const NOTE_SIGNAL = 0x08000000; /// shared with EVFILT_SIGNAL |
| 351 | | pub const NOTE_EXITSTATUS = 0x04000000; /// exit status to be returned, valid for child process only |
| 352 | | pub const NOTE_EXIT_DETAIL = 0x02000000; /// provide details on reasons for exit |
| 430 | /// shared with EVFILT_SIGNAL |
| 431 | pub const NOTE_SIGNAL = 0x08000000; |
| 353 | 432 | |
| 354 | | pub const NOTE_PDATAMASK = 0x000fffff; /// mask for signal & exit status |
| 355 | | pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK); |
| 433 | /// exit status to be returned, valid for child process only |
| 434 | pub const NOTE_EXITSTATUS = 0x04000000; |
| 356 | 435 | |
| 357 | | pub const NOTE_EXIT_DETAIL_MASK = 0x00070000; |
| 358 | | pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000; |
| 359 | | pub const NOTE_EXIT_MEMORY = 0x00020000; |
| 360 | | pub const NOTE_EXIT_CSERROR = 0x00040000; |
| 436 | /// provide details on reasons for exit |
| 437 | pub const NOTE_EXIT_DETAIL = 0x02000000; |
| 361 | 438 | |
| 439 | /// mask for signal & exit status |
| 440 | pub const NOTE_PDATAMASK = 0x000fffff; |
| 441 | pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK); |
| 362 | 442 | |
| 363 | | pub const NOTE_VM_PRESSURE = 0x80000000; /// will react on memory pressure |
| 364 | | pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000; /// will quit on memory pressure, possibly after cleaning up dirty state |
| 365 | | pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000; /// will quit immediately on memory pressure |
| 366 | | pub const NOTE_VM_ERROR = 0x10000000; /// there was an error |
| 443 | pub const NOTE_EXIT_DETAIL_MASK = 0x00070000; |
| 444 | pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000; |
| 445 | pub const NOTE_EXIT_MEMORY = 0x00020000; |
| 446 | pub const NOTE_EXIT_CSERROR = 0x00040000; |
| 367 | 447 | |
| 368 | | pub const NOTE_SECONDS = 0x00000001; /// data is seconds |
| 369 | | pub const NOTE_USECONDS = 0x00000002; /// data is microseconds |
| 370 | | pub const NOTE_NSECONDS = 0x00000004; /// data is nanoseconds |
| 371 | | pub const NOTE_ABSOLUTE = 0x00000008; /// absolute timeout |
| 448 | /// will react on memory pressure |
| 449 | pub const NOTE_VM_PRESSURE = 0x80000000; |
| 372 | 450 | |
| 373 | | pub const NOTE_LEEWAY = 0x00000010; /// ext[1] holds leeway for power aware timers |
| 374 | | pub const NOTE_CRITICAL = 0x00000020; /// system does minimal timer coalescing |
| 375 | | pub const NOTE_BACKGROUND = 0x00000040; /// system does maximum timer coalescing |
| 376 | | pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080; |
| 377 | | pub const NOTE_MACHTIME = 0x00000100; /// data is mach absolute time units |
| 451 | /// will quit on memory pressure, possibly after cleaning up dirty state |
| 452 | pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000; |
| 378 | 453 | |
| 454 | /// will quit immediately on memory pressure |
| 455 | pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000; |
| 456 | |
| 457 | /// there was an error |
| 458 | pub const NOTE_VM_ERROR = 0x10000000; |
| 459 | |
| 460 | /// data is seconds |
| 461 | pub const NOTE_SECONDS = 0x00000001; |
| 462 | |
| 463 | /// data is microseconds |
| 464 | pub const NOTE_USECONDS = 0x00000002; |
| 465 | |
| 466 | /// data is nanoseconds |
| 467 | pub const NOTE_NSECONDS = 0x00000004; |
| 468 | |
| 469 | /// absolute timeout |
| 470 | pub const NOTE_ABSOLUTE = 0x00000008; |
| 471 | |
| 472 | /// ext[1] holds leeway for power aware timers |
| 473 | pub const NOTE_LEEWAY = 0x00000010; |
| 474 | |
| 475 | /// system does minimal timer coalescing |
| 476 | pub const NOTE_CRITICAL = 0x00000020; |
| 477 | |
| 478 | /// system does maximum timer coalescing |
| 479 | pub const NOTE_BACKGROUND = 0x00000040; |
| 480 | pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080; |
| 481 | |
| 482 | /// data is mach absolute time units |
| 483 | pub const NOTE_MACHTIME = 0x00000100; |
| 379 | 484 | |
| 380 | 485 | fn wstatus(x: i32) i32 { |
| 381 | 486 | return x & 0o177; |
| ... | ... | @@ -503,12 +608,23 @@ pub fn kqueue() usize { |
| 503 | 608 | } |
| 504 | 609 | |
| 505 | 610 | pub fn kevent(kq: i32, changelist: []const Kevent, eventlist: []Kevent, timeout: ?*const timespec) usize { |
| 506 | | return errnoWrap(c.kevent(kq, changelist.ptr, @intCast(c_int, changelist.len), eventlist.ptr, @intCast(c_int, eventlist.len), timeout,)); |
| 507 | | } |
| 508 | | |
| 509 | | pub fn kevent64(kq: i32, changelist: []const kevent64_s, eventlist: []kevent64_s, flags: u32, |
| 510 | | timeout: ?*const timespec) usize |
| 511 | | { |
| 611 | return errnoWrap(c.kevent( |
| 612 | kq, |
| 613 | changelist.ptr, |
| 614 | @intCast(c_int, changelist.len), |
| 615 | eventlist.ptr, |
| 616 | @intCast(c_int, eventlist.len), |
| 617 | timeout, |
| 618 | )); |
| 619 | } |
| 620 | |
| 621 | pub fn kevent64( |
| 622 | kq: i32, |
| 623 | changelist: []const kevent64_s, |
| 624 | eventlist: []kevent64_s, |
| 625 | flags: u32, |
| 626 | timeout: ?*const timespec, |
| 627 | ) usize { |
| 512 | 628 | return errnoWrap(c.kevent64(kq, changelist.ptr, changelist.len, eventlist.ptr, eventlist.len, flags, timeout)); |
| 513 | 629 | } |
| 514 | 630 | |