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