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__) 42 #include <endian.h> 43 #endif 44 #include <math.h> 45 #include <float.h> 46 47 /* The floating point word order on ARM is big endian when floating point 48 * emulation is used, even if the byte order is little endian */ 49 #if !(defined(__APPLE__) && defined(__MACH__)) && !defined(WIN32) && \ 50 !defined(__FreeBSD__) && __FLOAT_WORD_ORDER == __BIG_ENDIAN 51 #define IEEE_MC68k 52 #else 53 #define IEEE_8087 54 #endif 55 56 #define __MATH_H__ 57 #if defined(__APPLE__) && defined(__MACH__) || defined(__FreeBSD__) 58 /* stdlib.h on FreeBSD and Apple's 10.5 and later SDKs will mangle the 59 * name of strtod. If it's included after strtod is redefined as 60 * gay_strtod, it will mangle the name of gay_strtod, which is 61 * unwanted. */ 62 #include <stdlib.h> 63 64 #endif 65 /* stdlib.h on Windows adds __declspec(dllimport) to all functions when using 66 * the DLL version of the CRT (compiling with /MD or /MDd). If stdlib.h is 67 * included after strtod is redefined as gay_strtod, it will add 68 * __declspec(dllimport) to gay_strtod, which causes the compilation of 69 * gay_strtod in dtoa.c to fail. 70 */ 71 #if defined(WIN32) && defined(_DLL) 72 #include "stdlib.h" 73 #endif 74 75 /* For MinGW, turn on __NO_ISOCEXT so that its strtod doesn't get added */ 76 #ifdef __MINGW32__ 77 #define __NO_ISOCEXT 78 #endif /* __MINGW32__ */ 79 80 /* On 64-bit systems, we need to make sure that a Long is only 32 bits. */ 81 #ifdef V8_TARGET_ARCH_X64 82 #define Long int 83 #endif /* V8_TARGET_ARCH_X64 */ 84 85 /* Make sure we use the David M. Gay version of strtod(). On Linux, we 86 * cannot use the same name (maybe the function does not have weak 87 * linkage?). */ 88 #define strtod gay_strtod 89 #include "third_party/dtoa/dtoa.c" 90