summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author[email protected] <[email protected]>2011-08-28 15:57:10 +0000
committer[email protected] <[email protected]>2011-08-28 15:57:10 +0000
commit472cc9334ac63bdd041f83e884757c75a30651c7 (patch)
tree476ced7ae5eb53a7ae3be460ea9baea8cd6037d6 /src
parentda74af2347cfee577b202cf4e26c1af16c05f5b6 (diff)
add errno implementation in RT-Thread.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1682 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'src')
-rw-r--r--src/kservice.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/kservice.c b/src/kservice.c
index 10d2807082..70a8e9060a 100644
--- a/src/kservice.c
+++ b/src/kservice.c
@@ -27,7 +27,7 @@
#ifndef RT_USING_NEWLIB
/* global errno in RT-Thread*/
-volatile int errno;
+static volatile int _errno;
#else
#include <errno.h>
#endif
@@ -47,11 +47,11 @@ rt_err_t rt_get_errno(void)
if(rt_interrupt_get_nest() != 0)
{
/* it's in interrupt context */
- return errno;
+ return _errno;
}
tid = rt_thread_self();
- if (tid == RT_NULL) return errno;
+ if (tid == RT_NULL) return _errno;
return tid->error;
}
@@ -68,17 +68,34 @@ void rt_set_errno(rt_err_t error)
if(rt_interrupt_get_nest() != 0)
{
/* it's in interrupt context */
- errno = error;
+ _errno = error;
return;
}
tid = rt_thread_self();
- if (tid == RT_NULL) { errno = error; return; }
+ if (tid == RT_NULL) { _errno = error; return; }
tid->error = error;
}
/**
+ * This function returns errno.
+ *
+ * @return the errno in the system
+ */
+int *_rt_errno(void)
+{
+ rt_thread_t tid;
+
+ if (rt_interrupt_get_nest() != 0) return (int *)&_errno;
+
+ tid = rt_thread_self();
+ if (tid != RT_NULL) return (int *)&(tid->error);
+
+ return (int *)&_errno;
+}
+
+/**
* This function will set the content of memory to specified value
*
* @param s the address of source memory