@@ -73,25 +73,6 @@ impl CpuSet {
73
73
}
74
74
}
75
75
76
- mod ffi {
77
- use libc:: { c_void, c_int} ;
78
-
79
- pub type CloneCb = extern "C" fn ( data : * const super :: CloneCb ) -> c_int ;
80
-
81
- // We cannot give a proper #[repr(C)] to super::CloneCb
82
- #[ allow( improper_ctypes) ]
83
- extern "C" {
84
- // create a child process
85
- // doc: http://man7.org/linux/man-pages/man2/clone.2.html
86
- pub fn clone ( cb : * const CloneCb ,
87
- child_stack : * mut c_void ,
88
- flags : c_int ,
89
- arg : * mut super :: CloneCb ,
90
- ...)
91
- -> c_int ;
92
- }
93
- }
94
-
95
76
pub fn sched_setaffinity ( pid : Pid , cpuset : & CpuSet ) -> Result < ( ) > {
96
77
let res = unsafe {
97
78
libc:: sched_setaffinity ( pid. into ( ) ,
@@ -116,10 +97,10 @@ pub fn clone(mut cb: CloneCb,
116
97
let combined = flags. bits ( ) | signal. unwrap_or ( 0 ) ;
117
98
let ptr = stack. as_mut_ptr ( ) . offset ( stack. len ( ) as isize ) ;
118
99
let ptr_aligned = ptr. offset ( ( ptr as usize % 16 ) as isize * -1 ) ;
119
- ffi :: clone ( mem:: transmute ( callback as extern "C" fn ( * mut Box < :: std:: ops:: FnMut ( ) -> isize > ) -> i32 ) ,
100
+ libc :: clone ( mem:: transmute ( callback as extern "C" fn ( * mut Box < :: std:: ops:: FnMut ( ) -> isize > ) -> i32 ) ,
120
101
ptr_aligned as * mut c_void ,
121
102
combined,
122
- & mut cb)
103
+ & mut cb as * mut _ as * mut c_void )
123
104
} ;
124
105
125
106
Errno :: result ( res) . map ( Pid :: from_raw)
0 commit comments