Skip to content

Commit 05768af

Browse files
committed
add ft support
1 parent a47b5b5 commit 05768af

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/evdev/genecodes_c.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777
{
7878
PyObject* m = PyModule_Create(&moduledef);
7979
if (m == NULL) return NULL;
80+
#ifdef Py_GIL_DISABLED
81+
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
82+
#endif
8083
8184
%s
8285

src/evdev/input.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ device_read(PyObject *self, PyObject *args)
5151
// get device file descriptor (O_RDONLY|O_NONBLOCK)
5252
int fd = (int)PyLong_AsLong(PyTuple_GET_ITEM(args, 0));
5353

54-
int n = read(fd, &event, sizeof(event));
54+
int n;
55+
Py_BEGIN_ALLOW_THREADS
56+
n = read(fd, &event, sizeof(event));
57+
Py_END_ALLOW_THREADS
5558

5659
if (n < 0) {
5760
if (errno == EAGAIN) {
@@ -84,7 +87,10 @@ device_read_many(PyObject *self, PyObject *args)
8487
struct input_event event[64];
8588

8689
size_t event_size = sizeof(struct input_event);
87-
ssize_t nread = read(fd, event, event_size*64);
90+
ssize_t nread;
91+
Py_BEGIN_ALLOW_THREADS
92+
nread = read(fd, event, event_size*64);
93+
Py_END_ALLOW_THREADS
8894

8995
if (nread < 0) {
9096
PyErr_SetFromErrno(PyExc_OSError);
@@ -570,6 +576,9 @@ moduleinit(void)
570576
{
571577
PyObject* m = PyModule_Create(&moduledef);
572578
if (m == NULL) return NULL;
579+
#ifdef Py_GIL_DISABLED
580+
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
581+
#endif
573582
return m;
574583
}
575584

src/evdev/uinput.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,9 @@ moduleinit(void)
405405
{
406406
PyObject* m = PyModule_Create(&moduledef);
407407
if (m == NULL) return NULL;
408-
408+
#ifdef Py_GIL_DISABLED
409+
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
410+
#endif
409411
PyModule_AddIntConstant(m, "maxnamelen", UINPUT_MAX_NAME_SIZE);
410412
return m;
411413
}

0 commit comments

Comments
 (0)