forked from micropython/micropython-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_libc.py
More file actions
36 lines (27 loc) · 613 Bytes
/
_libc.py
File metadata and controls
36 lines (27 loc) · 613 Bytes
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
import ffi
import sys
_h = None
names = ("libc.so", "libc.so.0", "libc.so.6", "libc.so.7", "libc.dylib")
def get():
global _h
if _h:
return _h
err = None
for n in names:
try:
_h = ffi.open(n)
return _h
except OSError as e:
err = e
raise err
def set_names(n):
global names
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
while v:
bitness += 1
v >>= 1