| 1 | (* The C library: what raz's own library calls in it, and what most |
| 2 | programs reach for. A program that imports C uses C, and so is |
| 3 | linked dynamically and starts through the C library. *) |
| 4 | module C; |
| 5 | import SYSTEM; |
| 6 | |
| 7 | extern proc write*(fd: I32; buf: ^U8; n: UINT): INT; |
| 8 | extern proc read*(fd: I32; buf: ^U8; n: UINT): INT; |
| 9 | extern proc open*(path: ^U8; flags: I32; ...): I32; |
| 10 | extern proc creat*(path: ^U8; mode: U32): I32; |
| 11 | extern proc close*(fd: I32): I32; |
| 12 | extern proc mmap*(addr: ^U8; n: UINT; prot, flags, fd: I32; off: I64): ^U8; |
| 13 | extern proc munmap*(addr: ^U8; n: UINT): I32; |
| 14 | extern proc mprotect*(addr: ^U8; n: UINT; prot: I32): I32; |
| 15 | extern proc isatty*(fd: I32): I32; |
| 16 | extern proc exit*(status: I32); |
| 17 | extern proc _exit*(status: I32); |
| 18 | extern proc __errno_location*: ^I32; (* errno, this thread's *) |
| 19 | extern proc sched_yield*: I32; |
| 20 | extern proc pthread_create*(t: ^UINT; attr: ^U8; |
| 21 | start: proc(arg: ^U8): ^U8; arg: ^U8): I32; |
| 22 | extern proc pthread_join*(t: UINT; result: ^^U8): I32; |
| 23 | extern proc rename*(old, new: ^U8): I32; |
| 24 | extern proc unlink*(path: ^U8): I32; |
| 25 | extern proc mkdir*(path: ^U8; mode: U32): I32; |
| 26 | extern proc rmdir*(path: ^U8): I32; |
| 27 | extern proc chmod*(path: ^U8; mode: U32): I32; |
| 28 | extern proc chown*(path: ^U8; uid, gid: U32): I32; |
| 29 | extern proc mkfifo*(path: ^U8; mode: U32): I32; |
| 30 | extern proc utimensat*(dir: I32; path, times: ^U8; flags: I32): I32; |
| 31 | extern proc readlink*(path, buf: ^U8; n: UINT): INT; |
| 32 | extern proc lseek*(fd: I32; off: I64; whence: I32): I64; |
| 33 | extern proc opendir*(path: ^U8): ^U8; (* DIR * *) |
| 34 | extern proc readdir*(d: ^U8): ^U8; (* struct dirent * *) |
| 35 | extern proc closedir*(d: ^U8): I32; |
| 36 | extern proc tcgetattr*(fd: I32; t: ^U8): I32; |
| 37 | extern proc tcsetattr*(fd: I32; when: I32; t: ^U8): I32; |
| 38 | extern proc cfmakeraw*(t: ^U8); |
| 39 | extern proc ioctl*(fd: I32; request: UINT; ...): I32; |
| 40 | extern proc poll*(fds: ^U8; n: UINT; ms: I32): I32; |
| 41 | extern proc fcntl*(fd, cmd: I32; ...): I32; |
| 42 | extern proc socket*(domain, kind, protocol: I32): I32; |
| 43 | extern proc connect*(fd: I32; addr: ^U8; len: U32): I32; |
| 44 | extern proc send*(fd: I32; buf: ^U8; n: UINT; flags: I32): INT; |
| 45 | extern proc bind*(fd: I32; addr: ^U8; len: U32): I32; |
| 46 | extern proc listen*(fd, backlog: I32): I32; |
| 47 | extern proc accept*(fd: I32; addr: ^U8; len: ^U32): I32; |
| 48 | extern proc accept4*(fd: I32; addr: ^U8; len: ^U32; flags: I32): I32; |
| 49 | extern proc setsockopt*(fd, level, name: I32; value: ^U8; len: U32): I32; |
| 50 | extern proc getsockopt*(fd, level, name: I32; value: ^U8; len: ^U32): I32; |
| 51 | extern proc getpeername*(fd: I32; addr: ^U8; len: ^U32): I32; |
| 52 | extern proc shutdown*(fd, how: I32): I32; |
| 53 | extern proc socketpair*(domain, kind, protocol: I32; fds: ^I32): I32; |
| 54 | extern proc getsockname*(fd: I32; addr: ^U8; len: ^U32): I32; |
| 55 | extern proc recvfrom*(fd: I32; buf: ^U8; n: UINT; flags: I32; addr: ^U8; len: ^U32): INT; |
| 56 | extern proc sendto*(fd: I32; buf: ^U8; n: UINT; flags: I32; addr: ^U8; len: U32): INT; |
| 57 | extern proc sendmsg*(fd: I32; msg: ^U8; flags: I32): INT; |
| 58 | extern proc recvmsg*(fd: I32; msg: ^U8; flags: I32): INT; |
| 59 | extern proc memfd_create*(name: ^U8; flags: U32): I32; |
| 60 | extern proc ftruncate*(fd: I32; size: I64): I32; |
| 61 | extern proc inet_pton*(family: I32; src, dst: ^U8): I32; |
| 62 | extern proc clock_gettime*(clock: I32; t: ^U8): I32; |
| 63 | extern proc clock_nanosleep*(clock, flags: I32; t, left: ^U8): I32; |
| 64 | extern proc getrandom*(buf: ^U8; n: UINT; flags: U32): INT; |
| 65 | extern proc getenv*(name: ^U8): ^U8; |
| 66 | extern proc setenv*(name, value: ^U8; overwrite: I32): I32; |
| 67 | extern proc strerror*(err: I32): ^U8; |
| 68 | extern proc getcwd*(buf: ^U8; n: UINT): ^U8; |
| 69 | extern proc chdir*(path: ^U8): I32; |
| 70 | extern proc stat*(path, st: ^U8): I32; |
| 71 | extern proc fstat*(fd: I32; st: ^U8): I32; |
| 72 | extern proc fsync*(fd: I32): I32; |
| 73 | extern proc sync*; |
| 74 | extern proc flock*(fd, how: I32): I32; |
| 75 | extern proc lstat*(path, st: ^U8): I32; |
| 76 | extern proc statvfs*(path, st: ^U8): I32; |
| 77 | extern proc symlink*(target, path: ^U8): I32; |
| 78 | extern proc posix_openpt*(flags: I32): I32; |
| 79 | extern proc grantpt*(fd: I32): I32; |
| 80 | extern proc unlockpt*(fd: I32): I32; |
| 81 | extern proc ptsname*(fd: I32): ^U8; |
| 82 | extern proc fork*: I32; |
| 83 | extern proc setsid*: I32; |
| 84 | extern proc dup2*(fd, fd2: I32): I32; |
| 85 | extern proc dup*(fd: I32): I32; |
| 86 | extern proc close_range*(first, last: U32; flags: I32): I32; |
| 87 | extern proc execve*(path: ^U8; argv, envp: ^^U8): I32; |
| 88 | extern proc waitpid*(pid: I32; status: ^I32; options: I32): I32; |
| 89 | extern proc kill*(pid, signal: I32): I32; |
| 90 | extern proc getpid*: I32; |
| 91 | extern proc getuid*: U32; |
| 92 | extern proc geteuid*: U32; |
| 93 | extern proc gethostname*(name: ^U8; n: UINT): I32; |
| 94 | extern proc access*(path: ^U8; how: I32): I32; |
| 95 | extern proc umask*(mask: U32): U32; |
| 96 | extern proc sched_getaffinity*(pid: I32; size: UINT; mask: ^U8): I32; |
| 97 | extern proc getrusage*(who: I32; usage: ^U8): I32; |
| 98 | extern proc getrlimit*(which: I32; limit: ^U8): I32; |
| 99 | extern proc setrlimit*(which: I32; limit: ^U8): I32; |
| 100 | extern proc getpgrp*: I32; |
| 101 | extern proc setpgid*(pid, group: I32): I32; |
| 102 | extern proc tcsetpgrp*(fd, group: I32): I32; |
| 103 | extern proc tcgetpgrp*(fd: I32): I32; |
| 104 | extern proc pipe2*(fds: ^I32; flags: I32): I32; |
| 105 | extern proc sigaction*(sig: I32; act, old: ^U8): I32; |
| 106 | extern proc sigprocmask*(how: I32; mask, old: ^U8): I32; |
| 107 | extern proc printf*(format: ^U8; ...): I32; |
| 108 | extern proc fflush*(f: ^U8): I32; |
| 109 | extern var environ*: ^^U8; |
| 110 | extern var stdout*: ^U8; (* FILE * *) |
| 111 | extern var stderr*: ^U8; |
| 112 | |
| 113 | end C. |