gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, long-double, updated. ecf5161fabf105c8a5


From: John Haque
Subject: [gawk-diffs] [SCM] gawk branch, long-double, updated. ecf5161fabf105c8a50834e5bbc7ada5b322ce03
Date: Sun, 20 Jan 2013 13:39:08 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, long-double has been updated
       via  ecf5161fabf105c8a50834e5bbc7ada5b322ce03 (commit)
      from  11961fbf6bc7340892176ea4911ba5ea2c130296 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=ecf5161fabf105c8a50834e5bbc7ada5b322ce03

commit ecf5161fabf105c8a50834e5bbc7ada5b322ce03
Author: John Haque <address@hidden>
Date:   Sun Jan 20 07:33:11 2013 -0600

    Added facilities to use gcc __float128 as long double -- only for testing.

diff --git a/Makefile.am b/Makefile.am
index c7969d2..00d1b2c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -132,7 +132,7 @@ base_sources = \
        version.c \
        xalloc.h
 
-gawk_SOURCES = $(base_sources)
+gawk_SOURCES = $(base_sources) float128.c
 
 # Get extra libs as needed, Automake will supply LIBINTL and SOCKET_LIBS.
 LDADD = $(LIBSIGSEGV) $(LIBINTL) $(SOCKET_LIBS) @LIBREADLINE@ @LIBMPFR@
diff --git a/Makefile.in b/Makefile.in
index 82c8a92..243af73 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -115,7 +115,7 @@ am__objects_1 = array.$(OBJEXT) awkgram.$(OBJEXT) 
builtin.$(OBJEXT) \
        random.$(OBJEXT) re.$(OBJEXT) regex.$(OBJEXT) \
        replace.$(OBJEXT) str_array.$(OBJEXT) symbol.$(OBJEXT) \
        version.$(OBJEXT)
-am_gawk_OBJECTS = $(am__objects_1)
+am_gawk_OBJECTS = $(am__objects_1) float128.$(OBJEXT)
 gawk_OBJECTS = $(am_gawk_OBJECTS)
 gawk_LDADD = $(LDADD)
 am__DEPENDENCIES_1 =
@@ -465,7 +465,7 @@ base_sources = \
        version.c \
        xalloc.h
 
-gawk_SOURCES = $(base_sources)
+gawk_SOURCES = $(base_sources) float128.c
 
 # Get extra libs as needed, Automake will supply LIBINTL and SOCKET_LIBS.
 LDADD = $(LIBSIGSEGV) $(LIBINTL) $(SOCKET_LIBS) @LIBREADLINE@ @LIBMPFR@
