patch: REG vs. REGISTER and longjmp portability

Werner Almesberger
Thu Aug 24 01:54:00 GMT 2000

In my Aug 22 patch to setjmp.S, I overlooked that i386mach.h defined
__REG_PREFIX__, while setjmp.S used __REGISTER_PREFIX__. Sorry.

I'm not sure if this makes sense (gcc frowns upon any attempt to change
__REGISTER_PREFIX__ anyway), but I've added the __REGISTER_PREFIX__
change to setjmp.S again.

The second part of the patch is to make cli/sti in longjmp configurable.
This is necessary to run it under Linux. The solution isn't perfectly
clean (i.e. there really ought to be hooks to do something else, e.g.
block signals), but I hope it's acceptable as a band aid.

My patch is relative to the CVS tree plus my machine/i386/*.S patch

The good news is that ash (Almquist shell) now compiles almost out of
the box.

- Werner

---------------------------------- ChangeLog ----------------------------------

2000-08-24  Werner Almesberger  <>
	* libc/machine/i386/setjmp.S: inclusion of i386mach.h did not take
	into account that i386mach.h defines __REG_PREFIX__, not
	* libc/machine/i386/i386mach.h: added __CLI and __STI macros
	(controlled via ALLOW_HW_INTERRUPTS macro)
	* libc/machine/i386/setjmp.S (longjmp): uses __CLI and __STI
	instead of cli and sti

------------------------------------ patch ------------------------------------

--- src/newlib/libc/machine/i386/i386mach.h.broken	Thu Aug 24 10:28:10 2000
+++ src/newlib/libc/machine/i386/i386mach.h	Thu Aug 24 10:29:37 2000
@@ -73,3 +73,11 @@
 #define SOTYPE_FUNCTION(sym)
+#define	__CLI
+#define	__STI
+#define __CLI	cli
+#define __STI	sti
--- src/newlib/libc/machine/i386/setjmp.S.broken	Thu Aug 24 09:42:15 2000
+++ src/newlib/libc/machine/i386/setjmp.S	Thu Aug 24 10:28:23 2000
@@ -24,6 +24,7 @@
 	#include "i386mach.h"
+	#define __REGISTER_PREFIX__ %  /* i386mach.h sets __REG_PREFIX__ ?!? */
         .global SYM (setjmp)
         .global SYM (longjmp)
@@ -72,7 +73,7 @@
 	movl	24(edi),ebp
-	cli
+	__CLI
 	movl	28(edi),esp
 	pushl	32(edi)	
@@ -83,6 +84,6 @@
 	movl	12(edi),edx
 	movl	16(edi),esi
 	movl	20(edi),edi
-	sti
+	__STI

 / Werner Almesberger, ICA, EPFL, CH /

More information about the Newlib mailing list