mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-09-14 14:40:26 +00:00
interpreters/python: Add ctypes prototype patches for NuttX
Integrate NuttX-specific ctypes and posixmodule updates. Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
This commit is contained in:
parent
965cddfa36
commit
58b780c280
7 changed files with 55 additions and 1 deletions
|
|
@ -6,6 +6,7 @@
|
|||
config INTERPRETERS_CPYTHON
|
||||
tristate "CPython"
|
||||
depends on LIB_ZLIB
|
||||
depends on !LIBC_DLFCN || LIB_LIBFFI
|
||||
depends on EXPERIMENTAL
|
||||
default n
|
||||
---help---
|
||||
|
|
|
|||
|
|
@ -88,6 +88,9 @@ $(CPYTHON_UNPACKNAME): $(CPYTHON_ZIP)
|
|||
$(Q) patch -p1 -d $(CPYTHON_UNPACKNAME) < patch$(DELIM)0016-fix-timezone-offset-check-when-time-t-is-unsigned.patch
|
||||
$(Q) patch -p1 -d $(CPYTHON_UNPACKNAME) < patch$(DELIM)0017-stdlib-zip-keep-pydecimal-and-trim-tooling-extras.patch
|
||||
$(Q) patch -p1 -d $(CPYTHON_UNPACKNAME) < patch$(DELIM)0018-ignore-chmod-on-nuttx-like-wasi.patch
|
||||
$(Q) patch -p1 -d $(CPYTHON_UNPACKNAME) < patch$(DELIM)0019-undef-get_errno-set_errno-to-avoid-nuttx-macro-coll.patch
|
||||
$(Q) patch -p1 -d $(CPYTHON_UNPACKNAME) < patch$(DELIM)0020-ctypes-skip-pythonapi-on-nuttx.patch
|
||||
$(Q) patch -p1 -d $(CPYTHON_UNPACKNAME) < patch$(DELIM)0021-posixmodule-ignore-utime-enosys-on-nuttx.patch
|
||||
|
||||
$(HOSTPYTHON):
|
||||
mkdir -p $(HOSTBUILD)
|
||||
|
|
@ -128,6 +131,9 @@ $(SETUP_LOCAL):
|
|||
ifneq ($(CONFIG_ARCH_HAVE_FORK),y)
|
||||
@echo "_posixsubprocess" >> $@
|
||||
endif
|
||||
ifneq ($(CONFIG_LIBC_DLFCN),y)
|
||||
@echo "_ctypes" >> $@
|
||||
endif
|
||||
|
||||
# For the Python's `configure` script, please consider the following
|
||||
# when building for NuttX:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ _codecs_iso2022
|
|||
_codecs_jp
|
||||
_codecs_kr
|
||||
_codecs_tw
|
||||
_ctypes
|
||||
_decimal
|
||||
_elementtree
|
||||
_heapq
|
||||
|
|
|
|||
|
|
@ -31,3 +31,7 @@ export ac_cv_func_utimes="yes"
|
|||
export ac_cv_func_getuid="yes"
|
||||
export ac_cv_func_sysconf="yes"
|
||||
export ac_cv_func_umask="yes"
|
||||
export ac_cv_func_ffi_prep_cif_var="yes"
|
||||
export ac_cv_func_ffi_prep_closure_loc="yes"
|
||||
export ac_cv_func_ffi_closure_alloc="yes"
|
||||
export ac_cv_func_utimes="no"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
--- a/Modules/_ctypes/callproc.c
|
||||
+++ b/Modules/_ctypes/callproc.c
|
||||
@@ -91,6 +91,14 @@
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
+/* NuttX errno.h defines get_errno() and set_errno(e) as macros.
|
||||
+ Undef them so that CPython's static functions of the same name
|
||||
+ in this file compile without conflict. */
|
||||
+#ifdef __NuttX__
|
||||
+#undef get_errno
|
||||
+#undef set_errno
|
||||
+#endif
|
||||
+
|
||||
#ifdef _Py_MEMORY_SANITIZER
|
||||
#include <sanitizer/msan_interface.h>
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
--- a/Lib/ctypes/__init__.py
|
||||
+++ b/Lib/ctypes/__init__.py
|
||||
@@ -481,6 +481,8 @@
|
||||
pythonapi = PyDLL("libpython%d.%d.so" % _sys.version_info[:2])
|
||||
elif _sys.platform == "cygwin":
|
||||
pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2])
|
||||
+elif _sys.platform == "nuttx":
|
||||
+ pythonapi = None
|
||||
else:
|
||||
pythonapi = PyDLL(None)
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
--- a/Modules/posixmodule.c
|
||||
+++ b/Modules/posixmodule.c
|
||||
@@ -6666,6 +6666,13 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
+#if defined(__NuttX__)
|
||||
+ if (result == -1 && errno == ENOSYS) {
|
||||
+ /* SmartFS and other NuttX fs do not implement chstat. */
|
||||
+ Py_RETURN_NONE;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
if (result < 0) {
|
||||
path_error(path);
|
||||
return NULL;
|
||||
Loading…
Add table
Add a link
Reference in a new issue