diff --git a/_libc/_libc.py b/_libc/_libc.py index 0033d4c3..a0890445 100644 --- a/_libc/_libc.py +++ b/_libc/_libc.py @@ -1,4 +1,5 @@ import ffi +import sys _h = None @@ -22,3 +23,12 @@ def get(): 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 diff --git a/select/metadata.txt b/select/metadata.txt index d5a2c299..fac372f6 100644 --- a/select/metadata.txt +++ b/select/metadata.txt @@ -1,5 +1,5 @@ srctype = micropython-lib type = module -version = 0.0.8 +version = 0.1 author = Paul Sokolovsky depends = os, libc diff --git a/select/select.py b/select/select.py index 63a13b92..b1dfdfc7 100644 --- a/select/select.py +++ b/select/select.py @@ -26,7 +26,11 @@ EPOLL_CTL_MOD = 3 # On x86, uint64_t is 4-byte aligned, on many other platforms - 8-byte. # Until uctypes module can assign native struct offset, use dirty hack # below. -if struct.calcsize("IQ") == 12: +# TODO: Get rid of all this dirtiness, move it on C side +if _libc.bitness > 32: + # On x86_64, epoll_event is packed struct + epoll_event = "