syscall_funcs.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2009 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. // +build darwin dragonfly freebsd hurd linux netbsd openbsd solaris
  5. package syscall
  6. //extern __go_syscall6
  7. func syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) uintptr
  8. // Do a system call. We look at the size of uintptr to see how to pass
  9. // the arguments, so that we don't pass a 64-bit value when the function
  10. // expects a 32-bit one.
  11. func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
  12. Entersyscall()
  13. SetErrno(0)
  14. r := syscall6(trap, a1, a2, a3, 0, 0, 0)
  15. err = GetErrno()
  16. Exitsyscall()
  17. return r, 0, err
  18. }
  19. func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
  20. Entersyscall()
  21. SetErrno(0)
  22. r := syscall6(trap, a1, a2, a3, a4, a5, a6)
  23. err = GetErrno()
  24. Exitsyscall()
  25. return r, 0, err
  26. }
  27. func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
  28. SetErrno(0)
  29. r := syscall6(trap, a1, a2, a3, 0, 0, 0)
  30. err = GetErrno()
  31. return r, 0, err
  32. }
  33. func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
  34. SetErrno(0)
  35. r := syscall6(trap, a1, a2, a3, a4, a5, a6)
  36. err = GetErrno()
  37. return r, 0, err
  38. }