Back to index

glibc  2.9
huge_val.h
Go to the documentation of this file.
00001 /* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity).
00002    Used by <stdlib.h> and <math.h> functions for overflow.
00003    ARM version.
00004    Copyright (C) 1992, 95, 96, 97, 98, 99, 2000, 2004
00005    Free Software Foundation, Inc.
00006    This file is part of the GNU C Library.
00007 
00008    The GNU C Library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Lesser General Public
00010    License as published by the Free Software Foundation; either
00011    version 2.1 of the License, or (at your option) any later version.
00012 
00013    The GNU C Library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Lesser General Public License for more details.
00017 
00018    You should have received a copy of the GNU Lesser General Public
00019    License along with the GNU C Library; if not, write to the Free
00020    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00021    02111-1307 USA.  */
00022 
00023 #ifndef _MATH_H
00024 # error "Never use <bits/huge_val.h> directly; include <math.h> instead."
00025 #endif
00026 
00027 /* IEEE positive infinity (-HUGE_VAL is negative infinity).  */
00028 
00029 #if __GNUC_PREREQ(3,3)
00030 # define HUGE_VAL  (__builtin_huge_val())
00031 #elif __GNUC_PREREQ(2,96)
00032 # define HUGE_VAL (__extension__ 0x1.0p2047)
00033 #elif defined __GNUC__
00034 
00035 # define HUGE_VAL \
00036   (__extension__                                                     \
00037    ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; })   \
00038     { __l: 0x000000007ff00000ULL }).__d)
00039 
00040 #else /* not GCC */
00041 
00042 # include <endian.h>
00043 
00044 typedef union { unsigned char __c[8]; double __d; } __huge_val_t;
00045 
00046 # if __BYTE_ORDER == __BIG_ENDIAN
00047 #  define __HUGE_VAL_bytes  { 0, 0, 0, 0, 0x7f, 0xf0, 0, 0 }
00048 # endif
00049 # if __BYTE_ORDER == __LITTLE_ENDIAN
00050 #  define __HUGE_VAL_bytes  { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 }
00051 # endif
00052 
00053 static __huge_val_t __huge_val = { __HUGE_VAL_bytes };
00054 # define HUGE_VAL    (__huge_val.__d)
00055 
00056 #endif /* GCC.  */