diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-04-03 18:42:33 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-04-03 18:42:33 +0000 |
commit | c5ec7c478098273586b7a5716e30dc82c1e6aba5 (patch) | |
tree | 241ec95305382eac68e212764452ee17655df48f /nuttx/include | |
parent | cfc7fe371ad9efc22bded77dc0779ec4eff1a9fd (diff) | |
download | px4-nuttx-c5ec7c478098273586b7a5716e30dc82c1e6aba5.tar.gz px4-nuttx-c5ec7c478098273586b7a5716e30dc82c1e6aba5.tar.bz2 px4-nuttx-c5ec7c478098273586b7a5716e30dc82c1e6aba5.zip |
Pass __KERNEL__ define (or not) to all makes to handle small differences in user-/kernel-builds
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3459 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include')
-rw-r--r-- | nuttx/include/errno.h | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/nuttx/include/errno.h b/nuttx/include/errno.h index 09c9690b6..d0c80975a 100644 --- a/nuttx/include/errno.h +++ b/nuttx/include/errno.h @@ -46,13 +46,38 @@ * Definitions ************************************************************************/ -/* Convenience/compatibility definition */ +/* Convenience/compatibility definition. + * + * For a flat, all kernel-mode build, the error can be read and written + * from all code using a simple pointer. + */ -#define errno *get_errno_ptr() #ifndef CONFIG_NUTTX_KERNEL + +# define errno *get_errno_ptr() # define set_errno(e) do { errno = (int)(e); } while (0) # define get_errno(e) errno -#endif + +#else + +/* 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. + */ + +#ifdef __KERNEL__ +# define errno *get_errno_ptr() +#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- + * mode code in order to set the errno value. + */ + +# define errno get_errno() + +#endif /* __KERNEL__ */ +#endif /* CONFIG_NUTTX_KERNEL */ /* Definitions of error numbers and the string that would be * returned by strerror(). |