summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-02-05 08:31:33 -0800
committerPixel <pixel@nobis-crew.org>2011-02-05 08:31:33 -0800
commit0736203a630b2fbc2bc3e6383e4aec9285bba184 (patch)
tree1bca3f8821e607a47b4adfaab2f60fa029a2a58a
parent681c1493836e79ea87faba47a804899374ccc219 (diff)
Context switch also means switching that global errno variable.
-rw-r--r--FreeRTOS/Source/tasks.c1
-rw-r--r--libc/Makefile1
-rw-r--r--libc/include/errno.h2
-rw-r--r--libc/src/errno.c3
4 files changed, 7 insertions, 0 deletions
diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c
index 6ad1c58..1aac8f2 100644
--- a/FreeRTOS/Source/tasks.c
+++ b/FreeRTOS/Source/tasks.c
@@ -1641,6 +1641,7 @@ void vTaskSwitchContext( void )
#if ( configUSE_NEWLIB_REENTRANT == 1 )
_impure_ptr = &(pxCurrentTCB->reent);
+ errno = _impure_ptr->_errno;
#endif
traceTASK_SWITCHED_IN();
diff --git a/libc/Makefile b/libc/Makefile
index 64cfa5d..9ef6392 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -20,6 +20,7 @@ src/read.c \
src/write.c \
\
src/stdio.c \
+src/errno.c \
\
src/reent.c \
\
diff --git a/libc/include/errno.h b/libc/include/errno.h
index c88ea64..5e0af8c 100644
--- a/libc/include/errno.h
+++ b/libc/include/errno.h
@@ -137,4 +137,6 @@ enum errno_t {
ERFKILL = 132,
};
+volatile extern enum errno_t errno;
+
#endif
diff --git a/libc/src/errno.c b/libc/src/errno.c
new file mode 100644
index 0000000..6e6a6e8
--- /dev/null
+++ b/libc/src/errno.c
@@ -0,0 +1,3 @@
+#include "errno.h"
+
+volatile enum errno_t errno = ENOERROR;