Blame sysdeps/ieee754/ieee754.h

Packit 6c4009
/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _IEEE754_H
Packit 6c4009
Packit 6c4009
#define _IEEE754_H 1
Packit 6c4009
#include <features.h>
Packit 6c4009
Packit 6c4009
#include <endian.h>
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
union ieee754_float
Packit 6c4009
  {
Packit 6c4009
    float f;
Packit 6c4009
Packit 6c4009
    /* This is the IEEE 754 single-precision format.  */
Packit 6c4009
    struct
Packit 6c4009
      {
Packit 6c4009
#if	__BYTE_ORDER == __BIG_ENDIAN
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
	unsigned int exponent:8;
Packit 6c4009
	unsigned int mantissa:23;
Packit 6c4009
#endif				/* Big endian.  */
Packit 6c4009
#if	__BYTE_ORDER == __LITTLE_ENDIAN
Packit 6c4009
	unsigned int mantissa:23;
Packit 6c4009
	unsigned int exponent:8;
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
#endif				/* Little endian.  */
Packit 6c4009
      } ieee;
Packit 6c4009
Packit 6c4009
    /* This format makes it easier to see if a NaN is a signalling NaN.  */
Packit 6c4009
    struct
Packit 6c4009
      {
Packit 6c4009
#if	__BYTE_ORDER == __BIG_ENDIAN
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
	unsigned int exponent:8;
Packit 6c4009
	unsigned int quiet_nan:1;
Packit 6c4009
	unsigned int mantissa:22;
Packit 6c4009
#endif				/* Big endian.  */
Packit 6c4009
#if	__BYTE_ORDER == __LITTLE_ENDIAN
Packit 6c4009
	unsigned int mantissa:22;
Packit 6c4009
	unsigned int quiet_nan:1;
Packit 6c4009
	unsigned int exponent:8;
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
#endif				/* Little endian.  */
Packit 6c4009
      } ieee_nan;
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
#define IEEE754_FLOAT_BIAS	0x7f /* Added to exponent.  */
Packit 6c4009
Packit 6c4009
Packit 6c4009
union ieee754_double
Packit 6c4009
  {
Packit 6c4009
    double d;
Packit 6c4009
Packit 6c4009
    /* This is the IEEE 754 double-precision format.  */
Packit 6c4009
    struct
Packit 6c4009
      {
Packit 6c4009
#if	__BYTE_ORDER == __BIG_ENDIAN
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
	unsigned int exponent:11;
Packit 6c4009
	/* Together these comprise the mantissa.  */
Packit 6c4009
	unsigned int mantissa0:20;
Packit 6c4009
	unsigned int mantissa1:32;
Packit 6c4009
#endif				/* Big endian.  */
Packit 6c4009
#if	__BYTE_ORDER == __LITTLE_ENDIAN
Packit 6c4009
# if	__FLOAT_WORD_ORDER == __BIG_ENDIAN
Packit 6c4009
	unsigned int mantissa0:20;
Packit 6c4009
	unsigned int exponent:11;
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
	unsigned int mantissa1:32;
Packit 6c4009
# else
Packit 6c4009
	/* Together these comprise the mantissa.  */
Packit 6c4009
	unsigned int mantissa1:32;
Packit 6c4009
	unsigned int mantissa0:20;
Packit 6c4009
	unsigned int exponent:11;
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
# endif
Packit 6c4009
#endif				/* Little endian.  */
Packit 6c4009
      } ieee;
Packit 6c4009
Packit 6c4009
    /* This format makes it easier to see if a NaN is a signalling NaN.  */
Packit 6c4009
    struct
Packit 6c4009
      {
Packit 6c4009
#if	__BYTE_ORDER == __BIG_ENDIAN
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
	unsigned int exponent:11;
Packit 6c4009
	unsigned int quiet_nan:1;
Packit 6c4009
	/* Together these comprise the mantissa.  */
Packit 6c4009
	unsigned int mantissa0:19;
Packit 6c4009
	unsigned int mantissa1:32;
Packit 6c4009
#else
Packit 6c4009
# if	__FLOAT_WORD_ORDER == __BIG_ENDIAN
Packit 6c4009
	unsigned int mantissa0:19;
Packit 6c4009
	unsigned int quiet_nan:1;
Packit 6c4009
	unsigned int exponent:11;
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
	unsigned int mantissa1:32;
Packit 6c4009
# else
Packit 6c4009
	/* Together these comprise the mantissa.  */
Packit 6c4009
	unsigned int mantissa1:32;
Packit 6c4009
	unsigned int mantissa0:19;
Packit 6c4009
	unsigned int quiet_nan:1;
Packit 6c4009
	unsigned int exponent:11;
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
      } ieee_nan;
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
#define IEEE754_DOUBLE_BIAS	0x3ff /* Added to exponent.  */
Packit 6c4009
Packit 6c4009
Packit 6c4009
union ieee854_long_double
Packit 6c4009
  {
Packit 6c4009
    long double d;
Packit 6c4009
Packit 6c4009
    /* This is the IEEE 854 double-extended-precision format.  */
Packit 6c4009
    struct
Packit 6c4009
      {
Packit 6c4009
#if	__BYTE_ORDER == __BIG_ENDIAN
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
	unsigned int exponent:15;
Packit 6c4009
	unsigned int empty:16;
Packit 6c4009
	unsigned int mantissa0:32;
Packit 6c4009
	unsigned int mantissa1:32;
Packit 6c4009
#endif
Packit 6c4009
#if	__BYTE_ORDER == __LITTLE_ENDIAN
Packit 6c4009
# if	__FLOAT_WORD_ORDER == __BIG_ENDIAN
Packit 6c4009
	unsigned int exponent:15;
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
	unsigned int empty:16;
Packit 6c4009
	unsigned int mantissa0:32;
Packit 6c4009
	unsigned int mantissa1:32;
Packit 6c4009
# else
Packit 6c4009
	unsigned int mantissa1:32;
Packit 6c4009
	unsigned int mantissa0:32;
Packit 6c4009
	unsigned int exponent:15;
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
	unsigned int empty:16;
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
      } ieee;
Packit 6c4009
Packit 6c4009
    /* This is for NaNs in the IEEE 854 double-extended-precision format.  */
Packit 6c4009
    struct
Packit 6c4009
      {
Packit 6c4009
#if	__BYTE_ORDER == __BIG_ENDIAN
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
	unsigned int exponent:15;
Packit 6c4009
	unsigned int empty:16;
Packit 6c4009
	unsigned int one:1;
Packit 6c4009
	unsigned int quiet_nan:1;
Packit 6c4009
	unsigned int mantissa0:30;
Packit 6c4009
	unsigned int mantissa1:32;
Packit 6c4009
#endif
Packit 6c4009
#if	__BYTE_ORDER == __LITTLE_ENDIAN
Packit 6c4009
# if	__FLOAT_WORD_ORDER == __BIG_ENDIAN
Packit 6c4009
	unsigned int exponent:15;
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
	unsigned int empty:16;
Packit 6c4009
	unsigned int mantissa0:30;
Packit 6c4009
	unsigned int quiet_nan:1;
Packit 6c4009
	unsigned int one:1;
Packit 6c4009
	unsigned int mantissa1:32;
Packit 6c4009
# else
Packit 6c4009
	unsigned int mantissa1:32;
Packit 6c4009
	unsigned int mantissa0:30;
Packit 6c4009
	unsigned int quiet_nan:1;
Packit 6c4009
	unsigned int one:1;
Packit 6c4009
	unsigned int exponent:15;
Packit 6c4009
	unsigned int negative:1;
Packit 6c4009
	unsigned int empty:16;
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
      } ieee_nan;
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif /* ieee754.h */