From 16be59858afa332cc8a0f8e61a215e1deea5e897 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 5 Apr 2011 20:54:00 +0000 Subject: Clean kernel-/user-mode module build git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3469 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/lib/lib_internal.h | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'nuttx/lib/lib_internal.h') 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 * * Redistribution and use in source and binary forms, with or without @@ -47,6 +47,7 @@ #include #include #include + #include /**************************************************************************** @@ -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 +# 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 +# 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 -- cgit v1.2.3