os_specific_bsd.odin 502 B

12345678910111213141516171819202122
  1. //+build freebsd, openbsd
  2. //+private
  3. package runtime
  4. foreign import libc "system:c"
  5. @(default_calling_convention="c")
  6. foreign libc {
  7. @(link_name="write")
  8. _unix_write :: proc(fd: i32, buf: rawptr, size: int) -> int ---
  9. __error :: proc() -> ^i32 ---
  10. }
  11. _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
  12. ret := _unix_write(2, raw_data(data), len(data))
  13. if ret < len(data) {
  14. err := __error()
  15. return int(ret), _OS_Errno(err^ if err != nil else 0)
  16. }
  17. return int(ret), 0
  18. }