diff options
author | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-11-16 20:04:58 +0000 |
---|---|---|
committer | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-11-16 20:04:58 +0000 |
commit | 883346d64a852193fb4119d4399aa0f5a54d8ae8 (patch) | |
tree | c012d8f76915d410cf7446b1efc51e3c2e3f5e95 /include | |
parent | 4948a0f37cad4e682bdd7860e0c2f01c6cb38ef7 (diff) |
Start untangling header inclusion in a way that does not affect
build times - tested, there is no measureable difference before and
after this commit.
In this change:
use asterisk/compat.h to include a small set of system headers:
inttypes.h, unistd.h, stddef.h, stddint.h, sys/types.h, stdarg.h,
stdlib.h, alloca.h, stdio.h
Where available, the inclusion is conditional on HAVE_FOO_H as determined
by autoconf.
Normally, source files should not include any of the above system headers,
and instead use either "asterisk.h" or "asterisk/compat.h" which does it
better.
For the time being I have left alone second-level directories
(main/db1-ast, etc.).
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89333 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/abstract_jb.h | 1 | ||||
-rw-r--r-- | include/asterisk/astmm.h | 7 | ||||
-rw-r--r-- | include/asterisk/astobj.h | 2 | ||||
-rw-r--r-- | include/asterisk/cli.h | 2 | ||||
-rw-r--r-- | include/asterisk/compat.h | 35 | ||||
-rw-r--r-- | include/asterisk/config.h | 1 | ||||
-rw-r--r-- | include/asterisk/file.h | 6 | ||||
-rw-r--r-- | include/asterisk/lock.h | 5 | ||||
-rw-r--r-- | include/asterisk/logger.h | 3 | ||||
-rw-r--r-- | include/asterisk/manager.h | 2 | ||||
-rw-r--r-- | include/asterisk/md5.h | 2 | ||||
-rw-r--r-- | include/asterisk/plc.h | 10 | ||||
-rw-r--r-- | include/asterisk/sha1.h | 9 | ||||
-rw-r--r-- | include/asterisk/slinfactory.h | 3 | ||||
-rw-r--r-- | include/asterisk/stringfields.h | 4 | ||||
-rw-r--r-- | include/asterisk/strings.h | 4 | ||||
-rw-r--r-- | include/asterisk/time.h | 3 | ||||
-rw-r--r-- | include/asterisk/utils.h | 4 |
18 files changed, 41 insertions, 62 deletions
diff --git a/include/asterisk/abstract_jb.h b/include/asterisk/abstract_jb.h index 9342dca82..1bd9dc84d 100644 --- a/include/asterisk/abstract_jb.h +++ b/include/asterisk/abstract_jb.h @@ -30,7 +30,6 @@ #ifndef _ABSTRACT_JB_H_ #define _ABSTRACT_JB_H_ -#include <stdio.h> #include <sys/time.h> #if defined(__cplusplus) || defined(c_plusplus) diff --git a/include/asterisk/astmm.h b/include/asterisk/astmm.h index f1f838ef0..4487c17aa 100644 --- a/include/asterisk/astmm.h +++ b/include/asterisk/astmm.h @@ -27,13 +27,6 @@ #include "asterisk.h" -/* Include these now to prevent them from being needed later */ -#include <sys/types.h> -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <stdarg.h> - /* Undefine any macros */ #undef malloc #undef calloc diff --git a/include/asterisk/astobj.h b/include/asterisk/astobj.h index 088d6df16..1d257ed7a 100644 --- a/include/asterisk/astobj.h +++ b/include/asterisk/astobj.h @@ -23,8 +23,6 @@ #ifndef _ASTERISK_ASTOBJ_H #define _ASTERISK_ASTOBJ_H -#include <string.h> - #include "asterisk/lock.h" #include "asterisk/compiler.h" diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h index d0db49f48..d29917d1d 100644 --- a/include/asterisk/cli.h +++ b/include/asterisk/cli.h @@ -27,8 +27,6 @@ extern "C" { #endif -#include <stdarg.h> - #include "asterisk/linkedlists.h" void ast_cli(int fd, const char *fmt, ...) diff --git a/include/asterisk/compat.h b/include/asterisk/compat.h index 838e24e47..7e019e064 100644 --- a/include/asterisk/compat.h +++ b/include/asterisk/compat.h @@ -11,16 +11,49 @@ /*! \file * \brief General Definitions for Asterisk top level program + * Included by asterisk.h to handle platform-specific issues + * especially those related to header files. */ #ifndef _COMPAT_H #define _COMPAT_H -#include "asterisk/autoconfig.h" +#ifdef HAVE_INTTYPES_H #include <inttypes.h> +#endif + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#ifdef HAVE_STDDEF_H +#include <stddef.h> +#endif + +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif + +#ifdef HAVE_SYS_TYPES_H #include <sys/types.h> +#endif + #include <stdarg.h> +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif + +#ifdef HAVE_ALLOCA_H +#include <alloca.h> /* not necessarily present - could be in stdlib */ +#endif + +#include <stdio.h> /* this is always present */ + +#ifdef HAVE_STRING_H +#include <string.h> +#endif + #if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) int asprintf(char **str, const char *fmt, ...); #endif diff --git a/include/asterisk/config.h b/include/asterisk/config.h index ab67fb22b..c60916a90 100644 --- a/include/asterisk/config.h +++ b/include/asterisk/config.h @@ -28,7 +28,6 @@ extern "C" { #endif #include "asterisk/utils.h" -#include <stdarg.h> struct ast_config; diff --git a/include/asterisk/file.h b/include/asterisk/file.h index a93b58915..994b7b943 100644 --- a/include/asterisk/file.h +++ b/include/asterisk/file.h @@ -23,13 +23,11 @@ #ifndef _ASTERISK_FILE_H #define _ASTERISK_FILE_H -#ifndef stdin -#error You must include stdio.h before file.h! -#endif /* !stdin */ - #include "asterisk/channel.h" #include "asterisk/frame.h" +#ifdef HAVE_FCNTL_H #include <fcntl.h> +#endif #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h index 52164ed03..eb09bbf45 100644 --- a/include/asterisk/lock.h +++ b/include/asterisk/lock.h @@ -46,7 +46,7 @@ #define _ASTERISK_LOCK_H #include <pthread.h> -#include <netdb.h> +// #include <netdb.h> #include <time.h> #include <sys/param.h> @@ -99,9 +99,6 @@ #endif #include <errno.h> -#include <string.h> -#include <stdio.h> -#include <unistd.h> #define AST_MUTEX_INIT_VALUE { PTHREAD_MUTEX_INIT_VALUE, 1, { NULL }, { 0 }, 0, { NULL }, { 0 }, PTHREAD_MUTEX_INIT_VALUE } #define AST_MUTEX_INIT_VALUE_NOTRACKING \ diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h index 2cfc8ecc3..62c970713 100644 --- a/include/asterisk/logger.h +++ b/include/asterisk/logger.h @@ -25,11 +25,8 @@ #ifndef _ASTERISK_LOGGER_H #define _ASTERISK_LOGGER_H -#include "asterisk/compat.h" #include "asterisk/options.h" -#include <stdarg.h> - #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h index 47684960c..cef48ed48 100644 --- a/include/asterisk/manager.h +++ b/include/asterisk/manager.h @@ -19,8 +19,6 @@ #ifndef _ASTERISK_MANAGER_H #define _ASTERISK_MANAGER_H -#include <stdarg.h> -#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> diff --git a/include/asterisk/md5.h b/include/asterisk/md5.h index f738bd5b6..714267da6 100644 --- a/include/asterisk/md5.h +++ b/include/asterisk/md5.h @@ -23,8 +23,6 @@ #ifndef _ASTERISK_MD5_H #define _ASTERISK_MD5_H -#include <inttypes.h> - struct MD5Context { uint32_t buf[4]; uint32_t bits[2]; diff --git a/include/asterisk/plc.h b/include/asterisk/plc.h index 762504952..cd650012c 100644 --- a/include/asterisk/plc.h +++ b/include/asterisk/plc.h @@ -33,15 +33,7 @@ #if !defined(_PLC_H_) #define _PLC_H_ -#ifdef SOLARIS -#include <sys/int_types.h> -#else -#if defined(__OpenBSD__) || defined( __FreeBSD__) -#include <inttypes.h> -#else -#include <stdint.h> -#endif -#endif +/* solaris used to #include <sys/int_types.h> */ /*! \page plc_page Packet loss concealment \section plc_page_sec_1 What does it do? diff --git a/include/asterisk/sha1.h b/include/asterisk/sha1.h index ed905d04b..d530c3206 100644 --- a/include/asterisk/sha1.h +++ b/include/asterisk/sha1.h @@ -18,15 +18,8 @@ #ifndef _SHA1_H_ #define _SHA1_H_ - - -#if defined(__OpenBSD__) || defined( __FreeBSD__) -#include <inttypes.h> -#else -#include <stdint.h> -#endif - /* + * We assume that the standard asterisk headers have been included before this one. * If you do not have the ISO standard stdint.h header file, then you * must typdef the following: * name meaning diff --git a/include/asterisk/slinfactory.h b/include/asterisk/slinfactory.h index 597d366bf..603c648c7 100644 --- a/include/asterisk/slinfactory.h +++ b/include/asterisk/slinfactory.h @@ -23,9 +23,6 @@ #ifndef _ASTERISK_SLINFACTORY_H #define _ASTERISK_SLINFACTORY_H -#include <stdlib.h> -#include <unistd.h> -#include <string.h> #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h index f842601ca..214935ac0 100644 --- a/include/asterisk/stringfields.h +++ b/include/asterisk/stringfields.h @@ -102,10 +102,6 @@ #ifndef _ASTERISK_STRINGFIELDS_H #define _ASTERISK_STRINGFIELDS_H -#include <string.h> -#include <stdarg.h> -#include <stddef.h> - #include "asterisk/inline_api.h" #include "asterisk/compiler.h" #include "asterisk/compat.h" diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index 62df5a36a..2efe02c2a 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -23,10 +23,6 @@ #ifndef _ASTERISK_STRINGS_H #define _ASTERISK_STRINGS_H -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> - #include "asterisk/inline_api.h" #include "asterisk/compiler.h" #include "asterisk/compat.h" diff --git a/include/asterisk/time.h b/include/asterisk/time.h index d04183354..7e1726e72 100644 --- a/include/asterisk/time.h +++ b/include/asterisk/time.h @@ -23,8 +23,9 @@ #ifndef _ASTERISK_TIME_H #define _ASTERISK_TIME_H +#ifdef HAVE_SYS_TIME_H #include <sys/time.h> -#include <stdlib.h> +#endif #include "asterisk/inline_api.h" diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index efde93d59..7d0b56089 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -25,14 +25,10 @@ #include "asterisk/compat.h" -#include <stdlib.h> -#include <stdio.h> -#include <stdarg.h> #include <netinet/in.h> #include <arpa/inet.h> /* we want to override inet_ntoa */ #include <netdb.h> #include <limits.h> -#include <string.h> #include <time.h> /* we want to override localtime_r */ #include "asterisk/lock.h" |