aboutsummaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorDamien George2020-04-20 23:48:34 +1000
committerDamien George2020-04-27 23:58:46 +1000
commite08ca78f40bb1948acffa60c0315083acfb02227 (patch)
treedac5e7df1adfea8fbbb9d386adf50a43e0df0c97 /ports
parent57fce3bdb203e9701dbd81ee108189898e19911b (diff)
py/stream: Remove mp_stream_errno and use system errno instead.
This change is made for two reasons: 1. A 3rd-party library (eg berkeley-db-1.xx, axtls) may use the system provided errno for certain errors, and yet MicroPython stream objects that it calls will be using the internal mp_stream_errno. So if the library returns an error it is not known whether the corresponding errno code is stored in the system errno or mp_stream_errno. Using the system errno in all cases (eg in the mp_stream_posix_XXX wrappers) fixes this ambiguity. 2. For systems that have threading the system-provided errno should always be used because the errno value is thread-local. For systems that do not have an errno, the new lib/embed/__errno.c file is provided.
Diffstat (limited to 'ports')
-rw-r--r--ports/esp32/mphalport.c7
-rw-r--r--ports/esp8266/Makefile1
-rw-r--r--ports/esp8266/esp_mphal.c5
3 files changed, 1 insertions, 12 deletions
diff --git a/ports/esp32/mphalport.c b/ports/esp32/mphalport.c
index 4f7785f24..99548ad62 100644
--- a/ports/esp32/mphalport.c
+++ b/ports/esp32/mphalport.c
@@ -195,13 +195,6 @@ void mp_hal_delay_us(uint32_t us) {
}
}
-/*
-extern int mp_stream_errno;
-int *__errno() {
- return &mp_stream_errno;
-}
-*/
-
// Wake up the main task if it is sleeping
void mp_hal_wake_main_task_from_isr(void) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile
index 85a04c070..7fb1bc43c 100644
--- a/ports/esp8266/Makefile
+++ b/ports/esp8266/Makefile
@@ -120,6 +120,7 @@ EXTMOD_SRC_C = $(addprefix extmod/,\
)
LIB_SRC_C = $(addprefix lib/,\
+ embed/__errno.c \
libc/string0.c \
libm/math.c \
libm/fmodf.c \
diff --git a/ports/esp8266/esp_mphal.c b/ports/esp8266/esp_mphal.c
index 8859046d7..20d0557d6 100644
--- a/ports/esp8266/esp_mphal.c
+++ b/ports/esp8266/esp_mphal.c
@@ -206,8 +206,3 @@ int ets_esf_free_bufs(int idx) {
}
return cnt;
}
-
-extern int mp_stream_errno;
-int *__errno() {
- return &mp_stream_errno;
-}