@@ -507,28 +507,6 @@ pub fn home_dir() -> Option<PathBuf> {
507
507
fallback ( )
508
508
} ) . map ( PathBuf :: from) ;
509
509
510
- #[ cfg( not( target_os = "solaris" ) ) ]
511
- unsafe fn getpwduid_r ( me : libc:: uid_t , passwd : & mut libc:: passwd ,
512
- buf : & mut Vec < c_char > ) -> Option < ( ) > {
513
- let mut result = ptr:: null_mut ( ) ;
514
- match libc:: getpwuid_r ( me, passwd, buf. as_mut_ptr ( ) ,
515
- buf. capacity ( ) as libc:: size_t ,
516
- & mut result) {
517
- 0 if !result. is_null ( ) => Some ( ( ) ) ,
518
- _ => None
519
- }
520
- }
521
-
522
- #[ cfg( target_os = "solaris" ) ]
523
- unsafe fn getpwduid_r ( me : libc:: uid_t , passwd : & mut libc:: passwd ,
524
- buf : & mut Vec < c_char > ) -> Option < ( ) > {
525
- // getpwuid_r semantics is different on Illumos/Solaris:
526
- // http://illumos.org/man/3c/getpwuid_r
527
- let result = libc:: getpwuid_r ( me, passwd, buf. as_mut_ptr ( ) ,
528
- buf. capacity ( ) as libc:: size_t ) ;
529
- if result. is_null ( ) { None } else { Some ( ( ) ) }
530
- }
531
-
532
510
#[ cfg( any( target_os = "android" ,
533
511
target_os = "ios" ,
534
512
target_os = "nacl" ) ) ]
@@ -537,6 +515,28 @@ pub fn home_dir() -> Option<PathBuf> {
537
515
target_os = "ios" ,
538
516
target_os = "nacl" ) ) ) ]
539
517
unsafe fn fallback ( ) -> Option < OsString > {
518
+ #[ cfg( not( target_os = "solaris" ) ) ]
519
+ unsafe fn getpwduid_r ( me : libc:: uid_t , passwd : & mut libc:: passwd ,
520
+ buf : & mut Vec < c_char > ) -> Option < ( ) > {
521
+ let mut result = ptr:: null_mut ( ) ;
522
+ match libc:: getpwuid_r ( me, passwd, buf. as_mut_ptr ( ) ,
523
+ buf. capacity ( ) as libc:: size_t ,
524
+ & mut result) {
525
+ 0 if !result. is_null ( ) => Some ( ( ) ) ,
526
+ _ => None
527
+ }
528
+ }
529
+
530
+ #[ cfg( target_os = "solaris" ) ]
531
+ unsafe fn getpwduid_r ( me : libc:: uid_t , passwd : & mut libc:: passwd ,
532
+ buf : & mut Vec < c_char > ) -> Option < ( ) > {
533
+ // getpwuid_r semantics is different on Illumos/Solaris:
534
+ // http://illumos.org/man/3c/getpwuid_r
535
+ let result = libc:: getpwuid_r ( me, passwd, buf. as_mut_ptr ( ) ,
536
+ buf. capacity ( ) as libc:: size_t ) ;
537
+ if result. is_null ( ) { None } else { Some ( ( ) ) }
538
+ }
539
+
540
540
let amt = match libc:: sysconf ( libc:: _SC_GETPW_R_SIZE_MAX) {
541
541
n if n < 0 => 512 as usize ,
542
542
n => n as usize ,
0 commit comments