xref: /PHP-7.1/Zend/zend_strtod_int.h (revision 03f3b847)
1 /*
2    +----------------------------------------------------------------------+
3    | Zend Engine                                                          |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1998-2018 Zend Technologies Ltd. (http://www.zend.com) |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 2.00 of the Zend license,     |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.zend.com/license/2_00.txt.                                |
11    | If you did not receive a copy of the Zend license and are unable to  |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@zend.com so we can mail you a copy immediately.              |
14    +----------------------------------------------------------------------+
15    | Authors: Anatol Belski <ab@php.net>                                  |
16    +----------------------------------------------------------------------+
17 */
18 
19 #ifndef ZEND_STRTOD_INT_H
20 #define ZEND_STRTOD_INT_H
21 
22 #ifdef ZTS
23 #include <TSRM.h>
24 #endif
25 
26 #include <stddef.h>
27 #include <stdio.h>
28 #include <ctype.h>
29 #include <stdarg.h>
30 #include <math.h>
31 
32 #ifdef HAVE_SYS_TYPES_H
33 #include <sys/types.h>
34 #endif
35 
36 /* TODO check to undef this option, this might
37 	make more perf. destroy_freelist()
38 	should be adapted then. */
39 #define Omit_Private_Memory 1
40 
41 /* HEX strings aren't supported as per
42 	https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings */
43 #define NO_HEX_FP 1
44 
45 #if defined(HAVE_INTTYPES_H)
46 #include <inttypes.h>
47 #elif defined(HAVE_STDINT_H)
48 #include <stdint.h>
49 #endif
50 
51 #ifndef HAVE_INT32_T
52 # if SIZEOF_INT == 4
53 typedef int int32_t;
54 # elif SIZEOF_LONG == 4
55 typedef long int int32_t;
56 # endif
57 #endif
58 
59 #ifndef HAVE_UINT32_T
60 # if SIZEOF_INT == 4
61 typedef unsigned int uint32_t;
62 # elif SIZEOF_LONG == 4
63 typedef unsigned long int uint32_t;
64 # endif
65 #endif
66 
67 #ifdef USE_LOCALE
68 #undef USE_LOCALE
69 #endif
70 
71 #ifndef NO_INFNAN_CHECK
72 #define NO_INFNAN_CHECK
73 #endif
74 
75 #ifndef NO_ERRNO
76 #define NO_ERRNO
77 #endif
78 
79 #ifdef WORDS_BIGENDIAN
80 #define IEEE_BIG_ENDIAN 1
81 #else
82 #define IEEE_LITTLE_ENDIAN 1
83 #endif
84 
85 #if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__))
86 # if defined(__LITTLE_ENDIAN__)
87 #  undef WORDS_BIGENDIAN
88 # else
89 #  if defined(__BIG_ENDIAN__)
90 #   define WORDS_BIGENDIAN
91 #  endif
92 # endif
93 #endif
94 
95 #if defined(__arm__) && !defined(__VFP_FP__)
96 /*
97  *  * Although the CPU is little endian the FP has different
98  *   * byte and word endianness. The byte order is still little endian
99  *    * but the word order is big endian.
100  *     */
101 #define IEEE_BIG_ENDIAN
102 #undef IEEE_LITTLE_ENDIAN
103 #endif
104 
105 #ifdef __vax__
106 #define VAX
107 #undef IEEE_LITTLE_ENDIAN
108 #endif
109 
110 #ifdef IEEE_LITTLE_ENDIAN
111 #define IEEE_8087 1
112 #endif
113 
114 #ifdef IEEE_BIG_ENDIAN
115 #define IEEE_MC68k 1
116 #endif
117 
118 #if defined(_MSC_VER)
119 #ifndef int32_t
120 #define int32_t __int32
121 #endif
122 #ifndef uint32_t
123 #define uint32_t unsigned __int32
124 #endif
125 #endif
126 
127 #ifdef ZTS
128 #define MULTIPLE_THREADS 1
129 
130 #define  ACQUIRE_DTOA_LOCK(x) \
131 	if (0 == x) { \
132 		tsrm_mutex_lock(dtoa_mutex); \
133 	} else if (1 == x) { \
134 		tsrm_mutex_lock(pow5mult_mutex); \
135 	}
136 
137 #define FREE_DTOA_LOCK(x) \
138 	if (0 == x) { \
139 		tsrm_mutex_unlock(dtoa_mutex); \
140 	} else if (1 == x) { \
141 		tsrm_mutex_unlock(pow5mult_mutex); \
142 	}
143 
144 
145 #endif
146 
147 #endif /* ZEND_STRTOD_INT_H */
148