| ... | ... | @@ -279,20 +279,10 @@ pub const PROT_READ = 1; |
| 279 | 279 | pub const PROT_WRITE = 2; |
| 280 | 280 | pub const PROT_EXEC = 4; |
| 281 | 281 | |
| 282 | | pub const CLOCK_REALTIME = 0; |
| 283 | | pub const CLOCK_VIRTUAL = 1; |
| 284 | | pub const CLOCK_PROF = 2; |
| 285 | | pub const CLOCK_MONOTONIC = 4; |
| 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; |
| 282 | pub const CLOCK_MONOTONIC = 0; |
| 283 | pub const CLOCK_REALTIME = -1; |
| 284 | pub const CLOCK_PROCESS_CPUTIME_ID = -2; |
| 285 | pub const CLOCK_THREAD_CPUTIME_ID = -3; |
| 296 | 286 | |
| 297 | 287 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); |
| 298 | 288 | pub const MAP_SHARED = 0x0001; |
| ... | ... | @@ -310,58 +300,59 @@ pub const MAP_NOCORE = 0x00020000; |
| 310 | 300 | pub const MAP_PREFAULT_READ = 0x00040000; |
| 311 | 301 | pub const MAP_32BIT = 0x00080000; |
| 312 | 302 | |
| 313 | | pub const WNOHANG = 1; |
| 314 | | pub const WUNTRACED = 2; |
| 315 | | pub const WSTOPPED = WUNTRACED; |
| 316 | | pub const WCONTINUED = 4; |
| 317 | | pub const WNOWAIT = 8; |
| 318 | | pub const WEXITED = 16; |
| 319 | | pub const WTRAPPED = 32; |
| 320 | | |
| 321 | | pub const SA_ONSTACK = 0x0001; |
| 322 | | pub const SA_RESTART = 0x0002; |
| 323 | | pub const SA_RESETHAND = 0x0004; |
| 324 | | pub const SA_NOCLDSTOP = 0x0008; |
| 325 | | pub const SA_NODEFER = 0x0010; |
| 326 | | pub const SA_NOCLDWAIT = 0x0020; |
| 327 | | pub const SA_SIGINFO = 0x0040; |
| 303 | pub const WNOHANG = 0x1; |
| 304 | pub const WUNTRACED = 0x2; |
| 305 | pub const WSTOPPED = 0x10; |
| 306 | pub const WCONTINUED = 0x4; |
| 307 | pub const WNOWAIT = 0x20; |
| 308 | pub const WEXITED = 0x08; |
| 309 | |
| 310 | pub const SA_ONSTACK = 0x20; |
| 311 | pub const SA_RESTART = 0x10; |
| 312 | pub const SA_RESETHAND = 0x04; |
| 313 | pub const SA_NOCLDSTOP = 0x01; |
| 314 | pub const SA_NODEFER = 0x08; |
| 315 | pub const SA_NOCLDWAIT = 0x02; |
| 316 | pub const SA_SIGINFO = 0x40; |
| 317 | pub const SA_NOMASK = SA_NODEFER; |
| 318 | pub const SA_STACK = SA_ONSTACK; |
| 319 | pub const SA_ONESHOT = SA_RESETHAND; |
| 328 | 320 | |
| 329 | 321 | pub const SIGHUP = 1; |
| 330 | 322 | pub const SIGINT = 2; |
| 331 | 323 | pub const SIGQUIT = 3; |
| 332 | 324 | pub const SIGILL = 4; |
| 333 | | pub const SIGTRAP = 5; |
| 325 | pub const SIGCHLD = 5; |
| 334 | 326 | pub const SIGABRT = 6; |
| 335 | 327 | pub const SIGIOT = SIGABRT; |
| 336 | | pub const SIGEMT = 7; |
| 328 | pub const SIGPIPE = 7; |
| 337 | 329 | pub const SIGFPE = 8; |
| 338 | 330 | pub const SIGKILL = 9; |
| 339 | | pub const SIGBUS = 10; |
| 331 | pub const SIGSTOP = 10; |
| 340 | 332 | pub const SIGSEGV = 11; |
| 341 | | pub const SIGSYS = 12; |
| 342 | | pub const SIGPIPE = 13; |
| 333 | pub const SIGCONT = 12; |
| 334 | pub const SIGTSTP = 13; |
| 343 | 335 | pub const SIGALRM = 14; |
| 344 | 336 | pub const SIGTERM = 15; |
| 345 | | pub const SIGURG = 16; |
| 346 | | pub const SIGSTOP = 17; |
| 347 | | pub const SIGTSTP = 18; |
| 348 | | pub const SIGCONT = 19; |
| 349 | | pub const SIGCHLD = 20; |
| 350 | | pub const SIGTTIN = 21; |
| 351 | | pub const SIGTTOU = 22; |
| 352 | | pub const SIGIO = 23; |
| 353 | | pub const SIGXCPU = 24; |
| 354 | | pub const SIGXFSZ = 25; |
| 355 | | pub const SIGVTALRM = 26; |
| 356 | | pub const SIGPROF = 27; |
| 357 | | pub const SIGWINCH = 28; |
| 358 | | pub const SIGINFO = 29; |
| 359 | | pub const SIGUSR1 = 30; |
| 360 | | pub const SIGUSR2 = 31; |
| 361 | | pub const SIGTHR = 32; |
| 362 | | pub const SIGLWP = SIGTHR; |
| 363 | | pub const SIGLIBRT = 33; |
| 364 | | |
| 337 | pub const SIGTTIN = 16; |
| 338 | pub const SIGTTOU = 17; |
| 339 | pub const SIGUSR1 = 18; |
| 340 | pub const SIGUSR2 = 19; |
| 341 | pub const SIGWINCH = 20; |
| 342 | pub const SIGKILLTHR = 21; |
| 343 | pub const SIGTRAP = 22; |
| 344 | pub const SIGPOLL = 23; |
| 345 | pub const SIGPROF = 24; |
| 346 | pub const SIGSYS = 25; |
| 347 | pub const SIGURG = 26; |
| 348 | pub const SIGVTALRM = 27; |
| 349 | pub const SIGXCPU = 28; |
| 350 | pub const SIGXFSZ = 29; |
| 351 | pub const SIGBUS = 30; |
| 352 | pub const SIGRESERVED1 = 31; |
| 353 | pub const SIGRESERVED2 = 32; |
| 354 | |
| 355 | // TODO: check |
| 365 | 356 | pub const SIGRTMIN = 65; |
| 366 | 357 | pub const SIGRTMAX = 126; |
| 367 | 358 | |
| ... | ... | @@ -645,135 +636,51 @@ pub const EVFILT_SENDFILE = -12; |
| 645 | 636 | |
| 646 | 637 | pub const EVFILT_EMPTY = -13; |
| 647 | 638 | |
| 648 | | /// On input, NOTE_TRIGGER causes the event to be triggered for output. |
| 649 | | pub const NOTE_TRIGGER = 0x01000000; |
| 650 | | |
| 651 | | /// ignore input fflags |
| 652 | | pub const NOTE_FFNOP = 0x00000000; |
| 653 | | |
| 654 | | /// and fflags |
| 655 | | pub const NOTE_FFAND = 0x40000000; |
| 656 | | |
| 657 | | /// or fflags |
| 658 | | pub const NOTE_FFOR = 0x80000000; |
| 659 | | |
| 660 | | /// copy fflags |
| 661 | | pub const NOTE_FFCOPY = 0xc0000000; |
| 662 | | |
| 663 | | /// mask for operations |
| 664 | | pub const NOTE_FFCTRLMASK = 0xc0000000; |
| 665 | | pub const NOTE_FFLAGSMASK = 0x00ffffff; |
| 666 | | |
| 667 | | /// low water mark |
| 668 | | pub const NOTE_LOWAT = 0x00000001; |
| 669 | | |
| 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; |
| 639 | pub const TCGETA = 0x8000; |
| 640 | pub const TCSETA = 0x8001; |
| 641 | pub const TCSETAW = 0x8004; |
| 642 | pub const TCSETAF = 0x8003; |
| 643 | pub const TCSBRK = 08005; |
| 644 | pub const TCXONC = 0x8007; |
| 645 | pub const TCFLSH = 0x8006; |
| 646 | |
| 647 | pub const TIOCSCTTY = 0x8017; |
| 648 | pub const TIOCGPGRP = 0x8015; |
| 649 | pub const TIOCSPGRP = 0x8016; |
| 650 | pub const TIOCGWINSZ = 0x8012; |
| 651 | pub const TIOCSWINSZ = 0x8013; |
| 652 | pub const TIOCMGET = 0x8018; |
| 653 | pub const TIOCMBIS = 0x8022; |
| 654 | pub const TIOCMBIC = 0x8023; |
| 655 | pub const TIOCMSET = 0x8019; |
| 656 | pub const FIONREAD = 0xbe000001; |
| 657 | pub const FIONBIO = 0xbe000000; |
| 658 | pub const TIOCSBRK = 0x8020; |
| 659 | pub const TIOCCBRK = 0x8021; |
| 660 | pub const TIOCGSID = 0x8024; |
| 759 | 661 | |
| 760 | 662 | pub fn WEXITSTATUS(s: u32) u32 { |
| 761 | | return (s & 0xff00) >> 8; |
| 663 | return (s & 0xff); |
| 762 | 664 | } |
| 665 | |
| 763 | 666 | pub fn WTERMSIG(s: u32) u32 { |
| 764 | | return s & 0x7f; |
| 667 | return (s >> 8) & 0xff; |
| 765 | 668 | } |
| 669 | |
| 766 | 670 | pub fn WSTOPSIG(s: u32) u32 { |
| 767 | 671 | return WEXITSTATUS(s); |
| 768 | 672 | } |
| 673 | |
| 769 | 674 | pub fn WIFEXITED(s: u32) bool { |
| 770 | 675 | return WTERMSIG(s) == 0; |
| 771 | 676 | } |
| 677 | |
| 772 | 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 | 682 | pub fn WIFSIGNALED(s: u32) bool { |
| 776 | | return (s & 0xffff) -% 1 < 0xff; |
| 683 | return ((s >> 8) & 0xff) != 0; |
| 777 | 684 | } |
| 778 | 685 | |
| 779 | 686 | pub const winsize = extern struct { |
| ... | ... | @@ -823,49 +730,47 @@ pub const sigset_t = extern struct { |
| 823 | 730 | __bits: [_SIG_WORDS]u32, |
| 824 | 731 | }; |
| 825 | 732 | |
| 826 | | pub const EPERM = 1; // Operation not permitted |
| 827 | | pub const ENOENT = 2; // No such file or directory |
| 828 | | pub const ESRCH = 3; // No such process |
| 829 | | pub const EINTR = 4; // Interrupted system call |
| 830 | | pub const EIO = 5; // Input/output error |
| 831 | | pub const ENXIO = 6; // Device not configured |
| 832 | | pub const E2BIG = 7; // Argument list too long |
| 833 | | pub const ENOEXEC = 8; // Exec format error |
| 834 | | pub const EBADF = 9; // Bad file descriptor |
| 835 | | pub const ECHILD = 10; // No child processes |
| 836 | | pub const EDEADLK = 11; // Resource deadlock avoided |
| 837 | | // 11 was EAGAIN |
| 838 | | pub const ENOMEM = 12; // Cannot allocate memory |
| 839 | | pub const EACCES = 13; // Permission denied |
| 840 | | pub const EFAULT = 14; // Bad address |
| 841 | | pub const ENOTBLK = 15; // Block device required |
| 842 | | pub const EBUSY = 16; // Device busy |
| 843 | | pub const EEXIST = 17; // File exists |
| 844 | | pub const EXDEV = 18; // Cross-device link |
| 845 | | pub const ENODEV = 19; // Operation not supported by device |
| 846 | | pub const ENOTDIR = 20; // Not a directory |
| 847 | | pub const EISDIR = 21; // Is a directory |
| 848 | | pub const EINVAL = 22; // Invalid argument |
| 849 | | pub const ENFILE = 23; // Too many open files in system |
| 850 | | pub const EMFILE = 24; // Too many open files |
| 851 | | pub const ENOTTY = 25; // Inappropriate ioctl for device |
| 852 | | pub const ETXTBSY = 26; // Text file busy |
| 853 | | pub const EFBIG = 27; // File too large |
| 854 | | pub const ENOSPC = 28; // No space left on device |
| 855 | | pub const ESPIPE = 29; // Illegal seek |
| 856 | | pub const EROFS = 30; // Read-only filesystem |
| 857 | | pub const EMLINK = 31; // Too many links |
| 858 | | pub const EPIPE = 32; // Broken pipe |
| 733 | pub const EPERM = -0x7ffffff1; // Operation not permitted |
| 734 | pub const ENOENT = -0x7fff9ffd; // No such file or directory |
| 735 | pub const ESRCH = -0x7fff8ff3; // No such process |
| 736 | pub const EINTR = -0x7ffffff6; // Interrupted system call |
| 737 | pub const EIO = -0x7fffffff; // Input/output error |
| 738 | pub const ENXIO = -0x7fff8ff5; // Device not configured |
| 739 | pub const E2BIG = -0x7fff8fff; // Argument list too long |
| 740 | pub const ENOEXEC = -0x7fffecfe; // Exec format error |
| 741 | pub const ECHILD = -0x7fff8ffe; // No child processes |
| 742 | pub const EDEADLK = -0x7fff8ffd; // Resource deadlock avoided |
| 743 | pub const ENOMEM = -0x80000000; // Cannot allocate memory |
| 744 | pub const EACCES = -0x7ffffffe; // Permission denied |
| 745 | pub const EFAULT = -0x7fffecff; // Bad address |
| 746 | pub const EBUSY = -0x7ffffff2; // Device busy |
| 747 | pub const EEXIST = -0x7fff9ffe; // File exists |
| 748 | pub const EXDEV = -0x7fff9ff5; // Cross-device link |
| 749 | pub const ENODEV = -0x7fff8ff9; // Operation not supported by device |
| 750 | pub const ENOTDIR = -0x7fff9ffb; // Not a directory |
| 751 | pub const EISDIR = -0x7fff9ff7; // Is a directory |
| 752 | pub const EINVAL = -0x7ffffffb; // Invalid argument |
| 753 | pub const ENFILE = -0x7fff8ffa; // Too many open files in system |
| 754 | pub const EMFILE = -0x7fff9ff6; // Too many open files |
| 755 | pub const ENOTTY = -0x7fff8ff6; // Inappropriate ioctl for device |
| 756 | pub const ETXTBSY = -0x7fff8fc5; // Text file busy |
| 757 | pub const EFBIG = -0x7fff8ffc; // File too large |
| 758 | pub const ENOSPC = -0x7fff9ff9; // No space left on device |
| 759 | pub const ESPIPE = -0x7fff8ff4; // Illegal seek |
| 760 | pub const EROFS = -0x7fff9ff8; // Read-only filesystem |
| 761 | pub const EMLINK = -0x7fff8ffb; // Too many links |
| 762 | pub const EPIPE = -0x7fff9ff3; // Broken pipe |
| 763 | pub const EBADF = -0x7fffa000; // Bad file descriptor |
| 859 | 764 | |
| 860 | 765 | // math software |
| 861 | 766 | pub const EDOM = 33; // Numerical argument out of domain |
| 862 | 767 | pub const ERANGE = 34; // Result too large |
| 863 | 768 | |
| 864 | 769 | // non-blocking and interrupt i/o |
| 865 | | pub const EAGAIN = 35; // Resource temporarily unavailable |
| 866 | | pub const EWOULDBLOCK = EAGAIN; // Operation would block |
| 867 | | pub const EINPROGRESS = 36; // Operation now in progress |
| 868 | | pub const EALREADY = 37; // Operation already in progress |
| 770 | pub const EAGAIN = -0x7ffffff5; |
| 771 | pub const EWOULDBLOCK = -0x7ffffff5; |
| 772 | pub const EINPROGRESS = -0x7fff8fdc; |
| 773 | pub const EALREADY = -0x7fff8fdb; |
| 869 | 774 | |
| 870 | 775 | // ipc/network software -- argument errors |
| 871 | 776 | pub const ENOTSOCK = 38; // Socket operation on non-socket |
| ... | ... | @@ -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 | }; |