@@ -598,6 +598,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
address@hidden@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
diff --git a/awk.h b/awk.h
index bd2a2ce..4aec8b5 100644
--- a/awk.h
+++ b/awk.h
@@ -861,8 +861,6 @@ typedef struct exp_instruction {
 /* Op_store_var */
 #define initval         x.xn
 
-
-#if ! (defined(TEST_NUMBR) && TEST_NUMBR == 1)
 #if SIZEOF_UNSIGNED_LONG == 8
 typedef long gawk_int_t;
 typedef unsigned long gawk_uint_t;
@@ -887,15 +885,6 @@ typedef unsigned int gawk_uint_t;
 #define        GAWK_UINT_MAX   UINT_MAX
 #endif
 #endif
-#else /* TEST_NUMBR */
-/* XXX: think twice before using these for any other purpose. */
-typedef long long gawk_int_t;
-typedef unsigned long long gawk_uint_t;
-#define SIZEOF_GAWK_INT        8
-#define        GAWK_INT_MAX    LLONG_MAX
-#define        GAWK_INT_MIN    LLONG_MIN
-#define        GAWK_UINT_MAX   ULLONG_MAX
-#endif /* TEST_NUMBR */
 
 
 typedef struct {
diff --git a/configure b/configure
index e027d3a..3d80b0d 100755
--- a/configure
+++ b/configure
@@ -5555,7 +5555,14 @@ $as_echo "yes" >&6; }
 else
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-       CFLAGS="$CFLAGS"        # DONOT TURN OF ASSERTIONS
+       if test -f $srcdir/.dev
+       then
+               CFLAGS="$CFLAGS -DLDBLTEST=1"   # DO NOT TURN OFF ASSERTIONS
+#              cp $srcdir/misc/float128.c $srcdir/
+#              sed -i 's/^gawk_SOURCES = $(base_sources)$/& float128.c/' 
$srcdir/Makefile.am
+       else
+               CFLAGS="$CFLAGS -DNDEBUG"       # turn off assertions
+       fi
 fi
 
 
diff --git a/configure.ac b/configure.ac
index e8686e0..2a13506 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,7 +95,14 @@ then
        AC_MSG_RESULT([yes])
 else
        AC_MSG_RESULT([no])
-       CFLAGS="$CFLAGS"        # DONOT TURN OF ASSERTIONS
+       if test -f $srcdir/.dev
+       then
+               CFLAGS="$CFLAGS -DLDBLTEST=1"   # DO NOT TURN OFF ASSERTIONS
+#              cp $srcdir/misc/float128.c $srcdir/
+#              sed -i 's/^gawk_SOURCES = $(base_sources)$/& float128.c/' 
$srcdir/Makefile.am
+       else
+               CFLAGS="$CFLAGS -DNDEBUG"       # turn off assertions
+       fi
 fi
 
 AC_SUBST(CFLAGS)
diff --git a/float128.c b/float128.c
new file mode 100644
index 0000000..0910a68
--- /dev/null
+++ b/float128.c
@@ -0,0 +1,112 @@
+#include "awk.h"
+
+#if defined(LDBLTEST) && LDBLTEST == 1
+#include <math.h>
+#include "random.h"
+#if 0
+#include "floatmagic.h"        /* definition of isnan -- XXX: only for float 
or double or long double */
+#endif
+
+#include "format.h"
+
+/* XXX: No libquadmath, and don't want or need it anyway. */
+
+/*
+ * Macros copied from quadmath.h
+ *     https://github.com/mirrors/gcc/blob/master/libquadmath/quadmath.h
+ */
+
+#define FLT128_MAX 1.18973149535723176508575932662800702e4932Q
+#define FLT128_MIN 3.36210314311209350626267781732175260e-4932Q
+#define FLT128_EPSILON 1.92592994438723585305597794258492732e-34Q
+#define FLT128_DENORM_MIN 6.475175119438025110924438958227646552e-4966Q
+#define FLT128_MANT_DIG 113
+#define FLT128_MIN_EXP (-16381)
+#define FLT128_MAX_EXP 16384
+#define FLT128_DIG 33
+#define FLT128_MIN_10_EXP (-4931)
+#define FLT128_MAX_10_EXP 4932
+
+/* #define HUGE_VALQ __builtin_huge_valq() */
+/* The following alternative is valid, but brings the warning:
+   (floating constant exceeds range of ‘__float128’)  */
+#define HUGE_VALQ (__extension__ 0x1.0p32767Q)
+
+/* end of Macros from quadmath.h */
+
+#define LDBL_FRAC_BITS FLT128_MANT_DIG
+
+#define AWKLDBL        __float128
+#define LDBL_VAL(n)    (*((AWKLDBL *) (n)->qnumbr))
+#define LDC(x)         x##Q
+
+#define        LDBL_INT_BITS   128
+
+#define get_long_double(d)     emalloc(d, void *, sizeof(AWKLDBL), "float128")
+#define free_long_double(d)    efree(d)
+
+static int format_float_1(char *str, size_t size, const char *format, ...);
+static AWKLDBL double_to_int(AWKLDBL);
+
+static inline AWKLDBL
+gawk_strtold(const char *str, char **endptr)
+{
+#ifdef HAVE_STRTOLD
+       return strtold(str, endptr);
+#else
+       return strtod(str, endptr);
+#endif
+}
+
+/* Define isnan() and isinf() before including the two files */
+
+static inline int isnan_awkldbl(AWKLDBL x) { return x != x; }
+#ifdef isnan
+#undef isnan
+#endif
+#define isnan isnan_awkldbl
+
+static inline int isinf_awkldbl(AWKLDBL x) { return isnan(x - x); }
+#ifdef isinf
+#undef isinf
+#endif
+#define isinf isinf_awkldbl
+
+#define GAWK_INFINITY  HUGE_VALQ
+#define GAWK_NAN       (LDC(0.0Q) / LDC(0.0Q))
+
+
+#ifdef HAVE_FLOORL
+#undef HAVE_FLOORL
+#endif
+#ifdef HAVE_CEILL
+#undef HAVE_CEILL
+#endif
+#ifdef PRINTF_HAS_LF_FORMAT
+#undef PRINTF_HAS_LF_FORMAT
+#endif
+
+numbr_handler_t float128_hndlr;
+
+#define awkldbl_hndlr float128_hndlr
+
+#define gawk_int_t long long
+#define gawk_uint_t unsigned long long
+#ifdef SIZEOF_GAWK_INT
+#undef SIZEOF_GAWK_INT
+#undef GAWK_INT_MAX
+#undef GAWK_INT_MIN
+#undef GAWK_UINT_MAX
+#endif
+
+#define SIZEOF_GAWK_INT        8
+#define        GAWK_INT_MAX    LLONG_MAX
+#define        GAWK_INT_MIN    LLONG_MIN
+#define        GAWK_UINT_MAX   ULLONG_MAX
+
+#define TEST_NUMBR 1
+
+#include "misc/gawk_math.h"
+#include "long_double.h"
+
+#endif /* LDBLTEST == 1 */
diff --git a/long_double.c b/long_double.c
index ca2b206..a2fc40e 100644
--- a/long_double.c
+++ b/long_double.c
@@ -220,3 +220,15 @@ awkldbl_init(bltin_t **bltins)
        return false;
 }
 #endif
