00001 00006 /* 00007 * Copyright 2004-2006 Intel Corporation 00008 * 00009 * Licensed under the Apache License, Version 2.0 (the "License"); 00010 * you may not use this file except in compliance with the License. 00011 * You may obtain a copy of the License at 00012 * 00013 * http://www.apache.org/licenses/LICENSE-2.0 00014 * 00015 * Unless required by applicable law or agreed to in writing, software 00016 * distributed under the License is distributed on an "AS IS" BASIS, 00017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00018 * See the License for the specific language governing permissions and 00019 * limitations under the License. 00020 */ 00021 00022 /*- 00023 * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org> 00024 * Copyright (c) 2002 David Schultz <das@FreeBSD.ORG> 00025 * All rights reserved. 00026 * 00027 * Redistribution and use in source and binary forms, with or without 00028 * modification, are permitted provided that the following conditions 00029 * are met: 00030 * 1. Redistributions of source code must retain the above copyright 00031 * notice, this list of conditions and the following disclaimer. 00032 * 2. Redistributions in binary form must reproduce the above copyright 00033 * notice, this list of conditions and the following disclaimer in the 00034 * documentation and/or other materials provided with the distribution. 00035 * 00036 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 00037 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00038 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00039 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 00040 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00041 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00042 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00043 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00044 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00045 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00046 * SUCH DAMAGE. 00047 * 00048 * $FreeBSD: src/lib/libc/include/fpmath.h,v 1.3 2005/02/06 03:23:31 das Exp $ 00049 */ 00050 00051 //#include <sys/endian.h> 00052 00053 #ifdef __i386__ 00054 #include "_fpmath-i386.h" 00055 #elif defined(__POWERPC__) || defined(PPC) 00056 #include "_fpmath-powerpc.h" 00057 #elif defined(__arm__) 00058 #include "_fpmath-arm.h" 00059 #elif defined(__amd64__) 00060 #include "_fpmath-amd64.h" 00061 #endif 00062 00063 union IEEEf2bits { 00064 float f; 00065 struct { 00066 #if _BYTE_ORDER == _LITTLE_ENDIAN 00067 unsigned int man :23; 00068 unsigned int exp :8; 00069 unsigned int sign :1; 00070 #else /* _BIG_ENDIAN */ 00071 unsigned int sign :1; 00072 unsigned int exp :8; 00073 unsigned int man :23; 00074 #endif 00075 } bits; 00076 }; 00077 00078 #define DBL_MANH_SIZE 20 00079 #define DBL_MANL_SIZE 32 00080 00081 union IEEEd2bits { 00082 double d; 00083 struct { 00084 #if _BYTE_ORDER == _LITTLE_ENDIAN 00085 unsigned int manl :32; 00086 unsigned int manh :20; 00087 unsigned int exp :11; 00088 unsigned int sign :1; 00089 #else /* _BIG_ENDIAN */ 00090 unsigned int sign :1; 00091 unsigned int exp :11; 00092 unsigned int manh :20; 00093 unsigned int manl :32; 00094 #endif 00095 } bits; 00096 };