Browse Source

make some types and procs match the c apis

procs:
| type          | old  | new (matching c api)|
| ---           | ---- | ------------------- |
| kern_return_t | u64  | c.int               |
| thread_t      | u64  | mach_port_t         |
| task_t        | u64  | mach_port_t         |
| semaphore_t   | u64  | mach_port_t         |

for mach_task_self(), return mach_port_t instead of task_t

for semaphore_signal_thread(), accept a thread_t instead of a thread_act_t
Beau McCartney 10 months ago
parent
commit
67252ff415
1 changed files with 6 additions and 11 deletions
  1. 6 11
      core/sys/darwin/mach_darwin.odin

+ 6 - 11
core/sys/darwin/mach_darwin.odin

@@ -4,20 +4,15 @@ foreign import mach "system:System.framework"
 
 
 import "core:c"
 import "core:c"
 
 
-// NOTE(tetra): Unclear whether these should be aligned 16 or not.
-// However all other sync primitives are aligned for robustness.
-// I cannot currently align these though.
-// See core/sys/unix/pthread_linux.odin/pthread_t.
-task_t :: distinct u64
-semaphore_t :: distinct u64
-
-kern_return_t :: distinct u64
-thread_act_t :: distinct u64
+kern_return_t :: distinct c.int
 
 
 mach_port_t :: distinct c.uint
 mach_port_t :: distinct c.uint
 vm_map_t :: mach_port_t
 vm_map_t :: mach_port_t
 mem_entry_name_port_t :: mach_port_t
 mem_entry_name_port_t :: mach_port_t
 ipc_space_t :: mach_port_t
 ipc_space_t :: mach_port_t
+thread_t :: mach_port_t
+task_t :: mach_port_t
+semaphore_t :: mach_port_t
 
 
 vm_size_t :: distinct c.uintptr_t
 vm_size_t :: distinct c.uintptr_t
 
 
@@ -34,14 +29,14 @@ mach_port_name_t :: distinct c.uint
 
 
 @(default_calling_convention="c")
 @(default_calling_convention="c")
 foreign mach {
 foreign mach {
-	mach_task_self :: proc() -> task_t ---
+	mach_task_self :: proc() -> mach_port_t ---
 
 
 	semaphore_create :: proc(task: task_t, semaphore: ^semaphore_t, policy, value: c.int) -> kern_return_t ---
 	semaphore_create :: proc(task: task_t, semaphore: ^semaphore_t, policy, value: c.int) -> kern_return_t ---
 	semaphore_destroy :: proc(task: task_t, semaphore: semaphore_t) -> kern_return_t ---
 	semaphore_destroy :: proc(task: task_t, semaphore: semaphore_t) -> kern_return_t ---
 
 
 	semaphore_signal :: proc(semaphore: semaphore_t) -> kern_return_t ---
 	semaphore_signal :: proc(semaphore: semaphore_t) -> kern_return_t ---
 	semaphore_signal_all :: proc(semaphore: semaphore_t) -> kern_return_t ---
 	semaphore_signal_all :: proc(semaphore: semaphore_t) -> kern_return_t ---
-	semaphore_signal_thread :: proc(semaphore: semaphore_t, thread: thread_act_t) -> kern_return_t ---
+	semaphore_signal_thread :: proc(semaphore: semaphore_t, thread: thread_t) -> kern_return_t ---
 	
 	
 	semaphore_wait :: proc(semaphore: semaphore_t) -> kern_return_t ---
 	semaphore_wait :: proc(semaphore: semaphore_t) -> kern_return_t ---