From 29f1fd98b32de829673d6b51a2455881b026d22b Mon Sep 17 00:00:00 2001
From: rtoy <rtoy>
Date: Wed, 10 Dec 2008 16:16:11 +0000
Subject: [PATCH] Change how we put the FPU type into the core file.  We can't
 use compile-time options to do this.  The running core file has to tell us.

lisp/save.c:
o Add extra arg to save function to indicate whether the core we're
  saving supports sse2 or not.  Non-zero means sse2.
o Put the correct indication into the core file.

lisp/save.h:
o Update declaration of save.

code/save.lisp:
o Update alien definition for save
o Pass in the extra parameter for the save routine to indicate if we
  support sse2 or not.
---
 code/save.lisp |  9 +++++----
 lisp/save.c    | 19 ++++++++++---------
 lisp/save.h    |  4 ++--
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/code/save.lisp b/code/save.lisp
index c2249c799..f809030e1 100644
--- a/code/save.lisp
+++ b/code/save.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/save.lisp,v 1.57 2008/06/19 20:58:05 rtoy Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/save.lisp,v 1.58 2008/12/10 16:16:10 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -123,7 +123,8 @@
 
 (alien:def-alien-routine "save" (alien:boolean)
   (file c-call:c-string)
-  (initial-function (alien:unsigned #.vm:word-bits)))
+  (initial-function (alien:unsigned #.vm:word-bits))
+  (sse2-mode c-call:int))
 
 #+:executable
 (alien:def-alien-routine "save_executable" (alien:boolean)
@@ -292,9 +293,9 @@
 	  #+:executable
 	(if executable
 	    (save-executable core-name initial-function)
-	    (save core-name initial-function))
+	    (save core-name initial-function #+sse2 1 #-sse2 0))
 	#-:executable
-	(save core-name initial-function))))
+	(save core-name initial-function #+sse2 1 #-sse2 0))))
   nil)
 
 
diff --git a/lisp/save.c b/lisp/save.c
index 3e7a1a2d0..a57c21bae 100644
--- a/lisp/save.c
+++ b/lisp/save.c
@@ -1,6 +1,6 @@
 /*
 
- $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/save.c,v 1.20 2008/11/12 15:04:24 rtoy Exp $
+ $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/save.c,v 1.21 2008/12/10 16:16:11 rtoy Exp $
 
  This code was written as part of the CMU Common Lisp project at
  Carnegie Mellon University, and has been placed in the public domain.
@@ -101,7 +101,7 @@ dump_region(struct alloc_region *alloc_region)
 #endif
 
 boolean
-save(char *filename, lispobj init_function)
+save(char *filename, lispobj init_function, int sse2_mode)
 {
     FILE *file;
 
@@ -148,18 +148,19 @@ save(char *filename, lispobj init_function)
     putw(CORE_MAGIC, file);
 
     putw(CORE_VERSION, file);
-#ifdef i386
+#if defined(i386) && defined(FEATURE_SSE2)
     putw(4, file);
 #else
     putw(3, file);
 #endif
     putw(version, file);
-#ifdef i386
-#ifdef FEATURE_SSE2
-    putw(SSE2, file);
-#else
-    putw(X87, file);
-#endif    
+
+#if defined(i386) && defined(FEATURE_SSE2)
+    if (sse2_mode) {
+        putw(SSE2, file);
+    } else {
+        putw(X87, file);
+    }
 #endif
     
     putw(CORE_NDIRECTORY, file);
diff --git a/lisp/save.h b/lisp/save.h
index 6d2630c5f..1f10aceda 100644
--- a/lisp/save.h
+++ b/lisp/save.h
@@ -1,5 +1,5 @@
 /*
- * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/save.h,v 1.3 2005/01/13 19:55:00 fgilham Exp $
+ * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/save.h,v 1.4 2008/12/10 16:16:11 rtoy Rel $
  */
 
 #ifndef _SAVE_H_
@@ -7,6 +7,6 @@
 
 #include "core.h"
 
-extern boolean save(char *filename, lispobj initfun);
+extern boolean save(char *filename, lispobj initfun, int sse2_mode);
 
 #endif /* _SAVE_H_ */
-- 
GitLab