gccgo_c.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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
  19. 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)
  20. {
  21. struct ret r;
  22. errno = 0;
  23. r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  24. r.err = errno;
  25. return r;
  26. }
  27. uintptr_t
  28. 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)
  29. {
  30. return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  31. }