15a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes/* 25a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * Copyright (C) 2014 The Android Open Source Project 35a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * All rights reserved. 45a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * 55a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * Redistribution and use in source and binary forms, with or without 65a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * modification, are permitted provided that the following conditions 75a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * are met: 85a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * * Redistributions of source code must retain the above copyright 95a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * notice, this list of conditions and the following disclaimer. 105a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * * Redistributions in binary form must reproduce the above copyright 115a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * notice, this list of conditions and the following disclaimer in 125a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * the documentation and/or other materials provided with the 135a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * distribution. 145a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * 155a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 165a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 175a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 185a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 195a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 205a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 215a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 225a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 235a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 245a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 255a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 265a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes * SUCH DAMAGE. 275a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes */ 285a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes 2920828db758f05fc4a98a45adaeb4700cfe780112Elliott Hughes#include <float.h> 305a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes#include <stdlib.h> 315a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes 324bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesextern "C" int __strtorQ(const char*, char**, int, void*); 334bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 345a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hugheslong double strtold(const char* s, char** end_ptr) { 354bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#if __LP64__ 364bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes long double result; 3720828db758f05fc4a98a45adaeb4700cfe780112Elliott Hughes __strtorQ(s, end_ptr, FLT_ROUNDS, &result); 384bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes return result; 394bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#else 404bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes // This is fine for LP32 where long double is just double. 415a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes return strtod(s, end_ptr); 424bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif 435a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughes} 44