kopia lustrzana https://github.com/micropython/micropython-lib
_libc: Helper FFI module to find and load proper libc for the system.
It's needed because different LIBC implementation use different shared library names, so this module abstracts operation of finding the correct one. Default search order: 1. libc.so. This is usually doesn't exist, but user can create such symlink, and it will be used fast. 2. libc.so.0, as used by current uClibc versions. 3. libc.so.6, as used by current Glibc versions. uClibc is tried first because system where it is used are usually underpowered to do array of attempts. User can also override default search names by calling _libc.set_names(), (which should be called before importing any other modules).pull/118/head^2
rodzic
41e738f1b0
commit
a6dee730f3
|
@ -0,0 +1,24 @@
|
|||
import ffi
|
||||
|
||||
|
||||
_h = None
|
||||
|
||||
names = ('libc.so', 'libc.so.0', 'libc.so.6')
|
||||
|
||||
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
|
|
@ -0,0 +1,7 @@
|
|||
dist_name = libc
|
||||
srctype = micropython-lib
|
||||
type = module
|
||||
version = 0.1
|
||||
author = Paul Sokolovsky
|
||||
desc = MicroPython FFI helper module
|
||||
long_desc = MicroPython FFI helper module to interface with underlying libc
|
|
@ -0,0 +1,18 @@
|
|||
import sys
|
||||
# Remove current dir from sys.path, otherwise setuptools will peek up our
|
||||
# module instead of system.
|
||||
sys.path.pop(0)
|
||||
from setuptools import setup
|
||||
|
||||
|
||||
setup(name='micropython-libc',
|
||||
version='0.1',
|
||||
description='MicroPython FFI helper module',
|
||||
long_description='MicroPython FFI helper module to interface with underlying libc',
|
||||
url='https://github.com/micropython/micropython/issues/405',
|
||||
author='Paul Sokolovsky',
|
||||
author_email='micro-python@googlegroups.com',
|
||||
maintainer='MicroPython Developers',
|
||||
maintainer_email='micro-python@googlegroups.com',
|
||||
license='MIT',
|
||||
py_modules=['_libc'])
|
Ładowanie…
Reference in New Issue