110480SAndreas.Sandberg@ARM.com/* 210480SAndreas.Sandberg@ARM.com * Copyright (c) 2014, Andreas Sandberg 310480SAndreas.Sandberg@ARM.com * All rights reserved. 410480SAndreas.Sandberg@ARM.com * 510480SAndreas.Sandberg@ARM.com * Redistribution and use in source and binary forms, with or without 610480SAndreas.Sandberg@ARM.com * modification, are permitted provided that the following conditions 710480SAndreas.Sandberg@ARM.com * are met: 810480SAndreas.Sandberg@ARM.com * 910480SAndreas.Sandberg@ARM.com * 1. Redistributions of source code must retain the above copyright 1010480SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer. 1110480SAndreas.Sandberg@ARM.com * 2. Redistributions in binary form must reproduce the above 1210480SAndreas.Sandberg@ARM.com * copyright notice, this list of conditions and the following 1310480SAndreas.Sandberg@ARM.com * disclaimer in the documentation and/or other materials provided 1410480SAndreas.Sandberg@ARM.com * with the distribution. 1510480SAndreas.Sandberg@ARM.com * 1610480SAndreas.Sandberg@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1710480SAndreas.Sandberg@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1810480SAndreas.Sandberg@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 1910480SAndreas.Sandberg@ARM.com * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 2010480SAndreas.Sandberg@ARM.com * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 2110480SAndreas.Sandberg@ARM.com * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 2210480SAndreas.Sandberg@ARM.com * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 2310480SAndreas.Sandberg@ARM.com * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2410480SAndreas.Sandberg@ARM.com * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 2510480SAndreas.Sandberg@ARM.com * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2610480SAndreas.Sandberg@ARM.com * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 2710480SAndreas.Sandberg@ARM.com * OF THE POSSIBILITY OF SUCH DAMAGE. 2810480SAndreas.Sandberg@ARM.com */ 2910480SAndreas.Sandberg@ARM.com 3010480SAndreas.Sandberg@ARM.com#ifndef _FPTYPES_H 3110480SAndreas.Sandberg@ARM.com#define _FPTYPES_H 1 3210480SAndreas.Sandberg@ARM.com 3310480SAndreas.Sandberg@ARM.com#include <stdint.h> 3410480SAndreas.Sandberg@ARM.com 3510480SAndreas.Sandberg@ARM.com#ifdef __cplusplus 3610480SAndreas.Sandberg@ARM.comextern "C" { 3710480SAndreas.Sandberg@ARM.com#endif 3810480SAndreas.Sandberg@ARM.com 3910480SAndreas.Sandberg@ARM.com/** 4010480SAndreas.Sandberg@ARM.com * @addtogroup fp64 4110480SAndreas.Sandberg@ARM.com * @{ 4210480SAndreas.Sandberg@ARM.com */ 4310480SAndreas.Sandberg@ARM.com 4410480SAndreas.Sandberg@ARM.com/** Internal representation of a 64-bit float */ 4510480SAndreas.Sandberg@ARM.comtypedef union { 4610480SAndreas.Sandberg@ARM.com /** 4710480SAndreas.Sandberg@ARM.com * Raw value exposed as an unsigned integer. Mainly used for bit 4810480SAndreas.Sandberg@ARM.com * manipulation. 4910480SAndreas.Sandberg@ARM.com */ 5010480SAndreas.Sandberg@ARM.com uint64_t bits; 5110480SAndreas.Sandberg@ARM.com /** Representation using the built-in double type */ 5210480SAndreas.Sandberg@ARM.com double value; 5310480SAndreas.Sandberg@ARM.com} fp64_t; 5410480SAndreas.Sandberg@ARM.com 5510480SAndreas.Sandberg@ARM.com/** @} */ 5610480SAndreas.Sandberg@ARM.com 5710480SAndreas.Sandberg@ARM.com 5810480SAndreas.Sandberg@ARM.com/** 5910480SAndreas.Sandberg@ARM.com * @addtogroup fp80 6010480SAndreas.Sandberg@ARM.com * @{ 6110480SAndreas.Sandberg@ARM.com */ 6210480SAndreas.Sandberg@ARM.com 6310480SAndreas.Sandberg@ARM.com/** Internal representation of an 80-bit float. */ 6410480SAndreas.Sandberg@ARM.comtypedef union { 6510480SAndreas.Sandberg@ARM.com struct { 6610480SAndreas.Sandberg@ARM.com /** Raw representation of the integer part bit and the 6710480SAndreas.Sandberg@ARM.com * fraction. Note that unlike 64-bit floating point 6810480SAndreas.Sandberg@ARM.com * representations the integer bit is explicit. */ 6910480SAndreas.Sandberg@ARM.com uint64_t fi; 7010480SAndreas.Sandberg@ARM.com /** Raw representation of sign bit and exponent */ 7110480SAndreas.Sandberg@ARM.com uint16_t se; 7211708Sandreas.sandberg@arm.com /** Add explicit padding to ensure this data structure 7311708Sandreas.sandberg@arm.com * is properly aligned. 7411708Sandreas.sandberg@arm.com */ 7511708Sandreas.sandberg@arm.com uint16_t pad[3]; 7610480SAndreas.Sandberg@ARM.com } repr; 7710480SAndreas.Sandberg@ARM.com /** 7810480SAndreas.Sandberg@ARM.com * Represented as a char array, mainly intended for debug dumping 7910480SAndreas.Sandberg@ARM.com * and serialization. 8010480SAndreas.Sandberg@ARM.com */ 8111708Sandreas.sandberg@arm.com char bits[16]; 8210480SAndreas.Sandberg@ARM.com} fp80_t; 8310480SAndreas.Sandberg@ARM.com 8410480SAndreas.Sandberg@ARM.com/** @} */ 8510480SAndreas.Sandberg@ARM.com 8610480SAndreas.Sandberg@ARM.com#ifdef __cplusplus 8710480SAndreas.Sandberg@ARM.com} /* extern "C" */ 8810480SAndreas.Sandberg@ARM.com#endif 8910480SAndreas.Sandberg@ARM.com 9010480SAndreas.Sandberg@ARM.com#endif 91