Skip to content

Commit c28faba

Browse files
kesmit13claude
andcommitted
Guard Unix-only headers and functions against _WIN32
The accel C extension uses poll.h, sys/mman.h, sys/socket.h, and unistd.h which are unavailable on Windows. Extend the existing __wasi__ guards to also exclude _WIN32. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6956d2f commit c28faba

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

accel.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11

22
#define PY_SSIZE_T_CLEAN
33
#include <math.h>
4-
#ifndef __wasi__
4+
#if !defined(__wasi__) && !defined(_WIN32)
55
#include <poll.h>
66
#endif
77
#include <stdint.h>
88
#include <stdlib.h>
99
#include <string.h>
10-
#ifndef __wasi__
10+
#if !defined(__wasi__) && !defined(_WIN32)
1111
#include <sys/mman.h>
1212
#include <sys/socket.h>
13-
#endif
1413
#include <unistd.h>
14+
#endif
1515
#include <Python.h>
1616

1717
#ifndef Py_LIMITED_API
@@ -5722,7 +5722,7 @@ static PyObject *call_function_accel(PyObject *self, PyObject *args, PyObject *k
57225722
goto exit;
57235723
}
57245724

5725-
#ifndef __wasi__
5725+
#if !defined(__wasi__) && !defined(_WIN32)
57265726
/*
57275727
* mmap_read(fd, length) -> bytes
57285728
*
@@ -5875,24 +5875,24 @@ static PyObject *accel_recv_exact(PyObject *self, PyObject *args) {
58755875
free(buf);
58765876
return result;
58775877
}
5878-
#else /* __wasi__ stubs — importable but raise NotImplementedError if called */
5878+
#else /* __wasi__ / _WIN32 stubs */
58795879

58805880
static PyObject *accel_mmap_read(PyObject *self, PyObject *args) {
5881-
PyErr_SetString(PyExc_NotImplementedError, "mmap_read is not available in WASM");
5881+
PyErr_SetString(PyExc_NotImplementedError, "mmap_read is not available on this platform");
58825882
return NULL;
58835883
}
58845884

58855885
static PyObject *accel_mmap_write(PyObject *self, PyObject *args) {
5886-
PyErr_SetString(PyExc_NotImplementedError, "mmap_write is not available in WASM");
5886+
PyErr_SetString(PyExc_NotImplementedError, "mmap_write is not available on this platform");
58875887
return NULL;
58885888
}
58895889

58905890
static PyObject *accel_recv_exact(PyObject *self, PyObject *args) {
5891-
PyErr_SetString(PyExc_NotImplementedError, "recv_exact is not available in WASM");
5891+
PyErr_SetString(PyExc_NotImplementedError, "recv_exact is not available on this platform");
58925892
return NULL;
58935893
}
58945894

5895-
#endif /* !__wasi__ */
5895+
#endif /* !__wasi__ && !_WIN32 */
58965896

58975897
static PyMethodDef PyMySQLAccelMethods[] = {
58985898
{"read_rowdata_packet", (PyCFunction)read_rowdata_packet, METH_VARARGS | METH_KEYWORDS, "PyMySQL row data packet reader"},

0 commit comments

Comments
 (0)