Skip to content

Commit 165fbbd

Browse files
committed
select: Add yet another workaround for struct epoll_event, this time for x86_64.
So, it's now clear that dealing with this struct should be rather moved on C side.
1 parent 22da54b commit 165fbbd

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

_libc/_libc.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ffi
2+
import sys
23

34

45
_h = None
@@ -22,3 +23,12 @@ def get():
2223
def set_names(n):
2324
global names
2425
names = n
26+
27+
# Find out bitness of the platform, even if long ints are not supported
28+
# TODO: All bitness differences should be removed from micropython-lib, and
29+
# this snippet too.
30+
bitness = 1
31+
v = sys.maxsize
32+
while v:
33+
bitness += 1
34+
v >>= 1

select/metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
srctype = micropython-lib
22
type = module
3-
version = 0.0.8
3+
version = 0.1
44
author = Paul Sokolovsky
55
depends = os, libc

select/select.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
# On x86, uint64_t is 4-byte aligned, on many other platforms - 8-byte.
2727
# Until uctypes module can assign native struct offset, use dirty hack
2828
# below.
29-
if struct.calcsize("IQ") == 12:
29+
# TODO: Get rid of all this dirtiness, move it on C side
30+
if _libc.bitness > 32:
31+
# On x86_64, epoll_event is packed struct
32+
epoll_event = "<IO"
33+
elif struct.calcsize("IQ") == 12:
3034
epoll_event = "IO"
3135
else:
3236
epoll_event = "QO"

select/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
setup(name='micropython-select',
9-
version='0.0.8',
9+
version='0.1',
1010
description='select module for MicroPython',
1111
long_description="This is a module reimplemented specifically for MicroPython standard library,\nwith efficient and lean design in mind. Note that this module is likely work\nin progress and likely supports just a subset of CPython's corresponding\nmodule. Please help with the development if you are interested in this\nmodule.",
1212
url='https://github.com/micropython/micropython/issues/405',

0 commit comments

Comments
 (0)