@@ -41,7 +41,8 @@ mod _multiprocessing {
4141 }
4242}
4343
44- #[ cfg( unix) ]
44+ // Apple platforms don't support sem_timedwait/sem_getvalue in libc crate
45+ #[ cfg( all( unix, not( target_vendor = "apple" ) ) ) ]
4546#[ pymodule]
4647mod _multiprocessing {
4748 use crate :: vm:: {
@@ -57,10 +58,6 @@ mod _multiprocessing {
5758 sync:: atomic:: { AtomicU64 , AtomicUsize , Ordering } ,
5859 time:: Duration ,
5960 } ;
60- unsafe extern "C" {
61- fn sem_getvalue ( sem : * mut sem_t , sval : * mut libc:: c_int ) -> libc:: c_int ;
62- fn sem_timedwait ( sem : * mut sem_t , abs_timeout : * const libc:: timespec ) -> libc:: c_int ;
63- }
6461
6562 const RECURSIVE_MUTEX_KIND : i32 = 0 ;
6663 const SEMAPHORE_KIND : i32 = 1 ;
@@ -381,9 +378,10 @@ mod _multiprocessing {
381378 fn wait_timeout ( & self , duration : Duration , vm : & VirtualMachine ) -> PyResult < bool > {
382379 let mut ts = current_timespec ( vm) ?;
383380 let nsec_total = ts. tv_nsec as i64 + i64:: from ( duration. subsec_nanos ( ) ) ;
381+ let extra_secs = ( nsec_total / 1_000_000_000 ) as libc:: time_t ;
384382 ts. tv_sec = ts
385383 . tv_sec
386- . saturating_add ( duration. as_secs ( ) as libc:: time_t + nsec_total / 1_000_000_000 ) ;
384+ . saturating_add ( duration. as_secs ( ) as libc:: time_t + extra_secs ) ;
387385 ts. tv_nsec = ( nsec_total % 1_000_000_000 ) as _ ;
388386 loop {
389387 let res = unsafe { libc:: sem_timedwait ( self . handle . as_ptr ( ) , & ts) } ;
@@ -480,6 +478,11 @@ mod _multiprocessing {
480478 }
481479}
482480
481+ // Apple platforms (macOS, iOS, etc.) - empty module
482+ #[ cfg( all( unix, target_vendor = "apple" ) ) ]
483+ #[ pymodule]
484+ mod _multiprocessing { }
485+
483486#[ cfg( all( not( unix) , not( windows) ) ) ]
484487#[ pymodule]
485488mod _multiprocessing { }
0 commit comments