diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-04-05 20:54:00 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-04-05 20:54:00 +0000 |
commit | 16be59858afa332cc8a0f8e61a215e1deea5e897 (patch) | |
tree | 0159742e27848cfac6eec8d9d87bd6579af48c18 /nuttx/lib/lib_internal.h | |
parent | 3607bf2b4b1f2087cfb52ab4591f2ac347698a9c (diff) | |
download | px4-nuttx-16be59858afa332cc8a0f8e61a215e1deea5e897.tar.gz px4-nuttx-16be59858afa332cc8a0f8e61a215e1deea5e897.tar.bz2 px4-nuttx-16be59858afa332cc8a0f8e61a215e1deea5e897.zip |
Clean kernel-/user-mode module build
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3469 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/lib/lib_internal.h')
-rw-r--r-- | nuttx/lib/lib_internal.h | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/nuttx/lib/lib_internal.h b/nuttx/lib/lib_internal.h index 6ec2fe201..b9c74304e 100644 --- a/nuttx/lib/lib_internal.h +++ b/nuttx/lib/lib_internal.h @@ -1,7 +1,7 @@ /**************************************************************************** * lib/lib_internal.h * - * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -47,6 +47,7 @@ #include <stdio.h> #include <limits.h> #include <semaphore.h> + #include <nuttx/streams.h> /**************************************************************************** @@ -57,10 +58,35 @@ # define CONFIG_LIB_HOMEDIR "/" #endif +/* If C std I/O buffering is not supported, then we don't need its semaphore + * protection. + */ + #if CONFIG_STDIO_BUFFER_SIZE <= 0 -# define lib_sem_initialize(s) -# define lib_take_semaphore(s) -# define lib_give_semaphore(s) +# define lib_sem_initialize(s) +# define lib_take_semaphore(s) +# define lib_give_semaphore(s) +#endif + +/* The NuttX C library an be build in two modes: (1) as a standard, C-libary + * that can be used by normal, user-space applications, or (2) as a special, + * kernel-mode C-library only used within the OS. If NuttX is not being + * built as separated kernel- and user-space modules, then only the first + * mode is supported. + */ + +#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__) +# include <nuttx/kmalloc.h> +# define lib_malloc(s) kmalloc(s) +# define lib_zalloc(s) kzalloc(s) +# define lib_realloc(p,s) krealloc(p,s) +# define lib_free(p) kfree(p) +#else +# include <stdlib.h> +# define lib_malloc(s) malloc(s) +# define lib_zalloc(s) zalloc(s) +# define lib_realloc(p,s) realloc(p,s) +# define lib_free(p) free(p) #endif #define LIB_BUFLEN_UNKNOWN INT_MAX |