+
+
+numbr_handler_t *
+get_ldbl_handler(char *arg)
+{
+#if defined(LDBLTEST) && LDBLTEST == 1
+       extern numbr_handler_t float128_hndlr;
+       if (arg != NULL && arg[0] == '1')
+               return & float128_hndlr;
+#endif
+       return  & awkldbl_hndlr;
+}
diff --git a/main.c b/main.c
index a22429c..7857c42 100644
--- a/main.c
+++ b/main.c
@@ -62,6 +62,8 @@ static void print_numbr_hndlr_versions(void);
 extern int debug_prog(INSTRUCTION *pc); /* debug.c */
 extern int init_debug(void);   /* debug.c */
 extern void init_parser(const bltin_t *);      /* awkgram.c */
+extern numbr_handler_t *get_ldbl_handler(char *arg);
+
 
 /* These nodes store all the special variables AWK uses */
 NODE *ARGC_node, *ARGIND_node, *ARGV_node, *BINMODE_node, *CONVFMT_node;
@@ -204,7 +206,7 @@ main(int argc, char **argv)
        /*
         * The + on the front tells GNU getopt not to rearrange argv.
         */
-       const char *optlist = 
"+F:f:v:W;m:bcCd::D::e:E:gh:i:l:L:nNo::Op::BMPrStVY";
+       const char *optlist = 
"+F:f:v:W;m:bcCd::D::e:E:gh:i:l:L:nNo::Op::B::MPrStVY";
        bool stopped_early = false;
        int old_optind;
        int i;
@@ -368,7 +370,7 @@ main(int argc, char **argv)
                        break;
 
                case 'B':
-                       numbr_hndlr = & awkldbl_hndlr;
+                       numbr_hndlr = get_ldbl_handler(optarg);
                        break;
                        
                case 'c':
diff --git a/misc/gawk_math.h b/misc/gawk_math.h
new file mode 100644
index 0000000..e34bfae
--- /dev/null
+++ b/misc/gawk_math.h
@@ -0,0 +1,88 @@
+static AWKLDBL gawk_sinl(AWKLDBL x);
+static AWKLDBL gawk_cosl(AWKLDBL x);
+static AWKLDBL gawk_atan2l(AWKLDBL y, AWKLDBL x);
+static AWKLDBL gawk_logl(AWKLDBL x);
+static AWKLDBL gawk_expl(AWKLDBL x);
+static AWKLDBL gawk_fmodl(AWKLDBL x, AWKLDBL y);
+static AWKLDBL gawk_powl(AWKLDBL x, AWKLDBL y);
+static AWKLDBL gawk_sqrtl(AWKLDBL x);
+
+static AWKLDBL
+gawk_sinl(AWKLDBL x)
+{
+#ifdef HAVE_SINL
+       return sinl( (long double) x);
+#else
+       return sin( (double) x);
+#endif
+}
+
+static AWKLDBL
+gawk_cosl(AWKLDBL x)
+{
+#ifdef HAVE_COSL
+       return cosl( (long double) x);
+#else
+       return cos( (double) x);
+#endif
+}
+
+static AWKLDBL
+gawk_atan2l(AWKLDBL y, AWKLDBL x)
+{
+#ifdef HAVE_ATAN2L
+       return atan2l( (long double) y, (long double) x);
+#else
+       return atan2( (double) y, (double) x);
+#endif
+}
+
+static AWKLDBL
+gawk_logl(AWKLDBL x)
+{
+#ifdef HAVE_LOGL
+       return logl( (long double) x);
+#else
+       return log( (double) x);
+#endif
+}
+
+static AWKLDBL
+gawk_expl(AWKLDBL x)
+{
+#ifdef HAVE_LOGL
+       return expl( (long double) x);
+#else
+       return exp( (double) x);
+#endif
+}
+
+static AWKLDBL
+gawk_fmodl(AWKLDBL x, AWKLDBL y)
+{
+#ifdef HAVE_FMODL
+       return fmodl( (long double) x, (long double) y);
+#else
+       return fmod( (double) x, (double) y);
+#endif
+}
+
+static AWKLDBL
+gawk_powl(AWKLDBL x, AWKLDBL y)
+{
+#ifdef HAVE_POWL
+       return powl( (long double) x, (long double) y);
+#else
+       return pow( (double) x, (double) y);
+#endif
+}
+
+static AWKLDBL
+gawk_sqrtl(AWKLDBL x)
+{
+#ifdef HAVE_SQRTL
+       return sqrtl( (long double) x);
+#else
+       return sqrt( (double) x);
+#endif 
+}

-----------------------------------------------------------------------

Summary of changes:
 Makefile.am      |    2 +-
 Makefile.in      |    5 +-
 awk.h            |   11 -----
 configure        |    9 ++++-
 configure.ac     |    9 ++++-
 float128.c       |  112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 long_double.c    |   12 ++++++
 main.c           |    6 ++-
 misc/gawk_math.h |   88 ++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 236 insertions(+), 18 deletions(-)
 create mode 100644 float128.c
 create mode 100644 misc/gawk_math.h


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]