1 /* 2 * Copyright 2007-2008 the V8 project authors. All rights reserved. 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above 10 * copyright notice, this list of conditions and the following 11 * disclaimer in the documentation and/or other materials provided 12 * with the distribution. 13 * * Neither the name of Google Inc. nor the names of its 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 /** 31 * Dtoa needs to have a particular environment set up for it so 32 * instead of using it directly you should use this file. 33 * 34 * The way it works is that when you link with it, its definitions 35 * of dtoa, strtod etc. override the default ones. So if you fail 36 * to link with this library everything will still work, it's just 37 * subtly wrong. 38 */ 39 40 #if !(defined(__APPLE__) && defined(__MACH__)) && \ 41 !defined(WIN32) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && \ 42 !defined(__sun) 43 #include <endian.h> 44 #endif 45 #include <math.h> 46 #include <float.h> 47 48 /* The floating point word order on ARM is big endian when floating point 49 * emulation is used, even if the byte order is little endian */ 50 #if !(defined(__APPLE__) && defined(__MACH__)) && !defined(WIN32) && \ 51 !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__sun) && \ 52 __FLOAT_WORD_ORDER == __BIG_ENDIAN 53 #define IEEE_MC68k 54 #else 55 #define IEEE_8087 56 #endif 57 58 #define __MATH_H__ 59 #if defined(__APPLE__) && defined(__MACH__) || defined(__FreeBSD__) || \ 60 defined(__OpenBSD__) || defined(__sun) 61 /* stdlib.h on FreeBSD and Apple's 10.5 and later SDKs will mangle the 62 * name of strtod. If it's included after strtod is redefined as 63 * gay_strtod, it will mangle the name of gay_strtod, which is 64 * unwanted. */ 65 #include <stdlib.h> 66 67 #endif 68 /* stdlib.h on Windows adds __declspec(dllimport) to all functions when using 69 * the DLL version of the CRT (compiling with /MD or /MDd). If stdlib.h is 70 * included after strtod is redefined as gay_strtod, it will add 71 * __declspec(dllimport) to gay_strtod, which causes the compilation of 72 * gay_strtod in dtoa.c to fail. 73 */ 74 #if defined(WIN32) && defined(_DLL) 75 #include "stdlib.h" 76 #endif 77 78 /* For MinGW, turn on __NO_ISOCEXT so that its strtod doesn't get added */ 79 #ifdef __MINGW32__ 80 #define __NO_ISOCEXT 81 #endif /* __MINGW32__ */ 82 83 /* On 64-bit systems, we need to make sure that a Long is only 32 bits. */ 84 #ifdef V8_TARGET_ARCH_X64 85 #define Long int 86 #endif /* V8_TARGET_ARCH_X64 */ 87 88 /* Make sure we use the David M. Gay version of strtod(). On Linux, we 89 * cannot use the same name (maybe the function does not have weak 90 * linkage?). */ 91 #define strtod gay_strtod 92 #include "third_party/dtoa/dtoa.c" 93