blob: a7c612cc9459c23ef86a3835f5bc38176704b655 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/*-
2 * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
3 * Copyright (c) 2002 David Schultz <das@FreeBSD.ORG>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: src/lib/libc/include/fpmath.h,v 1.3 2005/02/06 03:23:31 das Exp $
28 */
29
Calin Juravle4d77c112014-03-14 17:56:46 +000030#ifndef _FPMATH_
31#define _FPMATH_
32
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080033#include <endian.h>
34#include "_fpmath.h"
35
36union IEEEf2bits {
37 float f;
38 struct {
39#if __BYTE_ORDER == __LITTLE_ENDIAN
40 unsigned int man :23;
41 unsigned int exp :8;
42 unsigned int sign :1;
43#else /* _BIG_ENDIAN */
44 unsigned int sign :1;
45 unsigned int exp :8;
46 unsigned int man :23;
47#endif
48 } bits;
49};
50
51#define DBL_MANH_SIZE 20
52#define DBL_MANL_SIZE 32
53
54union IEEEd2bits {
55 double d;
56 struct {
57/* #ifdef __ARMEB__ */
58#if (__BYTE_ORDER == __BIG_ENDIAN) || (defined(__arm__) && !defined(__VFP_FP__))
59 unsigned int manh :20;
60 unsigned int exp :11;
61 unsigned int sign :1;
62 unsigned int manl :32;
Elliott Hughesa0ee0782013-01-30 19:06:37 -080063#elif __BYTE_ORDER == __LITTLE_ENDIAN
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080064 unsigned int manl :32;
65 unsigned int manh :20;
66 unsigned int exp :11;
67 unsigned int sign :1;
68#elif __BYTE_ORDER == __BIG_ENDIAN
69 unsigned int sign :1;
70 unsigned int exp :11;
71 unsigned int manh :20;
72 unsigned int manl :32;
73#endif
74 } bits;
75};
Elliott Hughesa0ee0782013-01-30 19:06:37 -080076
77/*
78 * The BSD "long double" functions are broken when sizeof(long double) == sizeof(double).
79 * Android works around those cases by replacing the broken functions with our own trivial stubs
80 * that call the regular "double" function.
81 */
Calin Juravle4d77c112014-03-14 17:56:46 +000082#ifndef __LP64__
83
Elliott Hughesa0ee0782013-01-30 19:06:37 -080084#define __fpclassifyl __broken__fpclassify
85#define __isfinitel __broken__isfinitel
86#define __isinfl __broken__isinfl
87#define __isnanl __broken__isnanl
88#define __isnormall __broken__isnormall
89#define __signbitl __broken_signbitl
Calin Juravle4d77c112014-03-14 17:56:46 +000090
91#endif // __LP64__
92
93#endif // _FPMATH_