os_specific_linux.odin 564 B

123456789101112131415161718192021222324
  1. //+private
  2. package runtime
  3. import "base:intrinsics"
  4. _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
  5. when ODIN_ARCH == .amd64 {
  6. SYS_write :: uintptr(1)
  7. } else when ODIN_ARCH == .arm64 {
  8. SYS_write :: uintptr(64)
  9. } else when ODIN_ARCH == .i386 {
  10. SYS_write :: uintptr(4)
  11. } else when ODIN_ARCH == .arm32 {
  12. SYS_write :: uintptr(4)
  13. }
  14. stderr :: 2
  15. ret := int(intrinsics.syscall(SYS_write, uintptr(stderr), uintptr(raw_data(data)), uintptr(len(data))))
  16. if ret < 0 && ret > -4096 {
  17. return 0, _OS_Errno(-ret)
  18. }
  19. return ret, 0
  20. }