diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-08-28 17:01:57 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-08-28 17:01:57 -0600 |
commit | 0fbd76ac35afc7465be9f80c26f88d5bd9395914 (patch) | |
tree | 9ca8752ada09f46ae3d14853104c53c63065fb55 | |
parent | 0c8c1a071f909e0adee75bc75194898585d94a3f (diff) | |
download | nuttx-0fbd76ac35afc7465be9f80c26f88d5bd9395914.tar.gz nuttx-0fbd76ac35afc7465be9f80c26f88d5bd9395914.tar.bz2 nuttx-0fbd76ac35afc7465be9f80c26f88d5bd9395914.zip |
errno must be handled in a special way if there are external modules
-rw-r--r-- | nuttx/include/errno.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/nuttx/include/errno.h b/nuttx/include/errno.h index 8137a6626..8c2ea46a8 100644 --- a/nuttx/include/errno.h +++ b/nuttx/include/errno.h @@ -52,7 +52,7 @@ * from all code using a simple pointer. */ -#ifndef CONFIG_NUTTX_KERNEL +#ifndef CONFIG_LIB_SYSCALL # define errno *get_errno_ptr() # define set_errno(e) do { errno = (int)(e); } while (0) @@ -62,22 +62,29 @@ /* We doing separate user-/kernel-mode builds, then the errno has to be * a little differently. In kernel-mode, the TCB errno value can still be - * read and written using a pointer. + * read and written using a pointer from code executing within the + * kernel. */ -#ifdef __KERNEL__ +#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__) # define errno *get_errno_ptr() +# define set_errno(e) do { errno = (int)(e); } while (0) +# define get_errno(e) errno #else /* But in user-mode, the errno can only be read using the name 'errno'. - * The non-standard API set_errno() must be explicity be used from user- + * The non-standard API set_errno() must explicitly be used from user- * mode code in order to set the errno value. + * + * The same is true of the case where we have syscalls enabled but this + * is not a kernel build, then we really have no option but to use the + * set_errno() accessor function explicitly, even from OS logic! */ # define errno get_errno() #endif /* __KERNEL__ */ -#endif /* CONFIG_NUTTX_KERNEL */ +#endif /* CONFIG_LIB_SYSCALL */ /* Definitions of error numbers and the string that would be * returned by strerror(). @@ -357,7 +364,7 @@ extern "C" FAR int *get_errno_ptr(void); -#ifdef CONFIG_NUTTX_KERNEL +#ifdef CONFIG_LIB_SYSCALL void set_errno(int errcode); int get_errno(void); #endif |