File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -494,4 +494,10 @@ extern {
494
494
flags : :: c_int ) -> :: c_int ;
495
495
pub fn eventfd ( init : :: c_uint , flags : :: c_int ) -> :: c_int ;
496
496
pub fn ptrace ( request : :: c_uint , ...) -> :: c_long ;
497
+ pub fn pthread_attr_getaffinity_np ( attr : * const :: pthread_attr_t ,
498
+ cpusetsize : :: size_t ,
499
+ cpuset : * mut :: cpu_set_t ) -> :: c_int ;
500
+ pub fn pthread_attr_setaffinity_np ( attr : * mut :: pthread_attr_t ,
501
+ cpusetsize : :: size_t ,
502
+ cpuset : * const :: cpu_set_t ) -> :: c_int ;
497
503
}
Original file line number Diff line number Diff line change 1
1
//! Linux-specific definitions for linux-like values
2
2
3
+ use dox:: mem;
4
+
3
5
pub type useconds_t = u32 ;
4
6
pub type dev_t = u64 ;
5
7
pub type socklen_t = u32 ;
@@ -185,6 +187,31 @@ s! {
185
187
}
186
188
}
187
189
190
+ f ! {
191
+ pub fn CPU_ZERO ( cpuset: & mut cpu_set_t) -> ( ) {
192
+ for slot in cpuset. bits. iter_mut( ) {
193
+ * slot = 0 ;
194
+ }
195
+ }
196
+
197
+ pub fn CPU_SET ( cpu: usize , cpuset: & mut cpu_set_t) -> ( ) {
198
+ let size = mem:: size_of_val( & cpuset. bits[ 0 ] ) ;
199
+ let ( idx, offset) = ( cpu / size, cpu % size) ;
200
+ cpuset. bits[ idx] |= 1 << offset;
201
+ ( )
202
+ }
203
+
204
+ pub fn CPU_ISSET ( cpu: usize , cpuset: & cpu_set_t) -> bool {
205
+ let size = mem:: size_of_val( & cpuset. bits[ 0 ] ) ;
206
+ let ( idx, offset) = ( cpu / size, cpu % size) ;
207
+ 0 != ( cpuset. bits[ idx] & ( 1 << offset) )
208
+ }
209
+
210
+ pub fn CPU_EQUAL ( set1: & cpu_set_t, set2: & cpu_set_t) -> bool {
211
+ set1. bits == set2. bits
212
+ }
213
+ }
214
+
188
215
pub const FILENAME_MAX : :: c_uint = 4096 ;
189
216
pub const L_tmpnam : :: c_uint = 20 ;
190
217
pub const _PC_NAME_MAX: :: c_int = 3 ;
Original file line number Diff line number Diff line change @@ -434,6 +434,12 @@ extern {
434
434
flags : :: c_int ) -> :: c_int ;
435
435
pub fn eventfd ( init : :: c_uint , flags : :: c_int ) -> :: c_int ;
436
436
pub fn ptrace ( request : :: c_uint , ...) -> :: c_long ;
437
+ pub fn pthread_attr_getaffinity_np ( attr : * const :: pthread_attr_t ,
438
+ cpusetsize : :: size_t ,
439
+ cpuset : * mut :: cpu_set_t ) -> :: c_int ;
440
+ pub fn pthread_attr_setaffinity_np ( attr : * mut :: pthread_attr_t ,
441
+ cpusetsize : :: size_t ,
442
+ cpuset : * const :: cpu_set_t ) -> :: c_int ;
437
443
}
438
444
439
445
cfg_if ! {
You can’t perform that action at this time.
0 commit comments