@@ -28,8 +28,8 @@ use crate::utils::as_mut_ptr;
28
28
use core:: mem:: MaybeUninit ;
29
29
use core:: ptr:: { null, null_mut} ;
30
30
use linux_raw_sys:: general:: {
31
- membarrier_cmd, membarrier_cmd_flag, rlimit , rlimit64, PRIO_PGRP , PRIO_PROCESS , PRIO_USER ,
32
- RLIM64_INFINITY , RLIM_INFINITY ,
31
+ membarrier_cmd, membarrier_cmd_flag, rlimit64, PRIO_PGRP , PRIO_PROCESS , PRIO_USER ,
32
+ RLIM64_INFINITY ,
33
33
} ;
34
34
#[ cfg( feature = "fs" ) ]
35
35
use { crate :: backend:: conv:: ret_c_uint_infallible, crate :: fs:: Mode } ;
@@ -299,52 +299,17 @@ pub(crate) fn setpriority_process(pid: Option<Pid>, priority: i32) -> io::Result
299
299
pub ( crate ) fn getrlimit ( limit : Resource ) -> Rlimit {
300
300
let mut result = MaybeUninit :: < rlimit64 > :: uninit ( ) ;
301
301
unsafe {
302
- match ret ( syscall ! (
302
+ ret_infallible ( syscall ! (
303
303
__NR_prlimit64,
304
304
c_uint( 0 ) ,
305
305
limit,
306
306
null:: <c:: c_void>( ) ,
307
307
& mut result
308
- ) ) {
309
- Ok ( ( ) ) => rlimit_from_linux ( result. assume_init ( ) ) ,
310
- Err ( err) => {
311
- debug_assert_eq ! ( err, io:: Errno :: NOSYS ) ;
312
- getrlimit_old ( limit)
313
- }
314
- }
308
+ ) ) ;
309
+ rlimit_from_linux ( result. assume_init ( ) )
315
310
}
316
311
}
317
312
318
- /// The old 32-bit-only `getrlimit` syscall, for when we lack the new
319
- /// `prlimit64`.
320
- unsafe fn getrlimit_old ( limit : Resource ) -> Rlimit {
321
- let mut result = MaybeUninit :: < rlimit > :: uninit ( ) ;
322
-
323
- // On these platforms, `__NR_getrlimit` is called `__NR_ugetrlimit`.
324
- #[ cfg( any(
325
- target_arch = "arm" ,
326
- target_arch = "powerpc" ,
327
- target_arch = "powerpc64" ,
328
- target_arch = "x86" ,
329
- ) ) ]
330
- {
331
- ret_infallible ( syscall ! ( __NR_ugetrlimit, limit, & mut result) ) ;
332
- }
333
-
334
- // On these platforms, it's just `__NR_getrlimit`.
335
- #[ cfg( not( any(
336
- target_arch = "arm" ,
337
- target_arch = "powerpc" ,
338
- target_arch = "powerpc64" ,
339
- target_arch = "x86" ,
340
- ) ) ) ]
341
- {
342
- ret_infallible ( syscall ! ( __NR_getrlimit, limit, & mut result) ) ;
343
- }
344
-
345
- rlimit_from_linux_old ( result. assume_init ( ) )
346
- }
347
-
348
313
#[ inline]
349
314
pub ( crate ) fn setrlimit ( limit : Resource , new : Rlimit ) -> io:: Result < ( ) > {
350
315
unsafe {
@@ -357,19 +322,11 @@ pub(crate) fn setrlimit(limit: Resource, new: Rlimit) -> io::Result<()> {
357
322
null_mut:: <c:: c_void>( )
358
323
) ) {
359
324
Ok ( ( ) ) => Ok ( ( ) ) ,
360
- Err ( io:: Errno :: NOSYS ) => setrlimit_old ( limit, new) ,
361
325
Err ( err) => Err ( err) ,
362
326
}
363
327
}
364
328
}
365
329
366
- /// The old 32-bit-only `setrlimit` syscall, for when we lack the new
367
- /// `prlimit64`.
368
- unsafe fn setrlimit_old ( limit : Resource , new : Rlimit ) -> io:: Result < ( ) > {
369
- let lim = rlimit_to_linux_old ( new) ?;
370
- ret ( syscall_readonly ! ( __NR_setrlimit, limit, by_ref( & lim) ) )
371
- }
372
-
373
330
#[ inline]
374
331
pub ( crate ) fn prlimit ( pid : Option < Pid > , limit : Resource , new : Rlimit ) -> io:: Result < Rlimit > {
375
332
let lim = rlimit_to_linux ( new) ;
@@ -391,12 +348,12 @@ pub(crate) fn prlimit(pid: Option<Pid>, limit: Resource, new: Rlimit) -> io::Res
391
348
/// Convert a Rust [`Rlimit`] to a C `rlimit64`.
392
349
#[ inline]
393
350
fn rlimit_from_linux ( lim : rlimit64 ) -> Rlimit {
394
- let current = if lim. rlim_cur as u64 == RLIM64_INFINITY as u64 {
351
+ let current = if lim. rlim_cur == RLIM64_INFINITY as _ {
395
352
None
396
353
} else {
397
354
Some ( lim. rlim_cur )
398
355
} ;
399
- let maximum = if lim. rlim_max as u64 == RLIM64_INFINITY as u64 {
356
+ let maximum = if lim. rlim_max == RLIM64_INFINITY as _ {
400
357
None
401
358
} else {
402
359
Some ( lim. rlim_max )
@@ -418,36 +375,6 @@ fn rlimit_to_linux(lim: Rlimit) -> rlimit64 {
418
375
rlimit64 { rlim_cur, rlim_max }
419
376
}
420
377
421
- /// Like `rlimit_from_linux` but uses Linux's old 32-bit `rlimit`.
422
- #[ allow( clippy:: useless_conversion) ]
423
- fn rlimit_from_linux_old ( lim : rlimit ) -> Rlimit {
424
- let current = if lim. rlim_cur as u32 == RLIM_INFINITY as u32 {
425
- None
426
- } else {
427
- Some ( lim. rlim_cur . into ( ) )
428
- } ;
429
- let maximum = if lim. rlim_max as u32 == RLIM_INFINITY as u32 {
430
- None
431
- } else {
432
- Some ( lim. rlim_max . into ( ) )
433
- } ;
434
- Rlimit { current, maximum }
435
- }
436
-
437
- /// Like `rlimit_to_linux` but uses Linux's old 32-bit `rlimit`.
438
- #[ allow( clippy:: useless_conversion) ]
439
- fn rlimit_to_linux_old ( lim : Rlimit ) -> io:: Result < rlimit > {
440
- let rlim_cur = match lim. current {
441
- Some ( r) => r. try_into ( ) . map_err ( |_e| io:: Errno :: INVAL ) ?,
442
- None => RLIM_INFINITY as _ ,
443
- } ;
444
- let rlim_max = match lim. maximum {
445
- Some ( r) => r. try_into ( ) . map_err ( |_e| io:: Errno :: INVAL ) ?,
446
- None => RLIM_INFINITY as _ ,
447
- } ;
448
- Ok ( rlimit { rlim_cur, rlim_max } )
449
- }
450
-
451
378
#[ inline]
452
379
pub ( crate ) fn wait ( waitopts : WaitOptions ) -> io:: Result < Option < ( Pid , WaitStatus ) > > {
453
380
_waitpid ( !0 , waitopts)
0 commit comments