include/asterisk/compat.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  * 
00004  * Copyright (C) 1999-2006, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * This program is free software, distributed under the terms of
00009  * the GNU General Public License
00010  */
00011 
00012 /*! \file
00013  * \brief General Definitions for Asterisk top level program
00014  * Included by asterisk.h to handle platform-specific issues
00015  * especially those related to header files.
00016  */
00017 
00018 #include "asterisk/compiler.h"
00019 
00020 #ifndef _COMPAT_H
00021 #define _COMPAT_H
00022 
00023 #ifndef __STDC_VERSION__
00024 /* flex output wants to find this defined. */
00025 #define  __STDC_VERSION__ 0
00026 #endif
00027 
00028 #ifdef HAVE_INTTYPES_H
00029 #include <inttypes.h>
00030 #endif
00031 
00032 #ifdef HAVE_LIMITS_H
00033 #include <limits.h>
00034 #endif
00035 
00036 #ifdef HAVE_UNISTD_H
00037 #include <unistd.h>
00038 #endif
00039 
00040 #ifdef HAVE_STDDEF_H
00041 #include <stddef.h>
00042 #endif
00043 
00044 #ifdef HAVE_STDINT_H
00045 #include <stdint.h>
00046 #endif
00047 
00048 #ifdef HAVE_SYS_TYPES_H
00049 #include <sys/types.h>
00050 #endif
00051 
00052 #include <stdarg.h>
00053 
00054 #ifdef HAVE_STDLIB_H
00055 #include <stdlib.h>
00056 #endif
00057 
00058 #ifdef HAVE_ALLOCA_H
00059 #include <alloca.h>    /* not necessarily present - could be in stdlib */
00060 #elif defined(HAVE_ALLOCA) && defined(__MINGW32__)
00061 #include <malloc.h>    /* see if it is here... */
00062 #endif
00063 
00064 #include <stdio.h>   /* this is always present */
00065 
00066 #ifdef HAVE_STRING_H
00067 #include <string.h>
00068 #endif
00069 
00070 #ifndef AST_POLL_COMPAT
00071 #include <sys/poll.h>
00072 #else
00073 #include "asterisk/poll-compat.h"
00074 #endif
00075 
00076 #ifndef HAVE_LLONG_MAX
00077 #define  LLONG_MAX   9223372036854775807LL
00078 #endif
00079 
00080 #ifndef HAVE_CLOSEFROM
00081 void closefrom(int lowfd);
00082 #endif
00083 
00084 #if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC)
00085 int __attribute__((format(printf, 2, 3))) asprintf(char **str, const char *fmt, ...);
00086 #endif
00087 
00088 #ifndef HAVE_FFSLL
00089 int ffsll(long long n);
00090 #endif
00091 
00092 #ifndef HAVE_GETLOADAVG
00093 int getloadavg(double *list, int nelem);
00094 #endif
00095 
00096 #ifndef HAVE_HTONLL
00097 uint64_t htonll(uint64_t host64);
00098 #endif
00099 
00100 #ifndef HAVE_MKDTEMP
00101 char *mkdtemp(char *template_s);
00102 #endif
00103 
00104 #ifndef HAVE_NTOHLL
00105 uint64_t ntohll(uint64_t net64);
00106 #endif
00107 
00108 #ifndef HAVE_SETENV
00109 int setenv(const char *name, const char *value, int overwrite);
00110 #endif
00111 
00112 #ifndef HAVE_STRCASESTR
00113 char *strcasestr(const char *, const char *);
00114 #endif
00115 
00116 #if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC)
00117 char *strndup(const char *, size_t);
00118 #endif
00119 
00120 #ifndef HAVE_STRNLEN
00121 size_t strnlen(const char *, size_t);
00122 #endif
00123 
00124 #ifndef HAVE_STRSEP
00125 char* strsep(char** str, const char* delims);
00126 #endif
00127 
00128 #ifndef HAVE_STRTOQ
00129 uint64_t strtoq(const char *nptr, char **endptr, int base);
00130 #endif
00131 
00132 #ifndef HAVE_UNSETENV
00133 int unsetenv(const char *name);
00134 #endif
00135 
00136 #if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC)
00137 int __attribute__((format(printf, 2, 0))) vasprintf(char **strp, const char *fmt, va_list ap);
00138 #endif
00139 
00140 #ifndef HAVE_TIMERSUB
00141 void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff);
00142 #endif
00143 
00144 #define  strlcat  __use__ast_str__functions_not__strlcat__
00145 #define  strlcpy  __use__ast_copy_string__not__strlcpy__
00146 
00147 #include <errno.h>
00148 
00149 #ifdef SOLARIS
00150 #define __BEGIN_DECLS
00151 #define __END_DECLS
00152 
00153 #ifndef __P
00154 #define __P(p) p
00155 #endif
00156 
00157 #include <alloca.h>
00158 #include <strings.h>
00159 #include <string.h>
00160 #include <pthread.h>
00161 #include <sys/stat.h>
00162 #include <signal.h>
00163 #include <netinet/in.h>
00164 #include <sys/loadavg.h>
00165 #include <dat/dat_platform_specific.h>
00166 
00167 #ifndef BYTE_ORDER
00168 #define LITTLE_ENDIAN   1234
00169 #define BIG_ENDIAN   4321
00170 
00171 #ifdef __sparc__
00172 #define BYTE_ORDER   BIG_ENDIAN
00173 #else
00174 #define BYTE_ORDER   LITTLE_ENDIAN
00175 #endif
00176 #endif
00177 
00178 #ifndef __BYTE_ORDER
00179 #define __LITTLE_ENDIAN LITTLE_ENDIAN
00180 #define __BIG_ENDIAN BIG_ENDIAN
00181 #define __BYTE_ORDER BYTE_ORDER
00182 #endif
00183 
00184 #ifndef __BIT_TYPES_DEFINED__
00185 #define __BIT_TYPES_DEFINED__
00186 typedef unsigned char   u_int8_t;
00187 typedef unsigned short  u_int16_t;
00188 typedef unsigned int u_int32_t;
00189 typedef unsigned int uint;
00190 #endif
00191 
00192 #endif /* SOLARIS */
00193 
00194 #ifdef __CYGWIN__
00195 #define _WIN32_WINNT 0x0500
00196 #ifndef INET_ADDRSTRLEN
00197 #define INET_ADDRSTRLEN  16
00198 #endif
00199 #ifndef INET6_ADDRSTRLEN
00200 #define INET6_ADDRSTRLEN 46
00201 #endif
00202 #endif /* __CYGWIN__ */
00203 
00204 #ifdef __CYGWIN__
00205 typedef unsigned long long uint64_t;
00206 #endif
00207 
00208 /* glob compat stuff */ 
00209 #if defined(__Darwin__) || defined(__CYGWIN__)
00210 #define GLOB_ABORTED GLOB_ABEND
00211 #endif
00212 #include <glob.h>
00213 #if !defined(HAVE_GLOB_NOMAGIC) || !defined(HAVE_GLOB_BRACE)
00214 #define MY_GLOB_FLAGS   GLOB_NOCHECK
00215 #else
00216 #define MY_GLOB_FLAGS   (GLOB_NOMAGIC | GLOB_BRACE)
00217 #endif
00218 
00219 #ifndef HAVE_ROUNDF
00220 #ifdef HAVE_ROUND
00221 #define roundf(x) ((float)round(x))
00222 #else
00223 float roundf(float x);
00224 #endif
00225 #endif
00226 
00227 #ifndef INFINITY
00228 #define INFINITY (1.0/0.0)
00229 #endif
00230 
00231 #ifndef NAN
00232 #define NAN (0.0/0.0)
00233 #endif
00234 
00235 #endif

Generated on Thu Apr 16 06:27:30 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6