mach_darwin.odin 1020 B

1234567891011121314151617181920212223242526272829
  1. package darwin
  2. foreign import pthread "System.framework"
  3. import "core:c"
  4. // NOTE(tetra): Unclear whether these should be aligned 16 or not.
  5. // However all other sync primitives are aligned for robustness.
  6. // I cannot currently align these though.
  7. // See core/sys/unix/pthread_linux.odin/pthread_t.
  8. task_t :: distinct u64
  9. semaphore_t :: distinct u64
  10. kern_return_t :: distinct u64
  11. thread_act_t :: distinct u64
  12. @(default_calling_convention="c")
  13. foreign pthread {
  14. mach_task_self :: proc() -> task_t ---
  15. semaphore_create :: proc(task: task_t, semaphore: ^semaphore_t, policy, value: c.int) -> kern_return_t ---
  16. semaphore_destroy :: proc(task: task_t, semaphore: semaphore_t) -> kern_return_t ---
  17. semaphore_signal :: proc(semaphore: semaphore_t) -> kern_return_t ---
  18. semaphore_signal_all :: proc(semaphore: semaphore_t) -> kern_return_t ---
  19. semaphore_signal_thread :: proc(semaphore: semaphore_t, thread: thread_act_t) -> kern_return_t ---
  20. semaphore_wait :: proc(semaphore: semaphore_t) -> kern_return_t ---
  21. }