gccgo_c.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2015 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 gccgo
  5. // +build !aix
  6. #include <errno.h>
  7. #include <stdint.h>
  8. #include <unistd.h>
  9. #define _STRINGIFY2_(x) #x
  10. #define _STRINGIFY_(x) _STRINGIFY2_(x)
  11. #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
  12. // Call syscall from C code because the gccgo support for calling from
  13. // Go to C does not support varargs functions.
  14. struct ret {
  15. uintptr_t r;
  16. uintptr_t err;
  17. };
  18. struct ret gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
  19. __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscall");
  20. struct ret
  21. gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
  22. {
  23. struct ret r;
  24. errno = 0;
  25. r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  26. r.err = errno;
  27. return r;
  28. }
  29. uintptr_t gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
  30. __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscallNoError");
  31. uintptr_t
  32. gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
  33. {
  34. return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  35. }