@@ -27,20 +27,15 @@ use crate::process::{
27
27
} ;
28
28
use core:: convert:: TryInto ;
29
29
use core:: mem:: MaybeUninit ;
30
- #[ cfg( all(
31
- not( any( target_arch = "arm" , target_arch = "powerpc64" , target_arch = "x86" ) ) ,
32
- target_pointer_width = "32"
33
- ) ) ]
30
+ #[ cfg( not( any( target_arch = "arm" , target_arch = "powerpc64" , target_arch = "x86" ) ) ) ]
34
31
use linux_raw_sys:: general:: __NR_getrlimit;
35
- #[ cfg( target_pointer_width = "32" ) ]
36
- use linux_raw_sys:: general:: __NR_setrlimit;
37
32
#[ cfg( any( target_arch = "arm" , target_arch = "powerpc64" , target_arch = "x86" ) ) ]
38
33
use linux_raw_sys:: general:: __NR_ugetrlimit as __NR_getrlimit;
39
34
use linux_raw_sys:: general:: {
40
35
__NR_chdir, __NR_exit_group, __NR_fchdir, __NR_getcwd, __NR_getpid, __NR_getppid,
41
36
__NR_getpriority, __NR_kill, __NR_membarrier, __NR_prlimit64, __NR_sched_getaffinity,
42
- __NR_sched_setaffinity, __NR_sched_yield, __NR_setpriority, __NR_setsid , __NR_uname ,
43
- __NR_wait4, __kernel_gid_t, __kernel_pid_t, __kernel_uid_t,
37
+ __NR_sched_setaffinity, __NR_sched_yield, __NR_setpriority, __NR_setrlimit , __NR_setsid ,
38
+ __NR_uname , __NR_wait4, __kernel_gid_t, __kernel_pid_t, __kernel_uid_t,
44
39
} ;
45
40
#[ cfg( not( any( target_arch = "x86" , target_arch = "sparc" , target_arch = "arm" ) ) ) ]
46
41
use linux_raw_sys:: general:: { __NR_getegid, __NR_geteuid, __NR_getgid, __NR_getuid} ;
@@ -320,7 +315,6 @@ pub(crate) fn setpriority_process(pid: Option<Pid>, priority: i32) -> io::Result
320
315
#[ inline]
321
316
pub ( crate ) fn getrlimit ( limit : Resource ) -> Rlimit {
322
317
let mut result = MaybeUninit :: < linux_raw_sys:: general:: rlimit64 > :: uninit ( ) ;
323
- #[ cfg( target_pointer_width = "32" ) ]
324
318
unsafe {
325
319
match ret ( syscall4 (
326
320
nr ( __NR_prlimit64) ,
@@ -336,22 +330,10 @@ pub(crate) fn getrlimit(limit: Resource) -> Rlimit {
336
330
}
337
331
}
338
332
}
339
- #[ cfg( target_pointer_width = "64" ) ]
340
- unsafe {
341
- ret_infallible ( syscall4 (
342
- nr ( __NR_prlimit64) ,
343
- c_uint ( 0 ) ,
344
- resource ( limit) ,
345
- const_void_star ( core:: ptr:: null ( ) ) ,
346
- out ( & mut result) ,
347
- ) ) ;
348
- rlimit_from_linux ( result. assume_init ( ) )
349
- }
350
333
}
351
334
352
335
/// The old 32-bit-only `getrlimit` syscall, for when we lack the new
353
336
/// `prlimit64`.
354
- #[ cfg( target_pointer_width = "32" ) ]
355
337
unsafe fn getrlimit_old ( limit : Resource ) -> Rlimit {
356
338
let mut result = MaybeUninit :: < linux_raw_sys:: general:: rlimit > :: uninit ( ) ;
357
339
ret_infallible ( syscall2 (
@@ -364,7 +346,6 @@ unsafe fn getrlimit_old(limit: Resource) -> Rlimit {
364
346
365
347
#[ inline]
366
348
pub ( crate ) fn setrlimit ( limit : Resource , new : Rlimit ) -> io:: Result < ( ) > {
367
- #[ cfg( target_pointer_width = "32" ) ]
368
349
unsafe {
369
350
let lim = rlimit_to_linux ( new. clone ( ) ) ?;
370
351
match ret ( syscall4 (
@@ -379,22 +360,10 @@ pub(crate) fn setrlimit(limit: Resource, new: Rlimit) -> io::Result<()> {
379
360
Err ( e) => Err ( e) ,
380
361
}
381
362
}
382
- #[ cfg( target_pointer_width = "64" ) ]
383
- unsafe {
384
- let lim = rlimit_to_linux ( new) ?;
385
- ret ( syscall4 (
386
- nr ( __NR_prlimit64) ,
387
- c_uint ( 0 ) ,
388
- resource ( limit) ,
389
- by_ref ( & lim) ,
390
- void_star ( core:: ptr:: null_mut ( ) ) ,
391
- ) )
392
- }
393
363
}
394
364
395
365
/// The old 32-bit-only `setrlimit` syscall, for when we lack the new
396
366
/// `prlimit64`.
397
- #[ cfg( target_pointer_width = "32" ) ]
398
367
unsafe fn setrlimit_old ( limit : Resource , new : Rlimit ) -> io:: Result < ( ) > {
399
368
let lim = rlimit_to_linux_old ( new) ?;
400
369
ret ( syscall2 ( nr ( __NR_setrlimit) , resource ( limit) , by_ref ( & lim) ) )
@@ -449,7 +418,6 @@ fn rlimit_to_linux(lim: Rlimit) -> io::Result<linux_raw_sys::general::rlimit64>
449
418
}
450
419
451
420
/// Like `rlimit_from_linux` but uses Linux's old 32-bit `rlimit`.
452
- #[ cfg( target_pointer_width = "32" ) ]
453
421
fn rlimit_from_linux_old ( lim : linux_raw_sys:: general:: rlimit ) -> Rlimit {
454
422
let current = if lim. rlim_cur == linux_raw_sys:: general:: RLIM_INFINITY as _ {
455
423
None
@@ -465,7 +433,6 @@ fn rlimit_from_linux_old(lim: linux_raw_sys::general::rlimit) -> Rlimit {
465
433
}
466
434
467
435
/// Like `rlimit_to_linux` but uses Linux's old 32-bit `rlimit`.
468
- #[ cfg( target_pointer_width = "32" ) ]
469
436
fn rlimit_to_linux_old ( lim : Rlimit ) -> io:: Result < linux_raw_sys:: general:: rlimit > {
470
437
let rlim_cur = match lim. current {
471
438
Some ( r) => r. try_into ( ) . map_err ( |_| io:: Error :: INVAL ) ?,
0 commit comments