fpmath.h revision 4d77c1151c40010d137e4a2fa8629bff4bea72b0
11dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/*- 21dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org> 31dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Copyright (c) 2002 David Schultz <das@FreeBSD.ORG> 41dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * All rights reserved. 51dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 61dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Redistribution and use in source and binary forms, with or without 71dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * modification, are permitted provided that the following conditions 81dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * are met: 91dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 1. Redistributions of source code must retain the above copyright 101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * notice, this list of conditions and the following disclaimer. 111dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * notice, this list of conditions and the following disclaimer in the 131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * documentation and/or other materials provided with the distribution. 141dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 151dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 161dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 171dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 181dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 191dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 201dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 211dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 221dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 231dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 241dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 251dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * SUCH DAMAGE. 261dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 271dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * $FreeBSD: src/lib/libc/include/fpmath.h,v 1.3 2005/02/06 03:23:31 das Exp $ 281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 291dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 304d77c1151c40010d137e4a2fa8629bff4bea72b0Calin Juravle#ifndef _FPMATH_ 314d77c1151c40010d137e4a2fa8629bff4bea72b0Calin Juravle#define _FPMATH_ 324d77c1151c40010d137e4a2fa8629bff4bea72b0Calin Juravle 331dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <endian.h> 341dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include "_fpmath.h" 351dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 361dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectunion IEEEf2bits { 371dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project float f; 381dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project struct { 391dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if __BYTE_ORDER == __LITTLE_ENDIAN 401dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int man :23; 411dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int exp :8; 421dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int sign :1; 431dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else /* _BIG_ENDIAN */ 441dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int sign :1; 451dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int exp :8; 461dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int man :23; 471dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 481dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project } bits; 491dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project}; 501dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 511dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define DBL_MANH_SIZE 20 521dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define DBL_MANL_SIZE 32 531dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 541dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectunion IEEEd2bits { 551dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project double d; 561dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project struct { 571dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* #ifdef __ARMEB__ */ 581dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if (__BYTE_ORDER == __BIG_ENDIAN) || (defined(__arm__) && !defined(__VFP_FP__)) 591dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int manh :20; 601dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int exp :11; 611dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int sign :1; 621dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int manl :32; 63a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#elif __BYTE_ORDER == __LITTLE_ENDIAN 641dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int manl :32; 651dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int manh :20; 661dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int exp :11; 671dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int sign :1; 681dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#elif __BYTE_ORDER == __BIG_ENDIAN 691dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int sign :1; 701dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int exp :11; 711dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int manh :20; 721dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project unsigned int manl :32; 731dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 741dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project } bits; 751dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project}; 76a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes 77a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes/* 78a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes * The BSD "long double" functions are broken when sizeof(long double) == sizeof(double). 79a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes * Android works around those cases by replacing the broken functions with our own trivial stubs 80a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes * that call the regular "double" function. 81a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes */ 824d77c1151c40010d137e4a2fa8629bff4bea72b0Calin Juravle#ifndef __LP64__ 834d77c1151c40010d137e4a2fa8629bff4bea72b0Calin Juravle 84a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#define __fpclassifyl __broken__fpclassify 85a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#define __isfinitel __broken__isfinitel 86a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#define __isinfl __broken__isinfl 87a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#define __isnanl __broken__isnanl 88a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#define __isnormall __broken__isnormall 89a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#define __signbitl __broken_signbitl 904d77c1151c40010d137e4a2fa8629bff4bea72b0Calin Juravle 914d77c1151c40010d137e4a2fa8629bff4bea72b0Calin Juravle#endif // __LP64__ 924d77c1151c40010d137e4a2fa8629bff4bea72b0Calin Juravle 934d77c1151c40010d137e4a2fa8629bff4bea72b0Calin Juravle#endif // _FPMATH_ 94