diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-08-29 16:23:46 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-08-29 16:23:46 -0600 |
commit | bad65d0c62ee527bbb839ab87b01abc0c874c8c9 (patch) | |
tree | c6316029e8e2a7b27422a2a8bbf10ccfb26aadd3 /nuttx/include/errno.h | |
parent | c7153c08bd9b6ebce31e6dbeb835b01aee4fabbb (diff) | |
download | nuttx-bad65d0c62ee527bbb839ab87b01abc0c874c8c9.tar.gz nuttx-bad65d0c62ee527bbb839ab87b01abc0c874c8c9.tar.bz2 nuttx-bad65d0c62ee527bbb839ab87b01abc0c874c8c9.zip |
Various changes/fixes to get configs/stm32f4discovery/kostest working after the big configuration renaming (and after a long period of bit rot)
Diffstat (limited to 'nuttx/include/errno.h')
-rw-r--r-- | nuttx/include/errno.h | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/nuttx/include/errno.h b/nuttx/include/errno.h index dc90b4d05..e61a752aa 100644 --- a/nuttx/include/errno.h +++ b/nuttx/include/errno.h @@ -43,8 +43,31 @@ #include <nuttx/compiler.h> /************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************/ +/* How can we access the errno variable? */ + +#undef __DIRECT_ERRNO_ACCESS +#if !defined(CONFIG_LIB_SYSCALL) + /* No system calls? Then there can only be direct access */ + +# define __DIRECT_ERRNO_ACCESS 1 + +#elif !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL) + /* Flat build... complete access */ + +# define __DIRECT_ERRNO_ACCESS 1 + +#elif defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) + /* Kernel portion of protected build. The Kernel has access */ + +# define __DIRECT_ERRNO_ACCESS 1 + +#elif defined(CONFIG_BUILD_KERNEL) + /* Kernel only build. The kernel has access */ + +# define __DIRECT_ERRNO_ACCESS 1 +#endif /* Convenience/compatibility definition. * @@ -52,7 +75,7 @@ * from all code using a simple pointer. */ -#ifndef CONFIG_LIB_SYSCALL +#ifdef __DIRECT_ERRNO_ACCESS # define errno *get_errno_ptr() # define set_errno(e) do { errno = (int)(e); } while (0) @@ -64,16 +87,8 @@ * a little differently. In kernel-mode, the TCB errno value can still be * read and written using a pointer from code executing within the * kernel. - */ - -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_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'. + * + * But in user-mode, the errno can only be read using the name 'errno'. * The non-standard API set_errno() must explicitly be used from user- * mode code in order to set the errno value. * @@ -84,8 +99,7 @@ # define errno get_errno() -#endif /* __KERNEL__ */ -#endif /* CONFIG_LIB_SYSCALL */ +#endif /* __DIRECT_ERRNO_ACCESS */ /* Definitions of error numbers and the string that would be * returned by strerror(). @@ -365,7 +379,7 @@ extern "C" FAR int *get_errno_ptr(void); -#ifdef CONFIG_LIB_SYSCALL +#ifndef __DIRECT_ERRNO_ACCESS void set_errno(int errcode); int get_errno(void); #endif |