xref: /PHP-7.3/TSRM/tsrm_config_common.h (revision 6a3a2bf1)
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 char *alloca ();
29 #   endif
30 #  endif
31 # endif
32 #endif
33 
34 #if HAVE_UNISTD_H
35 #include <unistd.h>
36 #endif
37 
38 #if HAVE_LIMITS_H
39 #include <limits.h>
40 #endif
41 
42 #ifndef MAXPATHLEN
43 # if _WIN32
44 #  include "win32/ioutil.h"
45 #  define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
46 # elif PATH_MAX
47 #  define MAXPATHLEN PATH_MAX
48 # elif defined(MAX_PATH)
49 #  define MAXPATHLEN MAX_PATH
50 # else
51 #  define MAXPATHLEN 256
52 # endif
53 #endif
54 
55 #if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2))
56 # define TSRM_ALLOCA_MAX_SIZE 4096
57 # define TSRM_ALLOCA_FLAG(name) \
58 	int name;
59 # define tsrm_do_alloca_ex(size, limit, use_heap) \
60 	((use_heap = ((size) > (limit))) ? malloc(size) : alloca(size))
61 # define tsrm_do_alloca(size, use_heap) \
62 	tsrm_do_alloca_ex(size, TSRM_ALLOCA_MAX_SIZE, use_heap)
63 # define tsrm_free_alloca(p, use_heap) \
64 	do { if (use_heap) free(p); } while (0)
65 #else
66 # define TSRM_ALLOCA_FLAG(name)
67 # define tsrm_do_alloca(p, use_heap)	malloc(p)
68 # define tsrm_free_alloca(p, use_heap)	free(p)
69 #endif
70 
71 #endif /* TSRM_CONFIG_COMMON_H */
72 
73 /*
74  * Local variables:
75  * tab-width: 4
76  * c-basic-offset: 4
77  * End:
78  * vim600: sw=4 ts=4 fdm=marker
79  * vim<600: sw=4 ts=4
80  */
81