platform.go 838 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package internal
  2. import (
  3. "runtime"
  4. )
  5. // PlatformPrefix returns the platform-dependent syscall wrapper prefix used by
  6. // the linux kernel.
  7. //
  8. // Based on https://github.com/golang/go/blob/master/src/go/build/syslist.go
  9. // and https://github.com/libbpf/libbpf/blob/master/src/libbpf.c#L10047
  10. func PlatformPrefix() string {
  11. switch runtime.GOARCH {
  12. case "386":
  13. return "__ia32_"
  14. case "amd64", "amd64p32":
  15. return "__x64_"
  16. case "arm", "armbe":
  17. return "__arm_"
  18. case "arm64", "arm64be":
  19. return "__arm64_"
  20. case "mips", "mipsle", "mips64", "mips64le", "mips64p32", "mips64p32le":
  21. return "__mips_"
  22. case "s390":
  23. return "__s390_"
  24. case "s390x":
  25. return "__s390x_"
  26. case "riscv", "riscv64":
  27. return "__riscv_"
  28. case "ppc":
  29. return "__powerpc_"
  30. case "ppc64", "ppc64le":
  31. return "__powerpc64_"
  32. default:
  33. return ""
  34. }
  35. }