File tree 1 file changed +13
-6
lines changed
1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change 1
1
use super :: mystd:: env;
2
2
use super :: mystd:: ffi:: OsStr ;
3
- use super :: mystd:: io:: Error ;
4
3
use super :: mystd:: os:: unix:: prelude:: * ;
5
4
use super :: xcoff;
6
5
use super :: { Library , LibrarySegment } ;
7
6
use alloc:: borrow:: ToOwned ;
8
7
use alloc:: vec;
9
8
use alloc:: vec:: Vec ;
10
- use core:: ffi:: CStr ;
9
+ use core:: ffi:: { c_int , CStr } ;
11
10
use core:: mem;
12
11
13
12
const EXE_IMAGE_BASE : u64 = 0x100000000 ;
14
13
14
+ extern "C" {
15
+ #[ link_name = "_Errno" ]
16
+ fn errno_location ( ) -> * mut c_int ;
17
+ }
18
+
19
+ fn errno ( ) -> i32 {
20
+ unsafe { ( * errno_location ( ) ) as i32 }
21
+ }
22
+
15
23
/// On AIX, we use `loadquery` with `L_GETINFO` flag to query libraries mmapped.
16
24
/// See https://www.ibm.com/docs/en/aix/7.2?topic=l-loadquery-subroutine for
17
25
/// detailed information of `loadquery`.
@@ -28,15 +36,14 @@ pub(super) fn native_libraries() -> Vec<Library> {
28
36
{
29
37
break ;
30
38
} else {
31
- match Error :: last_os_error ( ) . raw_os_error ( ) {
32
- Some ( libc:: ENOMEM ) => {
39
+ match errno ( ) {
40
+ libc:: ENOMEM => {
33
41
buffer. resize ( buffer. len ( ) * 2 , mem:: zeroed :: < libc:: ld_info > ( ) ) ;
34
42
}
35
- Some ( _ ) => {
43
+ _ => {
36
44
// If other error occurs, return empty libraries.
37
45
return Vec :: new ( ) ;
38
46
}
39
- _ => unreachable ! ( ) ,
40
47
}
41
48
}
42
49
}
You can’t perform that action at this time.
0 commit comments