- Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy path_libc.py
36 lines (27 loc) · 600 Bytes
/
_libc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
importffi
importsys
_h=None
names= ("libc.so", "libc.so.0", "libc.so.6", "libc.dylib")
defget():
global_h
if_h:
return_h
err=None
forninnames:
try:
_h=ffi.open(n)
return_h
exceptOSErrorase:
err=e
raiseerr
defset_names(n):
globalnames
names=n
# Find out bitness of the platform, even if long ints are not supported
# TODO: All bitness differences should be removed from micropython-lib, and
# this snippet too.
bitness=1
v=sys.maxsize
whilev:
bitness+=1
v>>=1