xref: /PHP-7.4/Zend/zend_strtod_int.h (revision 92ac598a)
18a8264a2SAnatol Belski /*
28a8264a2SAnatol Belski    +----------------------------------------------------------------------+
38a8264a2SAnatol Belski    | Zend Engine                                                          |
48a8264a2SAnatol Belski    +----------------------------------------------------------------------+
5*a81202acSZeev Suraski    | Copyright (c) Zend Technologies Ltd. (http://www.zend.com)           |
68a8264a2SAnatol Belski    +----------------------------------------------------------------------+
78a8264a2SAnatol Belski    | This source file is subject to version 2.00 of the Zend license,     |
88a8264a2SAnatol Belski    | that is bundled with this package in the file LICENSE, and is        |
98a8264a2SAnatol Belski    | available through the world-wide-web at the following url:           |
108a8264a2SAnatol Belski    | http://www.zend.com/license/2_00.txt.                                |
118a8264a2SAnatol Belski    | If you did not receive a copy of the Zend license and are unable to  |
128a8264a2SAnatol Belski    | obtain it through the world-wide-web, please send a note to          |
138a8264a2SAnatol Belski    | license@zend.com so we can mail you a copy immediately.              |
148a8264a2SAnatol Belski    +----------------------------------------------------------------------+
158a8264a2SAnatol Belski    | Authors: Anatol Belski <ab@php.net>                                  |
168a8264a2SAnatol Belski    +----------------------------------------------------------------------+
178a8264a2SAnatol Belski */
188a8264a2SAnatol Belski 
198a8264a2SAnatol Belski #ifndef ZEND_STRTOD_INT_H
208a8264a2SAnatol Belski #define ZEND_STRTOD_INT_H
21a160a909SAnatol Belski 
22956bab05SAnatol Belski #ifdef ZTS
23956bab05SAnatol Belski #include <TSRM.h>
24956bab05SAnatol Belski #endif
25956bab05SAnatol Belski 
26956bab05SAnatol Belski #include <stddef.h>
27956bab05SAnatol Belski #include <stdio.h>
28956bab05SAnatol Belski #include <ctype.h>
29956bab05SAnatol Belski #include <stdarg.h>
30956bab05SAnatol Belski #include <math.h>
31956bab05SAnatol Belski 
32956bab05SAnatol Belski #ifdef HAVE_SYS_TYPES_H
33956bab05SAnatol Belski #include <sys/types.h>
34956bab05SAnatol Belski #endif
35956bab05SAnatol Belski 
36a160a909SAnatol Belski /* TODO check to undef this option, this might
376687e8dbSGabriel Caruso 	make more perf. destroy_freelist()
38a160a909SAnatol Belski 	should be adapted then. */
39a160a909SAnatol Belski #define Omit_Private_Memory 1
40a160a909SAnatol Belski 
41e839ed8cSAnatol Belski /* HEX strings aren't supported as per
42e839ed8cSAnatol Belski 	https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings */
43e839ed8cSAnatol Belski #define NO_HEX_FP 1
44e839ed8cSAnatol Belski 
455d4616e2SAnatol Belski #if defined(HAVE_INTTYPES_H)
465d4616e2SAnatol Belski #include <inttypes.h>
475d4616e2SAnatol Belski #elif defined(HAVE_STDINT_H)
485d4616e2SAnatol Belski #include <stdint.h>
495d4616e2SAnatol Belski #endif
505d4616e2SAnatol Belski 
515d4616e2SAnatol Belski #ifndef HAVE_INT32_T
525d4616e2SAnatol Belski # if SIZEOF_INT == 4
535d4616e2SAnatol Belski typedef int int32_t;
545d4616e2SAnatol Belski # elif SIZEOF_LONG == 4
555d4616e2SAnatol Belski typedef long int int32_t;
565d4616e2SAnatol Belski # endif
575d4616e2SAnatol Belski #endif
585d4616e2SAnatol Belski 
595d4616e2SAnatol Belski #ifndef HAVE_UINT32_T
605d4616e2SAnatol Belski # if SIZEOF_INT == 4
615d4616e2SAnatol Belski typedef unsigned int uint32_t;
625d4616e2SAnatol Belski # elif SIZEOF_LONG == 4
635d4616e2SAnatol Belski typedef unsigned long int uint32_t;
645d4616e2SAnatol Belski # endif
655d4616e2SAnatol Belski #endif
665d4616e2SAnatol Belski 
6739e59917SAnatol Belski #ifdef USE_LOCALE
6839e59917SAnatol Belski #undef USE_LOCALE
695d4616e2SAnatol Belski #endif
705d4616e2SAnatol Belski 
719f2ab75bSAnatol Belski #ifndef NO_INFNAN_CHECK
729f2ab75bSAnatol Belski #define NO_INFNAN_CHECK
739f2ab75bSAnatol Belski #endif
749f2ab75bSAnatol Belski 
759b3c26d4SAnatol Belski #ifndef NO_ERRNO
769b3c26d4SAnatol Belski #define NO_ERRNO
779b3c26d4SAnatol Belski #endif
789b3c26d4SAnatol Belski 
795d4616e2SAnatol Belski #ifdef WORDS_BIGENDIAN
80a160a909SAnatol Belski #define IEEE_BIG_ENDIAN 1
815d4616e2SAnatol Belski #else
82a160a909SAnatol Belski #define IEEE_LITTLE_ENDIAN 1
835d4616e2SAnatol Belski #endif
845d4616e2SAnatol Belski 
855d4616e2SAnatol Belski #if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__))
865d4616e2SAnatol Belski # if defined(__LITTLE_ENDIAN__)
875d4616e2SAnatol Belski #  undef WORDS_BIGENDIAN
885d4616e2SAnatol Belski # else
895d4616e2SAnatol Belski #  if defined(__BIG_ENDIAN__)
905d4616e2SAnatol Belski #   define WORDS_BIGENDIAN
915d4616e2SAnatol Belski #  endif
925d4616e2SAnatol Belski # endif
935d4616e2SAnatol Belski #endif
945d4616e2SAnatol Belski 
955d4616e2SAnatol Belski #if defined(__arm__) && !defined(__VFP_FP__)
965d4616e2SAnatol Belski /*
975d4616e2SAnatol Belski  *  * Although the CPU is little endian the FP has different
985d4616e2SAnatol Belski  *   * byte and word endianness. The byte order is still little endian
995d4616e2SAnatol Belski  *    * but the word order is big endian.
1005d4616e2SAnatol Belski  *     */
1015d4616e2SAnatol Belski #define IEEE_BIG_ENDIAN
1025d4616e2SAnatol Belski #undef IEEE_LITTLE_ENDIAN
1035d4616e2SAnatol Belski #endif
1045d4616e2SAnatol Belski 
1055d4616e2SAnatol Belski #ifdef __vax__
1065d4616e2SAnatol Belski #define VAX
1075d4616e2SAnatol Belski #undef IEEE_LITTLE_ENDIAN
1085d4616e2SAnatol Belski #endif
1095d4616e2SAnatol Belski 
110956bab05SAnatol Belski #ifdef IEEE_LITTLE_ENDIAN
111956bab05SAnatol Belski #define IEEE_8087 1
112956bab05SAnatol Belski #endif
113956bab05SAnatol Belski 
114956bab05SAnatol Belski #ifdef IEEE_BIG_ENDIAN
115956bab05SAnatol Belski #define IEEE_MC68k 1
116956bab05SAnatol Belski #endif
117956bab05SAnatol Belski 
1185d4616e2SAnatol Belski #if defined(_MSC_VER)
1198a8264a2SAnatol Belski #ifndef int32_t
1205d4616e2SAnatol Belski #define int32_t __int32
1218a8264a2SAnatol Belski #endif
1228a8264a2SAnatol Belski #ifndef uint32_t
1235d4616e2SAnatol Belski #define uint32_t unsigned __int32
1245d4616e2SAnatol Belski #endif
1258a8264a2SAnatol Belski #endif
1265d4616e2SAnatol Belski 
1275d4616e2SAnatol Belski #ifdef ZTS
1285d4616e2SAnatol Belski #define MULTIPLE_THREADS 1
1295d4616e2SAnatol Belski 
1305d4616e2SAnatol Belski #define  ACQUIRE_DTOA_LOCK(x) \
1315d4616e2SAnatol Belski 	if (0 == x) { \
1325d4616e2SAnatol Belski 		tsrm_mutex_lock(dtoa_mutex); \
1335d4616e2SAnatol Belski 	} else if (1 == x) { \
1345d4616e2SAnatol Belski 		tsrm_mutex_lock(pow5mult_mutex); \
1355d4616e2SAnatol Belski 	}
1365d4616e2SAnatol Belski 
1375d4616e2SAnatol Belski #define FREE_DTOA_LOCK(x) \
1385d4616e2SAnatol Belski 	if (0 == x) { \
1395d4616e2SAnatol Belski 		tsrm_mutex_unlock(dtoa_mutex); \
1405d4616e2SAnatol Belski 	} else if (1 == x) { \
1415d4616e2SAnatol Belski 		tsrm_mutex_unlock(pow5mult_mutex); \
1425d4616e2SAnatol Belski 	}
1436687e8dbSGabriel Caruso 
1445d4616e2SAnatol Belski 
1455d4616e2SAnatol Belski #endif
1465d4616e2SAnatol Belski 
1478a8264a2SAnatol Belski #endif /* ZEND_STRTOD_INT_H */
148