@@ -27,20 +27,15 @@ use crate::process::{
2727} ;
2828use core:: convert:: TryInto ;
2929use 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" ) ) ) ]
3431use linux_raw_sys:: general:: __NR_getrlimit;
35- #[ cfg( target_pointer_width = "32" ) ]
36- use linux_raw_sys:: general:: __NR_setrlimit;
3732#[ cfg( any( target_arch = "arm" , target_arch = "powerpc64" , target_arch = "x86" ) ) ]
3833use linux_raw_sys:: general:: __NR_ugetrlimit as __NR_getrlimit;
3934use linux_raw_sys:: general:: {
4035 __NR_chdir, __NR_exit_group, __NR_fchdir, __NR_getcwd, __NR_getpid, __NR_getppid,
4136 __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,
4439} ;
4540#[ cfg( not( any( target_arch = "x86" , target_arch = "sparc" , target_arch = "arm" ) ) ) ]
4641use 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
320315#[ inline]
321316pub ( crate ) fn getrlimit ( limit : Resource ) -> Rlimit {
322317 let mut result = MaybeUninit :: < linux_raw_sys:: general:: rlimit64 > :: uninit ( ) ;
323- #[ cfg( target_pointer_width = "32" ) ]
324318 unsafe {
325319 match ret ( syscall4 (
326320 nr ( __NR_prlimit64) ,
@@ -336,22 +330,10 @@ pub(crate) fn getrlimit(limit: Resource) -> Rlimit {
336330 }
337331 }
338332 }
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- }
350333}
351334
352335/// The old 32-bit-only `getrlimit` syscall, for when we lack the new
353336/// `prlimit64`.
354- #[ cfg( target_pointer_width = "32" ) ]
355337unsafe fn getrlimit_old ( limit : Resource ) -> Rlimit {
356338 let mut result = MaybeUninit :: < linux_raw_sys:: general:: rlimit > :: uninit ( ) ;
357339 ret_infallible ( syscall2 (
@@ -364,7 +346,6 @@ unsafe fn getrlimit_old(limit: Resource) -> Rlimit {
364346
365347#[ inline]
366348pub ( crate ) fn setrlimit ( limit : Resource , new : Rlimit ) -> io:: Result < ( ) > {
367- #[ cfg( target_pointer_width = "32" ) ]
368349 unsafe {
369350 let lim = rlimit_to_linux ( new. clone ( ) ) ?;
370351 match ret ( syscall4 (
@@ -379,22 +360,10 @@ pub(crate) fn setrlimit(limit: Resource, new: Rlimit) -> io::Result<()> {
379360 Err ( e) => Err ( e) ,
380361 }
381362 }
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- }
393363}
394364
395365/// The old 32-bit-only `setrlimit` syscall, for when we lack the new
396366/// `prlimit64`.
397- #[ cfg( target_pointer_width = "32" ) ]
398367unsafe fn setrlimit_old ( limit : Resource , new : Rlimit ) -> io:: Result < ( ) > {
399368 let lim = rlimit_to_linux_old ( new) ?;
400369 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>
449418}
450419
451420/// Like `rlimit_from_linux` but uses Linux's old 32-bit `rlimit`.
452- #[ cfg( target_pointer_width = "32" ) ]
453421fn rlimit_from_linux_old ( lim : linux_raw_sys:: general:: rlimit ) -> Rlimit {
454422 let current = if lim. rlim_cur == linux_raw_sys:: general:: RLIM_INFINITY as _ {
455423 None
@@ -465,7 +433,6 @@ fn rlimit_from_linux_old(lim: linux_raw_sys::general::rlimit) -> Rlimit {
465433}
466434
467435/// Like `rlimit_to_linux` but uses Linux's old 32-bit `rlimit`.
468- #[ cfg( target_pointer_width = "32" ) ]
469436fn rlimit_to_linux_old ( lim : Rlimit ) -> io:: Result < linux_raw_sys:: general:: rlimit > {
470437 let rlim_cur = match lim. current {
471438 Some ( r) => r. try_into ( ) . map_err ( |_| io:: Error :: INVAL ) ?,
0 commit comments