You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gccgo_c.c 1.5KB

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