Asterisk - The Open Source Telephony Project GIT-master-7988d11
Loading...
Searching...
No Matches
asterisk/compat.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 1999-2006, Digium, Inc.
5 *
6 * Mark Spencer <markster@digium.com>
7 *
8 * This program is free software, distributed under the terms of
9 * the GNU General Public License
10 */
11
12/*! \file
13 * \brief General Definitions for Asterisk top level program
14 * Included by asterisk.h to handle platform-specific issues
15 * especially those related to header files.
16 */
17
18#ifndef _COMPAT_H
19#define _COMPAT_H
20/* IWYU pragma: private, include "asterisk.h" */
21/* IWYU pragma: begin_exports */
22
23#include "asterisk/compiler.h"
24
25#if !defined(__cplusplus) && !defined(c_plusplus)
26#ifndef __STDC_VERSION__
27/* flex output wants to find this defined. */
28#define __STDC_VERSION__ 0
29#endif
30#endif
31
32#include <inttypes.h>
33#include <limits.h>
34#include <unistd.h>
35
36#ifdef HAVE_STDDEF_H
37#include <stddef.h>
38#endif
39
40#include <stdint.h>
41#include <sys/types.h>
42#include <stdarg.h>
43#include <stdlib.h>
44
45#ifdef HAVE_ALLOCA_H
46#include <alloca.h> /* not necessarily present - could be in stdlib */
47#elif defined(HAVE_ALLOCA) && defined(__MINGW32__)
48#include <malloc.h> /* see if it is here... */
49#endif
50
51#include <stdio.h> /* this is always present */
52
53#include <string.h>
54
55#ifndef AST_POLL_COMPAT
56#include <poll.h>
57#else
59#endif
60
61#ifndef HAVE_LLONG_MAX
62#define LLONG_MAX 9223372036854775807LL
63#endif
64
65#ifndef HAVE_CLOSEFROM
66void closefrom(int lowfd);
67#endif
68
69#if !defined(HAVE_ASPRINTF)
70int __attribute__((format(printf, 2, 3))) asprintf(char **str, const char *fmt, ...);
71#endif
72
73#ifndef HAVE_FFSLL
74int ffsll(long long n);
75#endif
76
77#ifndef HAVE_GETLOADAVG
78int getloadavg(double *list, int nelem);
79#endif
80
81#ifndef HAVE_HTONLL
82uint64_t htonll(uint64_t host64);
83#endif
84
85#ifndef HAVE_MKDTEMP
86char *mkdtemp(char *template_s);
87#endif
88
89#ifndef HAVE_NTOHLL
90uint64_t ntohll(uint64_t net64);
91#endif
92
93#ifndef HAVE_SETENV
94int setenv(const char *name, const char *value, int overwrite);
95#endif
96
97#ifndef HAVE_STRCASESTR
98char *strcasestr(const char *, const char *);
99#endif
100
101#if !defined(HAVE_STRNDUP)
102char *strndup(const char *, size_t);
103#endif
104
105#ifndef HAVE_STRNLEN
106size_t strnlen(const char *, size_t);
107#endif
108
109#ifndef HAVE_STRSEP
110char* strsep(char** str, const char* delims);
111#endif
112
113#ifndef HAVE_STRTOQ
114uint64_t strtoq(const char *nptr, char **endptr, int base);
115#endif
116
117#ifndef HAVE_UNSETENV
118int unsetenv(const char *name);
119#endif
120
121#if !defined(HAVE_VASPRINTF)
122int __attribute__((format(printf, 2, 0))) vasprintf(char **strp, const char *fmt, va_list ap);
123#endif
124
125#ifndef HAVE_TIMERSUB
126void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff);
127#endif
128
129#define strlcat __use__ast_str__functions_not__strlcat__
130#define strlcpy __use__ast_copy_string__not__strlcpy__
131
132#include <errno.h>
133
134#ifdef SOLARIS
135#define __BEGIN_DECLS
136#define __END_DECLS
137
138#ifndef __P
139#define __P(p) p
140#endif
141
142#include <alloca.h>
143#include <strings.h>
144#include <pthread.h>
145#include <sys/stat.h>
146#include <signal.h>
147#include <netinet/in.h>
148#include <sys/loadavg.h>
149#include <dat/dat_platform_specific.h>
150
151#ifndef BYTE_ORDER
152#define LITTLE_ENDIAN 1234
153#define BIG_ENDIAN 4321
154
155#ifdef __sparc__
156#define BYTE_ORDER BIG_ENDIAN
157#else
158#define BYTE_ORDER LITTLE_ENDIAN
159#endif
160#endif
161
162#ifndef __BYTE_ORDER
163#define __LITTLE_ENDIAN LITTLE_ENDIAN
164#define __BIG_ENDIAN BIG_ENDIAN
165#define __BYTE_ORDER BYTE_ORDER
166#endif
167
168#ifndef __BIT_TYPES_DEFINED__
169#define __BIT_TYPES_DEFINED__
170typedef unsigned char u_int8_t;
171typedef unsigned short u_int16_t;
172typedef unsigned int u_int32_t;
173typedef unsigned int uint;
174#endif
175
176#endif /* SOLARIS */
177
178#ifdef __CYGWIN__
179#define _WIN32_WINNT 0x0500
180#ifndef INET_ADDRSTRLEN
181#define INET_ADDRSTRLEN 16
182#endif
183#ifndef INET6_ADDRSTRLEN
184#define INET6_ADDRSTRLEN 46
185#endif
186#endif /* __CYGWIN__ */
187
188#ifdef __CYGWIN__
189typedef unsigned long long uint64_t;
190#endif
191
192/* glob compat stuff */
193#if defined(__Darwin__) || defined(__CYGWIN__)
194#define GLOB_ABORTED GLOB_ABEND
195#endif
196#include <glob.h>
197#if !defined(HAVE_GLOB_NOMAGIC) || !defined(HAVE_GLOB_BRACE)
198#define MY_GLOB_FLAGS GLOB_NOCHECK
199#else
200#define MY_GLOB_FLAGS (GLOB_NOMAGIC | GLOB_BRACE)
201#endif
202
203#ifndef HAVE_ROUNDF
204#ifdef HAVE_ROUND
205#define roundf(x) ((float)round(x))
206#else
207float roundf(float x);
208#endif
209#endif
210
211#ifndef INFINITY
212#define INFINITY (1.0/0.0)
213#endif
214
215#ifndef NAN
216#define NAN (0.0/0.0)
217#endif
218/* IWYU pragma: end_exports */
219#endif
const char * str
Definition app_jack.c:150
int unsetenv(const char *name)
int setenv(const char *name, const char *value, int overwrite)
int getloadavg(double *list, int nelem)
int vasprintf(char **strp, const char *fmt, va_list ap)
void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff)
int ffsll(long long n)
uint64_t ntohll(uint64_t net64)
Definition strcompat.c:365
char * strsep(char **str, const char *delims)
char * mkdtemp(char *template_s)
void closefrom(int lowfd)
int asprintf(char **str, const char *fmt,...)
char * strndup(const char *, size_t)
uint64_t strtoq(const char *nptr, char **endptr, int base)
char * strcasestr(const char *, const char *)
size_t strnlen(const char *, size_t)
float roundf(float x)
uint64_t htonll(uint64_t host64)
Definition strcompat.c:391
Compiler-specific macros and other items.
static const char name[]
Definition format_mp3.c:68
unsigned int u_int32_t
unsigned short u_int16_t
unsigned char u_int8_t
String manipulation functions.
int value
Definition syslog.c:37