diff options
author | Damien George <damien.p.george@gmail.com> | 2020-04-20 23:48:34 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-04-27 23:58:46 +1000 |
commit | e08ca78f40bb1948acffa60c0315083acfb02227 (patch) | |
tree | dac5e7df1adfea8fbbb9d386adf50a43e0df0c97 /lib | |
parent | 57fce3bdb203e9701dbd81ee108189898e19911b (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 'lib')
-rw-r--r-- | lib/embed/__errno.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/embed/__errno.c b/lib/embed/__errno.c new file mode 100644 index 000000000..86417a02d --- /dev/null +++ b/lib/embed/__errno.c @@ -0,0 +1,13 @@ +// This file provides a version of __errno() for embedded systems that do not have one. +// This function is needed for expressions of the form: &errno + +static int embed_errno; + +#if defined(__linux__) +int *__errno_location(void) +#else +int *__errno(void) +#endif +{ + return &embed_errno; +} |