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: https://origsvn.digium.com/svn/asterisk/trunk@89333 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Luigi Rizzo
2007-11-16 20:04:58 +00:00
parent fd7b3e7261
commit fdb7f7ba3d
265 changed files with 58 additions and 1148 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -23,8 +23,6 @@
#ifndef _ASTERISK_ASTOBJ_H
#define _ASTERISK_ASTOBJ_H
#include <string.h>
#include "asterisk/lock.h"
#include "asterisk/compiler.h"

View File

@@ -27,8 +27,6 @@
extern "C" {
#endif
#include <stdarg.h>
#include "asterisk/linkedlists.h"
void ast_cli(int fd, const char *fmt, ...)

View File

@@ -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

View File

@@ -28,7 +28,6 @@ extern "C" {
#endif
#include "asterisk/utils.h"
#include <stdarg.h>
struct ast_config;

View File

@@ -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" {

View File

@@ -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 \

View File

@@ -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

View File

@@ -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>

View File

@@ -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];

View File

@@ -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?

View File

@@ -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

View File

@@ -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" {

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"