@@ -14,6 +14,9 @@ pub type key_t = ::c_long;
14
14
pub type msglen_t = :: c_ulong ;
15
15
pub type msgqnum_t = :: c_ulong ;
16
16
17
+ pub type cpulevel_t = :: c_int ;
18
+ pub type cpuwhich_t = :: c_int ;
19
+
17
20
pub type mqd_t = * mut :: c_void ;
18
21
pub type posix_spawnattr_t = * mut :: c_void ;
19
22
pub type posix_spawn_file_actions_t = * mut :: c_void ;
@@ -121,6 +124,13 @@ s! {
121
124
pub pve_fsid: u32 ,
122
125
pub pve_path: * mut :: c_char,
123
126
}
127
+
128
+ pub struct cpuset_t {
129
+ #[ cfg( target_pointer_width = "64" ) ]
130
+ __bits: [ :: c_long; 4 ] ,
131
+ #[ cfg( target_pointer_width = "32" ) ]
132
+ __bits: [ :: c_long; 8 ] ,
133
+ }
124
134
}
125
135
126
136
s_no_extra_traits ! {
@@ -1265,6 +1275,38 @@ f! {
1265
1275
pub fn uname( buf: * mut :: utsname) -> :: c_int {
1266
1276
__xuname( 256 , buf as * mut :: c_void)
1267
1277
}
1278
+
1279
+ pub fn CPU_ZERO ( cpuset: & mut cpuset_t) -> ( ) {
1280
+ for slot in cpuset. __bits. iter_mut( ) {
1281
+ * slot = 0 ;
1282
+ }
1283
+ }
1284
+
1285
+ pub fn CPU_FILL ( cpuset: & mut cpuset_t) -> ( ) {
1286
+ for slot in cpuset. __bits. iter_mut( ) {
1287
+ * slot = !0 ;
1288
+ }
1289
+ }
1290
+
1291
+ pub fn CPU_SET ( cpu: usize , cpuset: & mut cpuset_t) -> ( ) {
1292
+ let bitset_bits = :: mem:: size_of:: <:: c_long>( ) ;
1293
+ let ( idx, offset) = ( cpu / bitset_bits, cpu % bitset_bits) ;
1294
+ cpuset. __bits[ idx] |= 1 << offset;
1295
+ ( )
1296
+ }
1297
+
1298
+ pub fn CPU_CLR ( cpu: usize , cpuset: & mut cpuset_t) -> ( ) {
1299
+ let bitset_bits = :: mem:: size_of:: <:: c_long>( ) ;
1300
+ let ( idx, offset) = ( cpu / bitset_bits, cpu % bitset_bits) ;
1301
+ cpuset. __bits[ idx] &= !( 1 << offset) ;
1302
+ ( )
1303
+ }
1304
+
1305
+ pub fn CPU_ISSET ( cpu: usize , cpuset: & mut cpuset_t) -> bool {
1306
+ let bitset_bits = :: mem:: size_of:: <:: c_long>( ) ;
1307
+ let ( idx, offset) = ( cpu / bitset_bits, cpu % bitset_bits) ;
1308
+ 0 != cpuset. __bits[ idx] & ( 1 << offset)
1309
+ }
1268
1310
}
1269
1311
1270
1312
safe_f ! {
@@ -1527,6 +1569,20 @@ extern "C" {
1527
1569
) -> * mut :: c_void ;
1528
1570
1529
1571
pub fn nmount ( iov : * mut :: iovec , niov : :: c_uint , flags : :: c_int ) -> :: c_int ;
1572
+ pub fn cpuset_getaffinity (
1573
+ level : cpulevel_t ,
1574
+ which : cpuwhich_t ,
1575
+ id : :: id_t ,
1576
+ setsize : :: size_t ,
1577
+ mask : * mut cpuset_t ,
1578
+ ) -> :: c_int ;
1579
+ pub fn cpuset_setaffinity (
1580
+ level : cpulevel_t ,
1581
+ which : cpuwhich_t ,
1582
+ id : :: id_t ,
1583
+ setsize : :: size_t ,
1584
+ mask : * const cpuset_t ,
1585
+ ) -> :: c_int ;
1530
1586
}
1531
1587
1532
1588
#[ link( name = "util" ) ]
0 commit comments