Skip to content

Commit db8542d

Browse files
tmediccilupyuen
authored andcommitted
interpreters/python: fix patch to set _PyRuntime attribute
This commit also adds the check for the `__NuttX__` macro to the patch file that allows setting an attribute to the `_PyRuntime` structure. The `__NuttX__` macro is guaranteed to be present when building any application for NuttX.
1 parent 7f424c3 commit db8542d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

interpreters/python/patch/0012-hack-place-_PyRuntime-structure-into-PSRAM-bss-regio.patch

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From d1e903f516849c535455904b3c3f8a33665c1a88 Mon Sep 17 00:00:00 2001
1+
From 79b6142580bad5235588faf38c0a22c7280a2d1b Mon Sep 17 00:00:00 2001
22
From: Ivan Grokhotkov <[email protected]>
33
Date: Wed, 23 Oct 2024 16:52:52 +0200
4-
Subject: [PATCH 12/12] hack: place _PyRuntime structure into PSRAM bss region,
4+
Subject: [PATCH 12/13] hack: place _PyRuntime structure into PSRAM bss region,
55
initialize later
66

77
_PyRuntime occupies around 100kB of RAM in .data region, making it
@@ -22,14 +22,14 @@ Co-authored-by: Tiago Medicci Serrano <[email protected]>
2222
1 file changed, 11 insertions(+)
2323

2424
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
25-
index 1701a1cd217..2a8e544f0ac 100644
25+
index 1701a1cd217..93aa808bc03 100644
2626
--- a/Python/pylifecycle.c
2727
+++ b/Python/pylifecycle.c
2828
@@ -102,12 +102,23 @@ __attribute__((
2929
_PyRuntimeState _PyRuntime
3030
#if defined(__linux__) && (defined(__GNUC__) || defined(__clang__))
3131
__attribute__ ((section (".PyRuntime")))
32-
+#elif defined(ESP_PLATFORM)
32+
+#elif defined(ESP_PLATFORM) || defined(__NuttX__)
3333
+__attribute__ ((section (".PyRuntime")))
3434
#endif
3535
= _PyRuntimeState_INIT(_PyRuntime, _Py_Debug_Cookie);
@@ -38,7 +38,7 @@ index 1701a1cd217..2a8e544f0ac 100644
3838
static int runtime_initialized = 0;
3939

4040
+void _PyRuntime_Early_Init(void) {
41-
+#if defined(ESP_PLATFORM)
41+
+#if defined(ESP_PLATFORM) || defined(__NuttX__)
4242
+ // Normally, _PyRuntime is in .data and is initialized by the C runtime.
4343
+ // This function allows us to place it into external RAM .bss section
4444
+ // and initialize it manually, saving some internal RAM.
@@ -50,5 +50,5 @@ index 1701a1cd217..2a8e544f0ac 100644
5050
_PyRuntime_Initialize(void)
5151
{
5252
--
53-
2.47.1
53+
2.48.1
5454

0 commit comments

Comments
 (0)