synthesize-float   [plain text]


#!/bin/sh
#
# Synthesize float.h to be installed in the the system.
#
# This used to do all sorts of things, but now it just makes one change
# to support FLT_ROUNDS.
#
# This script is only called from the top-level GNUmakefile.  It
# is called as follows:
#
# synthesize_float $(SRCROOT) file $(RC_RELEASE)
#
# i.e., it will process $(SRCROOT)/gcc/config/float.h and
# and output the header into the file.
#
cat <<EOF >"$2"
/* float.h */
#ifndef _FLOAT_H_
#define _FLOAT_H_

/* APPLE LOCAL begin MW compatibility */
/* Define various characteristics of floating-point types, if needed.  */
#ifdef __MWERKS__
#ifndef __FLT_RADIX__   
#define __FLT_RADIX__ 2
#endif
#ifndef __FLT_MANT_DIG__
#define __FLT_MANT_DIG__ 24
#endif
#ifndef __FLT_DIG__
#define __FLT_DIG__ 6
#endif
#ifndef __FLT_EPSILON__
#define __FLT_EPSILON__ 1.19209290e-07F
#endif
#ifndef __FLT_MIN__
#define __FLT_MIN__ 1.17549435e-38F
#endif
#ifndef __FLT_MAX__
#define __FLT_MAX__ 3.40282347e+38F
#endif
#ifndef __FLT_MIN_EXP__
#define __FLT_MIN_EXP__ (-125)
#endif
#ifndef __FLT_MIN_10_EXP__
#define __FLT_MIN_10_EXP__ (-37)
#endif
#ifndef __FLT_MAX_EXP__
#define __FLT_MAX_EXP__ 128
#endif
#ifndef __FLT_MAX_10_EXP__
#define __FLT_MAX_10_EXP__ 38
#endif
#ifndef __DBL_MANT_DIG__
#define __DBL_MANT_DIG__ 53
#endif
#ifndef __DBL_DIG__
#define __DBL_DIG__ 15
#endif
#ifndef __DBL_EPSILON__
#define __DBL_EPSILON__ 2.2204460492503131e-16
#endif
#ifndef __DBL_MIN__
#define __DBL_MIN__ 2.2250738585072014e-308
#endif
#ifndef __DBL_MAX__
#define __DBL_MAX__ 1.7976931348623157e+308
#endif
#ifndef __DBL_MIN_EXP__
#define __DBL_MIN_EXP__ (-1021)
#endif
#ifndef __DBL_MIN_10_EXP__
#define __DBL_MIN_10_EXP__ (-307)
#endif
#ifndef __DBL_MAX_EXP__
#define __DBL_MAX_EXP__ 1024
#endif
#ifndef __DBL_MAX_10_EXP__
#define __DBL_MAX_10_EXP__ 308
#endif
#ifndef __LDBL_MANT_DIG__
#define __LDBL_MANT_DIG__ 53
#endif
#ifndef __LDBL_DIG__  
#define __LDBL_DIG__ 15 
#endif
#ifndef __LDBL_EPSILON__
#define __LDBL_EPSILON__ 2.2204460492503131e-16
#endif
#ifndef __LDBL_MIN__
#define __LDBL_MIN__ 2.2250738585072014e-308
#endif
#ifndef __LDBL_MAX__
#define __LDBL_MAX__ 1.7976931348623157e+308
#endif
#ifndef __LDBL_MIN_EXP__
#define __LDBL_MIN_EXP__ (-1021)
#endif
#ifndef __LDBL_MIN_10_EXP__
#define __LDBL_MIN_10_EXP__ (-307)
#endif
#ifndef __LDBL_MAX_EXP__
#define __LDBL_MAX_EXP__ 1024
#endif
#ifndef __LDBL_MAX_10_EXP__
#define __LDBL_MAX_10_EXP__ 308
#endif
#endif /* __MWERKS__ */
/* APPLE LOCAl end MW compatibility */

EOF

cat "$1"/gcc/ginclude/float.h | grep -v _FLOAT_H___ >>"$2"

cat <<EOF >/tmp/fegetfltrounds$$.c
extern int __fegetfltrounds (void);
int main()
{
  return __fegetfltrounds ();
}
EOF

set -x
if [ "$3" != "Proton" ]; then
    if cc /tmp/fegetfltrounds$$.c -o /tmp/xfegetfltrounds.$$ &> /dev/null; then
cat <<EOF >>"$2"

#ifdef __cplusplus
extern "C" {
#endif
extern int __fegetfltrounds( void ); 
#ifdef __cplusplus
}
#endif
#undef FLT_ROUNDS
#define FLT_ROUNDS (__fegetfltrounds ())
EOF
    fi
    rm -f /tmp/fegetfltrounds$$.c /tmp/xfegetfltrounds.$$
fi

cat <<EOF >>"$2"

/* APPLE LOCAL begin CW compatibility */
#ifdef __MWERKS__
/* CodeWarrior defines the following on its own.  */
#undef DECIMAL_DIG
#endif /* __MWERKS__ */
/* APPLE LOCAL end CW compatibility */

#endif /* _FLOAT_H_ */
EOF