os_specific_linux.odin 627 B

1234567891011121314151617181920212223242526
  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. } else when ODIN_ARCH == .riscv64 {
  14. SYS_write :: uintptr(64)
  15. }
  16. stderr :: 2
  17. ret := int(intrinsics.syscall(SYS_write, uintptr(stderr), uintptr(raw_data(data)), uintptr(len(data))))
  18. if ret < 0 && ret > -4096 {
  19. return 0, _OS_Errno(-ret)
  20. }
  21. return ret, 0
  22. }