xref: /PHP-7.1/TSRM/tsrm_config_common.h (revision 3d3f11ed)
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 # if _WIN32
46 #  include "win32/ioutil.h"
47 #  define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
48 # elif PATH_MAX
49 #  define MAXPATHLEN PATH_MAX
50 # elif defined(MAX_PATH)
51 #  define MAXPATHLEN MAX_PATH
52 # else
53 #  define MAXPATHLEN 256
54 # endif
55 #endif
56 
57 #if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2))
58 # define TSRM_ALLOCA_MAX_SIZE 4096
59 # define TSRM_ALLOCA_FLAG(name) \
60 	int name;
61 # define tsrm_do_alloca_ex(size, limit, use_heap) \
62 	((use_heap = ((size) > (limit))) ? malloc(size) : alloca(size))
63 # define tsrm_do_alloca(size, use_heap) \
64 	tsrm_do_alloca_ex(size, TSRM_ALLOCA_MAX_SIZE, use_heap)
65 # define tsrm_free_alloca(p, use_heap) \
66 	do { if (use_heap) free(p); } while (0)
67 #else
68 # define TSRM_ALLOCA_FLAG(name)
69 # define tsrm_do_alloca(p, use_heap)	malloc(p)
70 # define tsrm_free_alloca(p, use_heap)	free(p)
71 #endif
72 
73 #endif /* TSRM_CONFIG_COMMON_H */
74