File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -709,6 +709,28 @@ pub(crate) fn sched_getcpu() -> usize {
709709 r as usize
710710}
711711
712+ #[ cfg( linux_kernel) ]
713+ #[ inline]
714+ pub ( crate ) fn getcpu ( ) -> ( usize , usize ) {
715+ let ( mut cpu, mut node) : ( core:: mem:: MaybeUninit < u32 > , core:: mem:: MaybeUninit < u32 > ) = (
716+ core:: mem:: MaybeUninit :: uninit ( ) ,
717+ core:: mem:: MaybeUninit :: uninit ( ) ,
718+ ) ;
719+
720+ let r = unsafe {
721+ libc:: syscall (
722+ libc:: SYS_getcpu ,
723+ cpu. as_mut_ptr ( ) ,
724+ node. as_mut_ptr ( ) ,
725+ core:: ptr:: null :: < libc:: c_void > ( ) ,
726+ )
727+ } ;
728+
729+ debug_assert ! ( r >= 0 ) ;
730+
731+ unsafe { ( cpu. assume_init ( ) as usize , node. assume_init ( ) as usize ) }
732+ }
733+
712734#[ cfg( any( freebsdlike, linux_kernel, target_os = "fuchsia" ) ) ]
713735#[ inline]
714736pub ( crate ) fn sched_getaffinity ( pid : Option < Pid > , cpuset : & mut RawCpuSet ) -> io:: Result < ( ) > {
You can’t perform that action at this time.
0 commit comments