From 0d44b801c8186395689fd62674d15032bc796fe7 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Thu, 3 Jul 2008 19:09:33 -0500
Subject: [PATCH 1/2] Fix USING

---
 core/cpu/x86/64/64.factor | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/cpu/x86/64/64.factor b/core/cpu/x86/64/64.factor
index 8a9a0c89dd..6d99b72439 100755
--- a/core/cpu/x86/64/64.factor
+++ b/core/cpu/x86/64/64.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2005, 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types arrays cpu.x86.assembler
+USING: accessors alien.c-types arrays cpu.x86.assembler
 cpu.x86.architecture cpu.x86.intrinsics cpu.x86.sse2
 cpu.x86.allot cpu.architecture kernel kernel.private math
 namespaces sequences generator.registers generator.fixup system

From cc008e6c2c59090903acc3a783b79bfdd4f5716b Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Thu, 3 Jul 2008 19:52:59 -0500
Subject: [PATCH 2/2] Better error checking for image saves

---
 vm/image.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/vm/image.c b/vm/image.c
index 09ff035d7e..a0fa48d504 100755
--- a/vm/image.c
+++ b/vm/image.c
@@ -101,7 +101,7 @@ void load_image(F_PARAMETERS *p)
 }
 
 /* Save the current image to disk */
-void save_image(const F_CHAR *filename)
+bool save_image(const F_CHAR *filename)
 {
 	FILE* file;
 	F_HEADER h;
@@ -112,7 +112,7 @@ void save_image(const F_CHAR *filename)
 	if(file == NULL)
 	{
 		fprintf(stderr,"Cannot open image file: %s\n",strerror(errno));
-		return;
+		return false;
 	}
 
 	F_ZONE *tenured = &data_heap->generations[TENURED];
@@ -143,20 +143,22 @@ void save_image(const F_CHAR *filename)
 	if(fwrite((void*)tenured->start,h.data_size,1,file) != 1)
 	{
 		fprintf(stderr,"Save data heap failed: %s\n",strerror(errno));
-		return;
+		return false;
 	}
 
 	if(fwrite(first_block(&code_heap),h.code_size,1,file) != 1)
 	{
 		fprintf(stderr,"Save code heap failed: %s\n",strerror(errno));
-		return;
+		return false;
 	}
 
 	if(fclose(file))
 	{
 		fprintf(stderr,"Failed to close image file: %s\n",strerror(errno));
-		return;
+		return false;
 	}
+
+	return true;
 }
 
 DEFINE_PRIMITIVE(save_image)
@@ -187,10 +189,10 @@ DEFINE_PRIMITIVE(save_image_and_exit)
 	UNREGISTER_C_STRING(path);
 
 	/* Save the image */
-	save_image(path);
-
-	/* now exit; we cannot continue executing like this */
-	exit(0);
+	if(save_image(path))
+		exit(0);
+	else
+		exit(1);
 }
 
 void fixup_word(F_WORD *word)