This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [patch/rfc] Add host's floatformat
- From: Andrew Cagney <cagney at gnu dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 29 Jul 2004 15:35:44 -0400
- Subject: Re: [patch/rfc] Add host's floatformat
- References: <40939DD4.3000706@gnu.org>
Hello,
This patch adds the host's floatformat (when known) to floatformat.[hc]. It lets us wack of a heap of bogus code in GDB's configury.
I've checked this in. Differences from the original:
- GDB handles this locally
- GDB_HOST_... instead of just HOST_... in names
- per MarkK's suggestion, the bulk of the logic is in configure.host
I'll follow up by pruning some now dead xm files.
Andrew
2004-07-29 Andrew Cagney <cagney@gnu.org>
* config/pa/xm-linux.h: Do not include "floatformat.h".
(HOST_FLOAT_FORMAT, HOST_DOUBLE_FORMAT)
(HOST_LONG_DOUBLE_FORMAT): Delete macros.
* config/i386/xm-i386.h: Do not include "floatformat.h".
(HOST_FLOAT_FORMAT, HOST_DOUBLE_FORMAT)
(HOST_LONG_DOUBLE_FORMAT): Delete macros.
* doublest.c (HOST_FLOAT_FORMAT, HOST_DOUBLE_FORMAT)
(HOST_LONG_DOUBLE_FORMAT): Delete macros. Use
GDB_HOST_FLOAT_FORMAT, GDB_HOST_DOUBLE_FORMAT and
GDB_HOST_LONG_DOUBLE_FORMAT instead.
* configure.in (GDB_HOST_FLOAT_FORMAT, GDB_HOST_DOUBLE_FORMAT)
(GDB_HOST_LONG_DOUBLE_FORMAT): Define.
* configure, config.in: Regenerate.
* configure.host (gdb_host_float_format, gdb_host_double_format)
(gdb_host_long_double_format): Set according to the host.
Index: config.in
===================================================================
RCS file: /cvs/src/src/gdb/config.in,v
retrieving revision 1.65
diff -p -u -r1.65 config.in
--- config.in 17 Jul 2004 11:24:26 -0000 1.65
+++ config.in 29 Jul 2004 18:44:06 -0000
@@ -540,6 +540,15 @@
/* Define if we can use the tkill syscall. */
#undef HAVE_TKILL_SYSCALL
+/* Host float floatformat */
+#undef GDB_HOST_FLOAT_FORMAT
+
+/* Host double floatformat */
+#undef GDB_HOST_DOUBLE_FORMAT
+
+/* Host long double floatformat */
+#undef GDB_HOST_LONG_DOUBLE_FORMAT
+
/* Define to the default OS ABI for this configuration. */
#undef GDB_OSABI_DEFAULT
Index: configure.host
===================================================================
RCS file: /cvs/src/src/gdb/configure.host,v
retrieving revision 1.80
diff -p -u -r1.80 configure.host
--- configure.host 26 Jun 2004 10:06:35 -0000 1.80
+++ configure.host 29 Jul 2004 18:44:06 -0000
@@ -2,8 +2,11 @@
# invoked from the autoconf generated configure script.
# This file sets the following shell variables:
-# gdb_host_cpu generic name of host's CPU
-# gdb_host name of GDB host definition to use
+# gdb_host_cpu generic name of host's CPU
+# gdb_host name of GDB host definition to use
+# gdb_host_float_format host's float floatformat, or 0
+# gdb_host_double_format host's double floatformat, or 0
+# gdb_host_long_double_format host's long double floatformat, or 0
# Map host cpu into the config cpu subdirectory name.
# The default is $host_cpu.
@@ -145,3 +148,26 @@ x86_64-*-openbsd*) gdb_host=obsd64 ;;
m32r*-*-linux*) gdb_host=linux ;;
esac
+
+
+
+# Map the host/cpu onto the floatformat correspondong to C's "float",
+# "double" and "long double" types.
+
+case "${host}" in
+i[34567]86-*-*)
+ gdb_host_float_format="&floatformat_ieee_single_little"
+ gdb_host_double_format="&floatformat_ieee_double_little"
+ gdb_host_long_double_format="&floatformat_i387_ext"
+ ;;
+hppa*-*-linux*)
+ gdb_host_float_format="&floatformat_ieee_single_big"
+ gdb_host_double_format="&floatformat_ieee_double_big"
+ gdb_host_long_double_format="&floatformat_ieee_double_big"
+ ;;
+*)
+ gdb_host_float_format=0
+ gdb_host_double_format=0
+ gdb_host_long_double_format=0
+ ;;
+esac
Index: configure.in
===================================================================
RCS file: /cvs/src/src/gdb/configure.in,v
retrieving revision 1.158
diff -p -u -r1.158 configure.in
--- configure.in 17 Jul 2004 11:24:24 -0000 1.158
+++ configure.in 29 Jul 2004 18:44:08 -0000
@@ -1300,6 +1300,11 @@ AC_SUBST(CONFIG_CLEAN)
AC_SUBST(CONFIG_INSTALL)
AC_SUBST(CONFIG_UNINSTALL)
+# List of host floatformats.
+AC_DEFINE_UNQUOTED(GDB_HOST_FLOAT_FORMAT,$gdb_host_float_format,[Host float floatformat])
+AC_DEFINE_UNQUOTED(GDB_HOST_DOUBLE_FORMAT,$gdb_host_double_format,[Host double floatformat])
+AC_DEFINE_UNQUOTED(GDB_HOST_LONG_DOUBLE_FORMAT,$gdb_host_long_double_format,[Host long double floatformat])
+
# target_subdir is used by the testsuite to find the target libraries.
target_subdir=
if test "${host}" != "${target}"; then
Index: doublest.c
===================================================================
RCS file: /cvs/src/src/gdb/doublest.c,v
retrieving revision 1.17
diff -p -u -r1.17 doublest.c
--- doublest.c 15 Sep 2003 21:33:44 -0000 1.17
+++ doublest.c 29 Jul 2004 18:44:08 -0000
@@ -91,10 +91,17 @@ get_field (unsigned char *data, enum flo
{
result |= (unsigned long)*(data + cur_byte) << cur_bitshift;
cur_bitshift += FLOATFORMAT_CHAR_BIT;
- if (order == floatformat_little || order == floatformat_littlebyte_bigword)
- ++cur_byte;
- else
- --cur_byte;
+ switch (order)
+ {
+ case floatformat_little:
+ ++cur_byte;
+ break;
+ case floatformat_big:
+ --cur_byte;
+ break;
+ case floatformat_littlebyte_bigword:
+ break;
+ }
}
if (len < sizeof(result) * FLOATFORMAT_CHAR_BIT)
/* Mask out bits which are not part of the field */
@@ -554,19 +561,9 @@ floatformat_mantissa (const struct float
increase precision as necessary. Otherwise, we call the conversion
routine and let it do the dirty work. */
-#ifndef HOST_FLOAT_FORMAT
-#define HOST_FLOAT_FORMAT 0
-#endif
-#ifndef HOST_DOUBLE_FORMAT
-#define HOST_DOUBLE_FORMAT 0
-#endif
-#ifndef HOST_LONG_DOUBLE_FORMAT
-#define HOST_LONG_DOUBLE_FORMAT 0
-#endif
-
-static const struct floatformat *host_float_format = HOST_FLOAT_FORMAT;
-static const struct floatformat *host_double_format = HOST_DOUBLE_FORMAT;
-static const struct floatformat *host_long_double_format = HOST_LONG_DOUBLE_FORMAT;
+static const struct floatformat *host_float_format = GDB_HOST_FLOAT_FORMAT;
+static const struct floatformat *host_double_format = GDB_HOST_DOUBLE_FORMAT;
+static const struct floatformat *host_long_double_format = GDB_HOST_LONG_DOUBLE_FORMAT;
void
floatformat_to_doublest (const struct floatformat *fmt,
Index: config/i386/xm-i386.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/xm-i386.h,v
retrieving revision 1.3
diff -p -u -r1.3 xm-i386.h
--- config/i386/xm-i386.h 22 Feb 2004 16:20:22 -0000 1.3
+++ config/i386/xm-i386.h 29 Jul 2004 18:44:08 -0000
@@ -22,10 +22,4 @@
#ifndef XM_I386_H
#define XM_I386_H
-#include "floatformat.h"
-
-#define HOST_FLOAT_FORMAT &floatformat_ieee_single_little
-#define HOST_DOUBLE_FORMAT &floatformat_ieee_double_little
-#define HOST_LONG_DOUBLE_FORMAT &floatformat_i387_ext
-
#endif /* xm-i386.h */
Index: config/pa/xm-linux.h
===================================================================
RCS file: /cvs/src/src/gdb/config/pa/xm-linux.h,v
retrieving revision 1.1
diff -p -u -r1.1 xm-linux.h
--- config/pa/xm-linux.h 29 Apr 2004 03:36:50 -0000 1.1
+++ config/pa/xm-linux.h 29 Jul 2004 18:44:08 -0000
@@ -22,10 +22,4 @@
#ifndef XM_HPPA_LINUX_H
#define XM_HPPA_LINUX_H
-#include "floatformat.h"
-
-#define HOST_FLOAT_FORMAT &floatformat_ieee_single_big
-#define HOST_DOUBLE_FORMAT &floatformat_ieee_double_big
-#define HOST_LONG_DOUBLE_FORMAT &floatformat_ieee_double_big
-
#endif /* xm-linux.h */