| ... | @@ -279,20 +279,10 @@ pub const PROT_READ = 1; | ... | @@ -279,20 +279,10 @@ pub const PROT_READ = 1; |
| 279 | pub const PROT_WRITE = 2; | 279 | pub const PROT_WRITE = 2; |
| 280 | pub const PROT_EXEC = 4; | 280 | pub const PROT_EXEC = 4; |
| 281 | | 281 | |
| 282 | pub const CLOCK_REALTIME = 0; | 282 | pub const CLOCK_MONOTONIC = 0; |
| 283 | pub const CLOCK_VIRTUAL = 1; | 283 | pub const CLOCK_REALTIME = -1; |
| 284 | pub const CLOCK_PROF = 2; | 284 | pub const CLOCK_PROCESS_CPUTIME_ID = -2; |
| 285 | pub const CLOCK_MONOTONIC = 4; | 285 | pub const CLOCK_THREAD_CPUTIME_ID = -3; |
| 286 | pub const CLOCK_UPTIME = 5; | | |
| 287 | pub const CLOCK_UPTIME_PRECISE = 7; | | |
| 288 | pub const CLOCK_UPTIME_FAST = 8; | | |
| 289 | pub const CLOCK_REALTIME_PRECISE = 9; | | |
| 290 | pub const CLOCK_REALTIME_FAST = 10; | | |
| 291 | pub const CLOCK_MONOTONIC_PRECISE = 11; | | |
| 292 | pub const CLOCK_MONOTONIC_FAST = 12; | | |
| 293 | pub const CLOCK_SECOND = 13; | | |
| 294 | pub const CLOCK_THREAD_CPUTIME_ID = 14; | | |
| 295 | pub const CLOCK_PROCESS_CPUTIME_ID = 15; | | |
| 296 | | 286 | |
| 297 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | 287 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); |
| 298 | pub const MAP_SHARED = 0x0001; | 288 | pub const MAP_SHARED = 0x0001; |
| ... | @@ -310,58 +300,59 @@ pub const MAP_NOCORE = 0x00020000; | ... | @@ -310,58 +300,59 @@ pub const MAP_NOCORE = 0x00020000; |
| 310 | pub const MAP_PREFAULT_READ = 0x00040000; | 300 | pub const MAP_PREFAULT_READ = 0x00040000; |
| 311 | pub const MAP_32BIT = 0x00080000; | 301 | pub const MAP_32BIT = 0x00080000; |
| 312 | | 302 | |
| 313 | pub const WNOHANG = 1; | 303 | pub const WNOHANG = 0x1; |
| 314 | pub const WUNTRACED = 2; | 304 | pub const WUNTRACED = 0x2; |
| 315 | pub const WSTOPPED = WUNTRACED; | 305 | pub const WSTOPPED = 0x10; |
| 316 | pub const WCONTINUED = 4; | 306 | pub const WCONTINUED = 0x4; |
| 317 | pub const WNOWAIT = 8; | 307 | pub const WNOWAIT = 0x20; |
| 318 | pub const WEXITED = 16; | 308 | pub const WEXITED = 0x08; |
| 319 | pub const WTRAPPED = 32; | 309 | |
| 320 | | 310 | pub const SA_ONSTACK = 0x20; |
| 321 | pub const SA_ONSTACK = 0x0001; | 311 | pub const SA_RESTART = 0x10; |
| 322 | pub const SA_RESTART = 0x0002; | 312 | pub const SA_RESETHAND = 0x04; |
| 323 | pub const SA_RESETHAND = 0x0004; | 313 | pub const SA_NOCLDSTOP = 0x01; |
| 324 | pub const SA_NOCLDSTOP = 0x0008; | 314 | pub const SA_NODEFER = 0x08; |
| 325 | pub const SA_NODEFER = 0x0010; | 315 | pub const SA_NOCLDWAIT = 0x02; |
| 326 | pub const SA_NOCLDWAIT = 0x0020; | 316 | pub const SA_SIGINFO = 0x40; |
| 327 | pub const SA_SIGINFO = 0x0040; | 317 | pub const SA_NOMASK = SA_NODEFER; |
| | 318 | pub const SA_STACK = SA_ONSTACK; |
| | 319 | pub const SA_ONESHOT = SA_RESETHAND; |
| 328 | | 320 | |
| 329 | pub const SIGHUP = 1; | 321 | pub const SIGHUP = 1; |
| 330 | pub const SIGINT = 2; | 322 | pub const SIGINT = 2; |
| 331 | pub const SIGQUIT = 3; | 323 | pub const SIGQUIT = 3; |
| 332 | pub const SIGILL = 4; | 324 | pub const SIGILL = 4; |
| 333 | pub const SIGTRAP = 5; | 325 | pub const SIGCHLD = 5; |
| 334 | pub const SIGABRT = 6; | 326 | pub const SIGABRT = 6; |
| 335 | pub const SIGIOT = SIGABRT; | 327 | pub const SIGIOT = SIGABRT; |
| 336 | pub const SIGEMT = 7; | 328 | pub const SIGPIPE = 7; |
| 337 | pub const SIGFPE = 8; | 329 | pub const SIGFPE = 8; |
| 338 | pub const SIGKILL = 9; | 330 | pub const SIGKILL = 9; |
| 339 | pub const SIGBUS = 10; | 331 | pub const SIGSTOP = 10; |
| 340 | pub const SIGSEGV = 11; | 332 | pub const SIGSEGV = 11; |
| 341 | pub const SIGSYS = 12; | 333 | pub const SIGCONT = 12; |
| 342 | pub const SIGPIPE = 13; | 334 | pub const SIGTSTP = 13; |
| 343 | pub const SIGALRM = 14; | 335 | pub const SIGALRM = 14; |
| 344 | pub const SIGTERM = 15; | 336 | pub const SIGTERM = 15; |
| 345 | pub const SIGURG = 16; | 337 | pub const SIGTTIN = 16; |
| 346 | pub const SIGSTOP = 17; | 338 | pub const SIGTTOU = 17; |
| 347 | pub const SIGTSTP = 18; | 339 | pub const SIGUSR1 = 18; |
| 348 | pub const SIGCONT = 19; | 340 | pub const SIGUSR2 = 19; |
| 349 | pub const SIGCHLD = 20; | 341 | pub const SIGWINCH = 20; |
| 350 | pub const SIGTTIN = 21; | 342 | pub const SIGKILLTHR = 21; |
| 351 | pub const SIGTTOU = 22; | 343 | pub const SIGTRAP = 22; |
| 352 | pub const SIGIO = 23; | 344 | pub const SIGPOLL = 23; |
| 353 | pub const SIGXCPU = 24; | 345 | pub const SIGPROF = 24; |
| 354 | pub const SIGXFSZ = 25; | 346 | pub const SIGSYS = 25; |
| 355 | pub const SIGVTALRM = 26; | 347 | pub const SIGURG = 26; |
| 356 | pub const SIGPROF = 27; | 348 | pub const SIGVTALRM = 27; |
| 357 | pub const SIGWINCH = 28; | 349 | pub const SIGXCPU = 28; |
| 358 | pub const SIGINFO = 29; | 350 | pub const SIGXFSZ = 29; |
| 359 | pub const SIGUSR1 = 30; | 351 | pub const SIGBUS = 30; |
| 360 | pub const SIGUSR2 = 31; | 352 | pub const SIGRESERVED1 = 31; |
| 361 | pub const SIGTHR = 32; | 353 | pub const SIGRESERVED2 = 32; |
| 362 | pub const SIGLWP = SIGTHR; | 354 | |
| 363 | pub const SIGLIBRT = 33; | 355 | // TODO: check |
| 364 | | | |
| 365 | pub const SIGRTMIN = 65; | 356 | pub const SIGRTMIN = 65; |
| 366 | pub const SIGRTMAX = 126; | 357 | pub const SIGRTMAX = 126; |
| 367 | | 358 | |
| ... | @@ -645,135 +636,51 @@ pub const EVFILT_SENDFILE = -12; | ... | @@ -645,135 +636,51 @@ pub const EVFILT_SENDFILE = -12; |
| 645 | | 636 | |
| 646 | pub const EVFILT_EMPTY = -13; | 637 | pub const EVFILT_EMPTY = -13; |
| 647 | | 638 | |
| 648 | /// On input, NOTE_TRIGGER causes the event to be triggered for output. | 639 | pub const TCGETA = 0x8000; |
| 649 | pub const NOTE_TRIGGER = 0x01000000; | 640 | pub const TCSETA = 0x8001; |
| 650 | | 641 | pub const TCSETAW = 0x8004; |
| 651 | /// ignore input fflags | 642 | pub const TCSETAF = 0x8003; |
| 652 | pub const NOTE_FFNOP = 0x00000000; | 643 | pub const TCSBRK = 08005; |
| 653 | | 644 | pub const TCXONC = 0x8007; |
| 654 | /// and fflags | 645 | pub const TCFLSH = 0x8006; |
| 655 | pub const NOTE_FFAND = 0x40000000; | 646 | |
| 656 | | 647 | pub const TIOCSCTTY = 0x8017; |
| 657 | /// or fflags | 648 | pub const TIOCGPGRP = 0x8015; |
| 658 | pub const NOTE_FFOR = 0x80000000; | 649 | pub const TIOCSPGRP = 0x8016; |
| 659 | | 650 | pub const TIOCGWINSZ = 0x8012; |
| 660 | /// copy fflags | 651 | pub const TIOCSWINSZ = 0x8013; |
| 661 | pub const NOTE_FFCOPY = 0xc0000000; | 652 | pub const TIOCMGET = 0x8018; |
| 662 | | 653 | pub const TIOCMBIS = 0x8022; |
| 663 | /// mask for operations | 654 | pub const TIOCMBIC = 0x8023; |
| 664 | pub const NOTE_FFCTRLMASK = 0xc0000000; | 655 | pub const TIOCMSET = 0x8019; |
| 665 | pub const NOTE_FFLAGSMASK = 0x00ffffff; | 656 | pub const FIONREAD = 0xbe000001; |
| 666 | | 657 | pub const FIONBIO = 0xbe000000; |
| 667 | /// low water mark | 658 | pub const TIOCSBRK = 0x8020; |
| 668 | pub const NOTE_LOWAT = 0x00000001; | 659 | pub const TIOCCBRK = 0x8021; |
| 669 | | 660 | pub const TIOCGSID = 0x8024; |
| 670 | /// behave like poll() | | |
| 671 | pub const NOTE_FILE_POLL = 0x00000002; | | |
| 672 | | | |
| 673 | /// vnode was removed | | |
| 674 | pub const NOTE_DELETE = 0x00000001; | | |
| 675 | | | |
| 676 | /// data contents changed | | |
| 677 | pub const NOTE_WRITE = 0x00000002; | | |
| 678 | | | |
| 679 | /// size increased | | |
| 680 | pub const NOTE_EXTEND = 0x00000004; | | |
| 681 | | | |
| 682 | /// attributes changed | | |
| 683 | pub const NOTE_ATTRIB = 0x00000008; | | |
| 684 | | | |
| 685 | /// link count changed | | |
| 686 | pub const NOTE_LINK = 0x00000010; | | |
| 687 | | | |
| 688 | /// vnode was renamed | | |
| 689 | pub const NOTE_RENAME = 0x00000020; | | |
| 690 | | | |
| 691 | /// vnode access was revoked | | |
| 692 | pub const NOTE_REVOKE = 0x00000040; | | |
| 693 | | | |
| 694 | /// vnode was opened | | |
| 695 | pub const NOTE_OPEN = 0x00000080; | | |
| 696 | | | |
| 697 | /// file closed, fd did not allow write | | |
| 698 | pub const NOTE_CLOSE = 0x00000100; | | |
| 699 | | | |
| 700 | /// file closed, fd did allow write | | |
| 701 | pub const NOTE_CLOSE_WRITE = 0x00000200; | | |
| 702 | | | |
| 703 | /// file was read | | |
| 704 | pub const NOTE_READ = 0x00000400; | | |
| 705 | | | |
| 706 | /// process exited | | |
| 707 | pub const NOTE_EXIT = 0x80000000; | | |
| 708 | | | |
| 709 | /// process forked | | |
| 710 | pub const NOTE_FORK = 0x40000000; | | |
| 711 | | | |
| 712 | /// process exec'd | | |
| 713 | pub const NOTE_EXEC = 0x20000000; | | |
| 714 | | | |
| 715 | /// mask for signal & exit status | | |
| 716 | pub const NOTE_PDATAMASK = 0x000fffff; | | |
| 717 | pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK); | | |
| 718 | | | |
| 719 | /// data is seconds | | |
| 720 | pub const NOTE_SECONDS = 0x00000001; | | |
| 721 | | | |
| 722 | /// data is milliseconds | | |
| 723 | pub const NOTE_MSECONDS = 0x00000002; | | |
| 724 | | | |
| 725 | /// data is microseconds | | |
| 726 | pub const NOTE_USECONDS = 0x00000004; | | |
| 727 | | | |
| 728 | /// data is nanoseconds | | |
| 729 | pub const NOTE_NSECONDS = 0x00000008; | | |
| 730 | | | |
| 731 | /// timeout is absolute | | |
| 732 | pub const NOTE_ABSTIME = 0x00000010; | | |
| 733 | | | |
| 734 | pub const TIOCEXCL = 0x2000740d; | | |
| 735 | pub const TIOCNXCL = 0x2000740e; | | |
| 736 | pub const TIOCSCTTY = 0x20007461; | | |
| 737 | pub const TIOCGPGRP = 0x40047477; | | |
| 738 | pub const TIOCSPGRP = 0x80047476; | | |
| 739 | pub const TIOCOUTQ = 0x40047473; | | |
| 740 | pub const TIOCSTI = 0x80017472; | | |
| 741 | pub const TIOCGWINSZ = 0x40087468; | | |
| 742 | pub const TIOCSWINSZ = 0x80087467; | | |
| 743 | pub const TIOCMGET = 0x4004746a; | | |
| 744 | pub const TIOCMBIS = 0x8004746c; | | |
| 745 | pub const TIOCMBIC = 0x8004746b; | | |
| 746 | pub const TIOCMSET = 0x8004746d; | | |
| 747 | pub const FIONREAD = 0x4004667f; | | |
| 748 | pub const TIOCCONS = 0x80047462; | | |
| 749 | pub const TIOCPKT = 0x80047470; | | |
| 750 | pub const FIONBIO = 0x8004667e; | | |
| 751 | pub const TIOCNOTTY = 0x20007471; | | |
| 752 | pub const TIOCSETD = 0x8004741b; | | |
| 753 | pub const TIOCGETD = 0x4004741a; | | |
| 754 | pub const TIOCSBRK = 0x2000747b; | | |
| 755 | pub const TIOCCBRK = 0x2000747a; | | |
| 756 | pub const TIOCGSID = 0x40047463; | | |
| 757 | pub const TIOCGPTN = 0x4004740f; | | |
| 758 | pub const TIOCSIG = 0x2004745f; | | |
| 759 | | 661 | |
| 760 | pub fn WEXITSTATUS(s: u32) u32 { | 662 | pub fn WEXITSTATUS(s: u32) u32 { |
| 761 | return (s & 0xff00) >> 8; | 663 | return (s & 0xff); |
| 762 | } | 664 | } |
| | 665 | |
| 763 | pub fn WTERMSIG(s: u32) u32 { | 666 | pub fn WTERMSIG(s: u32) u32 { |
| 764 | return s & 0x7f; | 667 | return (s >> 8) & 0xff; |
| 765 | } | 668 | } |
| | 669 | |
| 766 | pub fn WSTOPSIG(s: u32) u32 { | 670 | pub fn WSTOPSIG(s: u32) u32 { |
| 767 | return WEXITSTATUS(s); | 671 | return WEXITSTATUS(s); |
| 768 | } | 672 | } |
| | 673 | |
| 769 | pub fn WIFEXITED(s: u32) bool { | 674 | pub fn WIFEXITED(s: u32) bool { |
| 770 | return WTERMSIG(s) == 0; | 675 | return WTERMSIG(s) == 0; |
| 771 | } | 676 | } |
| | 677 | |
| 772 | pub fn WIFSTOPPED(s: u32) bool { | 678 | pub fn WIFSTOPPED(s: u32) bool { |
| 773 | return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; | 679 | return ((s >> 16) & 0xff) != 0; |
| 774 | } | 680 | } |
| | 681 | |
| 775 | pub fn WIFSIGNALED(s: u32) bool { | 682 | pub fn WIFSIGNALED(s: u32) bool { |
| 776 | return (s & 0xffff) -% 1 < 0xff; | 683 | return ((s >> 8) & 0xff) != 0; |
| 777 | } | 684 | } |
| 778 | | 685 | |
| 779 | pub const winsize = extern struct { | 686 | pub const winsize = extern struct { |
| ... | @@ -823,49 +730,47 @@ pub const sigset_t = extern struct { | ... | @@ -823,49 +730,47 @@ pub const sigset_t = extern struct { |
| 823 | __bits: [_SIG_WORDS]u32, | 730 | __bits: [_SIG_WORDS]u32, |
| 824 | }; | 731 | }; |
| 825 | | 732 | |
| 826 | pub const EPERM = 1; // Operation not permitted | 733 | pub const EPERM = -0x7ffffff1; // Operation not permitted |
| 827 | pub const ENOENT = 2; // No such file or directory | 734 | pub const ENOENT = -0x7fff9ffd; // No such file or directory |
| 828 | pub const ESRCH = 3; // No such process | 735 | pub const ESRCH = -0x7fff8ff3; // No such process |
| 829 | pub const EINTR = 4; // Interrupted system call | 736 | pub const EINTR = -0x7ffffff6; // Interrupted system call |
| 830 | pub const EIO = 5; // Input/output error | 737 | pub const EIO = -0x7fffffff; // Input/output error |
| 831 | pub const ENXIO = 6; // Device not configured | 738 | pub const ENXIO = -0x7fff8ff5; // Device not configured |
| 832 | pub const E2BIG = 7; // Argument list too long | 739 | pub const E2BIG = -0x7fff8fff; // Argument list too long |
| 833 | pub const ENOEXEC = 8; // Exec format error | 740 | pub const ENOEXEC = -0x7fffecfe; // Exec format error |
| 834 | pub const EBADF = 9; // Bad file descriptor | 741 | pub const ECHILD = -0x7fff8ffe; // No child processes |
| 835 | pub const ECHILD = 10; // No child processes | 742 | pub const EDEADLK = -0x7fff8ffd; // Resource deadlock avoided |
| 836 | pub const EDEADLK = 11; // Resource deadlock avoided | 743 | pub const ENOMEM = -0x80000000; // Cannot allocate memory |
| 837 | // 11 was EAGAIN | 744 | pub const EACCES = -0x7ffffffe; // Permission denied |
| 838 | pub const ENOMEM = 12; // Cannot allocate memory | 745 | pub const EFAULT = -0x7fffecff; // Bad address |
| 839 | pub const EACCES = 13; // Permission denied | 746 | pub const EBUSY = -0x7ffffff2; // Device busy |
| 840 | pub const EFAULT = 14; // Bad address | 747 | pub const EEXIST = -0x7fff9ffe; // File exists |
| 841 | pub const ENOTBLK = 15; // Block device required | 748 | pub const EXDEV = -0x7fff9ff5; // Cross-device link |
| 842 | pub const EBUSY = 16; // Device busy | 749 | pub const ENODEV = -0x7fff8ff9; // Operation not supported by device |
| 843 | pub const EEXIST = 17; // File exists | 750 | pub const ENOTDIR = -0x7fff9ffb; // Not a directory |
| 844 | pub const EXDEV = 18; // Cross-device link | 751 | pub const EISDIR = -0x7fff9ff7; // Is a directory |
| 845 | pub const ENODEV = 19; // Operation not supported by device | 752 | pub const EINVAL = -0x7ffffffb; // Invalid argument |
| 846 | pub const ENOTDIR = 20; // Not a directory | 753 | pub const ENFILE = -0x7fff8ffa; // Too many open files in system |
| 847 | pub const EISDIR = 21; // Is a directory | 754 | pub const EMFILE = -0x7fff9ff6; // Too many open files |
| 848 | pub const EINVAL = 22; // Invalid argument | 755 | pub const ENOTTY = -0x7fff8ff6; // Inappropriate ioctl for device |
| 849 | pub const ENFILE = 23; // Too many open files in system | 756 | pub const ETXTBSY = -0x7fff8fc5; // Text file busy |
| 850 | pub const EMFILE = 24; // Too many open files | 757 | pub const EFBIG = -0x7fff8ffc; // File too large |
| 851 | pub const ENOTTY = 25; // Inappropriate ioctl for device | 758 | pub const ENOSPC = -0x7fff9ff9; // No space left on device |
| 852 | pub const ETXTBSY = 26; // Text file busy | 759 | pub const ESPIPE = -0x7fff8ff4; // Illegal seek |
| 853 | pub const EFBIG = 27; // File too large | 760 | pub const EROFS = -0x7fff9ff8; // Read-only filesystem |
| 854 | pub const ENOSPC = 28; // No space left on device | 761 | pub const EMLINK = -0x7fff8ffb; // Too many links |
| 855 | pub const ESPIPE = 29; // Illegal seek | 762 | pub const EPIPE = -0x7fff9ff3; // Broken pipe |
| 856 | pub const EROFS = 30; // Read-only filesystem | 763 | pub const EBADF = -0x7fffa000; // Bad file descriptor |
| 857 | pub const EMLINK = 31; // Too many links | | |
| 858 | pub const EPIPE = 32; // Broken pipe | | |
| 859 | | 764 | |
| 860 | // math software | 765 | // math software |
| 861 | pub const EDOM = 33; // Numerical argument out of domain | 766 | pub const EDOM = 33; // Numerical argument out of domain |
| 862 | pub const ERANGE = 34; // Result too large | 767 | pub const ERANGE = 34; // Result too large |
| 863 | | 768 | |
| 864 | // non-blocking and interrupt i/o | 769 | // non-blocking and interrupt i/o |
| 865 | pub const EAGAIN = 35; // Resource temporarily unavailable | 770 | pub const EAGAIN = -0x7ffffff5; |
| 866 | pub const EWOULDBLOCK = EAGAIN; // Operation would block | 771 | pub const EWOULDBLOCK = -0x7ffffff5; |
| 867 | pub const EINPROGRESS = 36; // Operation now in progress | 772 | pub const EINPROGRESS = -0x7fff8fdc; |
| 868 | pub const EALREADY = 37; // Operation already in progress | 773 | pub const EALREADY = -0x7fff8fdb; |
| 869 | | 774 | |
| 870 | // ipc/network software -- argument errors | 775 | // ipc/network software -- argument errors |
| 871 | pub const ENOTSOCK = 38; // Socket operation on non-socket | 776 | pub const ENOTSOCK = 38; // Socket operation on non-socket |
| ... | @@ -1447,3 +1352,20 @@ pub const directory_which = extern enum(c_int) { | ... | @@ -1447,3 +1352,20 @@ pub const directory_which = extern enum(c_int) { |
| 1447 | | 1352 | |
| 1448 | _, | 1353 | _, |
| 1449 | }; | 1354 | }; |
| | 1355 | |
| | 1356 | pub const cc_t = u8; |
| | 1357 | pub const speed_t = u8; |
| | 1358 | pub const tcflag_t = u32; |
| | 1359 | |
| | 1360 | pub const NCCS = 32; |
| | 1361 | |
| | 1362 | pub const termios = extern struct { |
| | 1363 | c_iflag: tcflag_t, |
| | 1364 | c_oflag: tcflag_t, |
| | 1365 | c_cflag: tcflag_t, |
| | 1366 | c_lflag: tcflag_t, |
| | 1367 | c_line: cc_t, |
| | 1368 | c_ispeed: speed_t, |
| | 1369 | c_ospeed: speed_t, |
| | 1370 | cc_t: [NCCS]cc_t, |
| | 1371 | }; |