[kaffe] CVS kaffe (guilhem): Bug fix for FPU on ix86/linux.

Kaffe CVS cvs-commits at kaffe.org
Wed Jun 15 03:01:10 PDT 2005


PatchSet 6644 
Date: 2005/06/15 09:56:19
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Bug fix for FPU on ix86/linux.

        * config/i386/linux/md.c
        (init_md): Setup the FP unit to use double precision and not extended
        precision.

        * configure.ac: Check for fpu_control.h

        * configure, config/config.h.in: Regenerated.

        Fixes bug reported by Daniel Bonniot <Daniel.Bonniot at inria.fr>

Members: 
	ChangeLog:1.4170->1.4171 
	configure:1.457->1.458 
	configure.ac:1.144->1.145 
	config/config.h.in:1.143->1.144 
	config/i386/linux/md.c:INITIAL->1.6 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4170 kaffe/ChangeLog:1.4171
--- kaffe/ChangeLog:1.4170	Mon Jun 13 15:44:41 2005
+++ kaffe/ChangeLog	Wed Jun 15 09:56:19 2005
@@ -1,3 +1,15 @@
+2005-06-15  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	* config/i386/linux/md.c
+	(init_md): Setup the FP unit to use double precision and not extended
+	precision.
+
+	* configure.ac: Check for fpu_control.h
+
+	* configure, config/config.h.in: Regenerated.
+
+	Fixes bug reported by Daniel Bonniot <Daniel.Bonniot at inria.fr>
+
 2005-06-13  Guilhem Lavaux  <guilhem at kaffe.org>
 
 	* kaffe/kaffevm/baseClasses.c
Index: kaffe/configure
diff -u kaffe/configure:1.457 kaffe/configure:1.458
--- kaffe/configure:1.457	Sat Jun 11 22:04:44 2005
+++ kaffe/configure	Wed Jun 15 09:56:22 2005
@@ -29827,6 +29827,7 @@
 
 
 
+
 for ac_header in stdarg.h \
 alloca.h \
 bsd/libc.h \
@@ -29875,7 +29876,8 @@
 utime.h \
 wintypes.h \
 wtypes.h \
-zlib.h
+zlib.h \
+fpu_control.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
Index: kaffe/configure.ac
diff -u kaffe/configure.ac:1.144 kaffe/configure.ac:1.145
--- kaffe/configure.ac:1.144	Sat Jun 11 22:04:49 2005
+++ kaffe/configure.ac	Wed Jun 15 09:56:28 2005
@@ -1051,7 +1051,8 @@
 utime.h \
 wintypes.h \
 wtypes.h \
-zlib.h])
+zlib.h \
+fpu_control.h])
 
 dnl GNU/Linux sigcontext headers
 AC_CHECK_HEADERS([asm/sigcontext.h])
Index: kaffe/config/config.h.in
diff -u kaffe/config/config.h.in:1.143 kaffe/config/config.h.in:1.144
--- kaffe/config/config.h.in:1.143	Fri May 13 17:08:47 2005
+++ kaffe/config/config.h.in	Wed Jun 15 09:56:29 2005
@@ -132,6 +132,9 @@
 /* Define to 1 if you have the `fork' function. */
 #undef HAVE_FORK
 
+/* Define to 1 if you have the <fpu_control.h> header file. */
+#undef HAVE_FPU_CONTROL_H
+
 /* Define to 1 if you have the `fsync' function. */
 #undef HAVE_FSYNC
 
===================================================================
Checking out kaffe/config/i386/linux/md.c
RCS:  /home/cvs/kaffe/kaffe/config/i386/linux/md.c,v
VERS: 1.6
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/config/i386/linux/md.c	Wed Jun 15 10:01:09 2005
@@ -0,0 +1,60 @@
+/*
+ * i386/linux/md.c
+ * Linux i386 specific functions.
+ *
+ * Copyright (c) 1996, 1997
+ *	Transvirtual Technologies, Inc.  All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution 
+ * of this file. 
+ */
+
+#include "config.h"
+#include "gtypes.h"
+#include "md.h"
+
+#include <malloc.h>
+#include <unistd.h>
+#include <stdio.h>
+#if defined(HAVE_FEATURES_H)
+#include <features.h>
+#endif
+
+#if defined(HAVE_FPU_CONTROL_H)
+#include <fpu_control.h>
+#endif
+
+void
+init_md(void)
+{
+#if defined(M_MMAP_MAX) && defined(HAVE_MALLOPT)
+	mallopt(M_MMAP_MAX, 0);
+#endif
+
+#if defined(HAVE_FPU_CONTROL_H)
+	/* See http://www.srware.com/linux_numerics.txt */
+        /*
+	  This puts the X86 FPU in 64-bit precision mode.  The default
+	  under Linux is to use 80-bit mode, which produces subtle
+	  differences from FreeBSD and other systems, eg,
+	  (int)(1000*atof("0.3")) is 300 in 64-bit mode, 299 in 80-bit
+	  mode.
+        */
+        fpu_control_t cw;
+        _FPU_GETCW(cw);
+        cw &= ~_FPU_EXTENDED;
+        cw |= _FPU_DOUBLE;
+        _FPU_SETCW(cw);
+#endif
+}
+
+#if defined(__GLIBC__)
+extern void * __libc_stack_end;
+
+void *mdGetStackEnd(void)
+{
+  long sz = sysconf(_SC_PAGESIZE);
+  
+  return (void *)(((uintp)__libc_stack_end + sz - 1) & (-sz));
+}
+#endif




More information about the kaffe mailing list