A lightweight mechanism to provide an *instant kickstart* to a Go web server instance upon changing any Go source files under the project directory (and its subdirectories).

syscall_openbsd.go 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. // Copyright 2009,2010 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // OpenBSD system calls.
  5. // This file is compiled as ordinary Go code,
  6. // but it is also input to mksyscall,
  7. // which parses the //sys lines and generates system call stubs.
  8. // Note that sometimes we use a lowercase //sys name and wrap
  9. // it in our own nicer implementation, either here or in
  10. // syscall_bsd.go or syscall_unix.go.
  11. package unix
  12. import (
  13. "syscall"
  14. "unsafe"
  15. )
  16. type SockaddrDatalink struct {
  17. Len uint8
  18. Family uint8
  19. Index uint16
  20. Type uint8
  21. Nlen uint8
  22. Alen uint8
  23. Slen uint8
  24. Data [24]int8
  25. raw RawSockaddrDatalink
  26. }
  27. func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
  28. func nametomib(name string) (mib []_C_int, err error) {
  29. // Perform lookup via a binary search
  30. left := 0
  31. right := len(sysctlMib) - 1
  32. for {
  33. idx := left + (right-left)/2
  34. switch {
  35. case name == sysctlMib[idx].ctlname:
  36. return sysctlMib[idx].ctloid, nil
  37. case name > sysctlMib[idx].ctlname:
  38. left = idx + 1
  39. default:
  40. right = idx - 1
  41. }
  42. if left > right {
  43. break
  44. }
  45. }
  46. return nil, EINVAL
  47. }
  48. func direntIno(buf []byte) (uint64, bool) {
  49. return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno))
  50. }
  51. func direntReclen(buf []byte) (uint64, bool) {
  52. return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
  53. }
  54. func direntNamlen(buf []byte) (uint64, bool) {
  55. return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
  56. }
  57. //sysnb pipe(p *[2]_C_int) (err error)
  58. func Pipe(p []int) (err error) {
  59. if len(p) != 2 {
  60. return EINVAL
  61. }
  62. var pp [2]_C_int
  63. err = pipe(&pp)
  64. p[0] = int(pp[0])
  65. p[1] = int(pp[1])
  66. return
  67. }
  68. //sys getdents(fd int, buf []byte) (n int, err error)
  69. func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
  70. return getdents(fd, buf)
  71. }
  72. // TODO
  73. func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
  74. return -1, ENOSYS
  75. }
  76. func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
  77. var _p0 unsafe.Pointer
  78. var bufsize uintptr
  79. if len(buf) > 0 {
  80. _p0 = unsafe.Pointer(&buf[0])
  81. bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
  82. }
  83. r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
  84. n = int(r0)
  85. if e1 != 0 {
  86. err = e1
  87. }
  88. return
  89. }
  90. /*
  91. * Exposed directly
  92. */
  93. //sys Access(path string, mode uint32) (err error)
  94. //sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
  95. //sys Chdir(path string) (err error)
  96. //sys Chflags(path string, flags int) (err error)
  97. //sys Chmod(path string, mode uint32) (err error)
  98. //sys Chown(path string, uid int, gid int) (err error)
  99. //sys Chroot(path string) (err error)
  100. //sys Close(fd int) (err error)
  101. //sys Dup(fd int) (nfd int, err error)
  102. //sys Dup2(from int, to int) (err error)
  103. //sys Exit(code int)
  104. //sys Fchdir(fd int) (err error)
  105. //sys Fchflags(fd int, flags int) (err error)
  106. //sys Fchmod(fd int, mode uint32) (err error)
  107. //sys Fchown(fd int, uid int, gid int) (err error)
  108. //sys Flock(fd int, how int) (err error)
  109. //sys Fpathconf(fd int, name int) (val int, err error)
  110. //sys Fstat(fd int, stat *Stat_t) (err error)
  111. //sys Fstatfs(fd int, stat *Statfs_t) (err error)
  112. //sys Fsync(fd int) (err error)
  113. //sys Ftruncate(fd int, length int64) (err error)
  114. //sysnb Getegid() (egid int)
  115. //sysnb Geteuid() (uid int)
  116. //sysnb Getgid() (gid int)
  117. //sysnb Getpgid(pid int) (pgid int, err error)
  118. //sysnb Getpgrp() (pgrp int)
  119. //sysnb Getpid() (pid int)
  120. //sysnb Getppid() (ppid int)
  121. //sys Getpriority(which int, who int) (prio int, err error)
  122. //sysnb Getrlimit(which int, lim *Rlimit) (err error)
  123. //sysnb Getrusage(who int, rusage *Rusage) (err error)
  124. //sysnb Getsid(pid int) (sid int, err error)
  125. //sysnb Gettimeofday(tv *Timeval) (err error)
  126. //sysnb Getuid() (uid int)
  127. //sys Issetugid() (tainted bool)
  128. //sys Kill(pid int, signum syscall.Signal) (err error)
  129. //sys Kqueue() (fd int, err error)
  130. //sys Lchown(path string, uid int, gid int) (err error)
  131. //sys Link(path string, link string) (err error)
  132. //sys Listen(s int, backlog int) (err error)
  133. //sys Lstat(path string, stat *Stat_t) (err error)
  134. //sys Mkdir(path string, mode uint32) (err error)
  135. //sys Mkfifo(path string, mode uint32) (err error)
  136. //sys Mknod(path string, mode uint32, dev int) (err error)
  137. //sys Mlock(b []byte) (err error)
  138. //sys Mlockall(flags int) (err error)
  139. //sys Mprotect(b []byte, prot int) (err error)
  140. //sys Munlock(b []byte) (err error)
  141. //sys Munlockall() (err error)
  142. //sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
  143. //sys Open(path string, mode int, perm uint32) (fd int, err error)
  144. //sys Pathconf(path string, name int) (val int, err error)
  145. //sys Pread(fd int, p []byte, offset int64) (n int, err error)
  146. //sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
  147. //sys read(fd int, p []byte) (n int, err error)
  148. //sys Readlink(path string, buf []byte) (n int, err error)
  149. //sys Rename(from string, to string) (err error)
  150. //sys Revoke(path string) (err error)
  151. //sys Rmdir(path string) (err error)
  152. //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
  153. //sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
  154. //sysnb Setegid(egid int) (err error)
  155. //sysnb Seteuid(euid int) (err error)
  156. //sysnb Setgid(gid int) (err error)
  157. //sys Setlogin(name string) (err error)
  158. //sysnb Setpgid(pid int, pgid int) (err error)
  159. //sys Setpriority(which int, who int, prio int) (err error)
  160. //sysnb Setregid(rgid int, egid int) (err error)
  161. //sysnb Setreuid(ruid int, euid int) (err error)
  162. //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
  163. //sysnb Setresuid(ruid int, euid int, suid int) (err error)
  164. //sysnb Setrlimit(which int, lim *Rlimit) (err error)
  165. //sysnb Setsid() (pid int, err error)
  166. //sysnb Settimeofday(tp *Timeval) (err error)
  167. //sysnb Setuid(uid int) (err error)
  168. //sys Stat(path string, stat *Stat_t) (err error)
  169. //sys Statfs(path string, stat *Statfs_t) (err error)
  170. //sys Symlink(path string, link string) (err error)
  171. //sys Sync() (err error)
  172. //sys Truncate(path string, length int64) (err error)
  173. //sys Umask(newmask int) (oldmask int)
  174. //sys Unlink(path string) (err error)
  175. //sys Unmount(path string, flags int) (err error)
  176. //sys write(fd int, p []byte) (n int, err error)
  177. //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
  178. //sys munmap(addr uintptr, length uintptr) (err error)
  179. //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
  180. //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
  181. /*
  182. * Unimplemented
  183. */
  184. // __getcwd
  185. // __semctl
  186. // __syscall
  187. // __sysctl
  188. // adjfreq
  189. // break
  190. // clock_getres
  191. // clock_gettime
  192. // clock_settime
  193. // closefrom
  194. // execve
  195. // faccessat
  196. // fchmodat
  197. // fchownat
  198. // fcntl
  199. // fhopen
  200. // fhstat
  201. // fhstatfs
  202. // fork
  203. // fstatat
  204. // futimens
  205. // getfh
  206. // getgid
  207. // getitimer
  208. // getlogin
  209. // getresgid
  210. // getresuid
  211. // getrtable
  212. // getthrid
  213. // ioctl
  214. // ktrace
  215. // lfs_bmapv
  216. // lfs_markv
  217. // lfs_segclean
  218. // lfs_segwait
  219. // linkat
  220. // mincore
  221. // minherit
  222. // mkdirat
  223. // mkfifoat
  224. // mknodat
  225. // mount
  226. // mquery
  227. // msgctl
  228. // msgget
  229. // msgrcv
  230. // msgsnd
  231. // nfssvc
  232. // nnpfspioctl
  233. // openat
  234. // poll
  235. // preadv
  236. // profil
  237. // pwritev
  238. // quotactl
  239. // readlinkat
  240. // readv
  241. // reboot
  242. // renameat
  243. // rfork
  244. // sched_yield
  245. // semget
  246. // semop
  247. // setgroups
  248. // setitimer
  249. // setrtable
  250. // setsockopt
  251. // shmat
  252. // shmctl
  253. // shmdt
  254. // shmget
  255. // sigaction
  256. // sigaltstack
  257. // sigpending
  258. // sigprocmask
  259. // sigreturn
  260. // sigsuspend
  261. // symlinkat
  262. // sysarch
  263. // syscall
  264. // threxit
  265. // thrsigdivert
  266. // thrsleep
  267. // thrwakeup
  268. // unlinkat
  269. // utimensat
  270. // vfork
  271. // writev