xref: /PHP-5.5/TSRM/tsrm_config_common.h (revision c6a4a7ca)
1 #ifndef TSRM_CONFIG_COMMON_H
2 #define TSRM_CONFIG_COMMON_H
3 
4 #ifndef __CYGWIN__
5 # ifdef _WIN32
6 #  define TSRM_WIN32
7 # endif
8 #endif
9 
10 #ifdef TSRM_WIN32
11 # include "tsrm_config.w32.h"
12 #else
13 # include <tsrm_config.h>
14 # include <sys/param.h>
15 #endif
16 
17 #if HAVE_ALLOCA_H && !defined(_ALLOCA_H)
18 #  include <alloca.h>
19 #endif
20 
21 /* AIX requires this to be the first thing in the file.  */
22 #ifndef __GNUC__
23 # ifndef HAVE_ALLOCA_H
24 #  ifdef _AIX
25 #pragma alloca
26 #  else
27 #   ifndef alloca /* predefined by HP cc +Olibcalls */
28 #    ifndef NETWARE
29 char *alloca ();
30 #    endif
31 #   endif
32 #  endif
33 # endif
34 #endif
35 
36 #if HAVE_UNISTD_H
37 #include <unistd.h>
38 #endif
39 
40 #if HAVE_LIMITS_H
41 #include <limits.h>
42 #endif
43 
44 #ifndef MAXPATHLEN
45 # ifdef PATH_MAX
46 #  define MAXPATHLEN PATH_MAX
47 # elif defined(MAX_PATH)
48 #  define MAXPATHLEN MAX_PATH
49 # else
50 #  define MAXPATHLEN 256
51 # endif
52 #endif
53 
54 #if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2))
55 # define TSRM_ALLOCA_MAX_SIZE 4096
56 # define TSRM_ALLOCA_FLAG(name) \
57 	int name;
58 # define tsrm_do_alloca_ex(size, limit, use_heap) \
59 	((use_heap = ((size) > (limit))) ? malloc(size) : alloca(size))
60 # define tsrm_do_alloca(size, use_heap) \
61 	tsrm_do_alloca_ex(size, TSRM_ALLOCA_MAX_SIZE, use_heap)
62 # define tsrm_free_alloca(p, use_heap) \
63 	do { if (use_heap) free(p); } while (0)
64 #else
65 # define TSRM_ALLOCA_FLAG(name)
66 # define tsrm_do_alloca(p, use_heap)	malloc(p)
67 # define tsrm_free_alloca(p, use_heap)	free(p)
68 #endif
69 
70 #endif /* TSRM_CONFIG_COMMON_H */
71