[uClibc]JB_PC JB_REGS

Ilguiz Latypov ilatypov at superbt.com
Mon Apr 1 22:37:17 UTC 2002


Lei,

Have you found the solution the the setjmp/longjmp compilation on 
m68knommu?  I wrote my own, but I am afraid I might miss something.

Ilguiz

On Thu, 28 Mar 2002, Lei Zhang wrote:

> I have tried to compile the uClibc0.9.10 on M68K platform against
> uClinux-2.4.17.But I failed on files such as __longjmp.S, setjmp.S and
> so on.
-------------- next part --------------
Index: libc/sysdeps/linux/m68k/__longjmp.S
===================================================================
RCS file: /usr/local/cvsroot/uClibc/libc/sysdeps/linux/m68k/__longjmp.S,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- libc/sysdeps/linux/m68k/__longjmp.S	20 Mar 2002 21:49:15 -0000	1.1.1.1
+++ libc/sysdeps/linux/m68k/__longjmp.S	1 Apr 2002 17:25:44 -0000	1.2
@@ -15,10 +15,17 @@
 	bne		1f
 	movel	#1, %d0
 1:
-	moveml	%a0@(JB_REGS), %d2-%d7/%a2-%a7
+	moveml	%a0@(JB_REGS), %d2-%d7/%a2-%a6
 #if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
 	fmovemx %a0@(JB_FPREGS), %fp2-%fp7
 #endif
-	movel	%a0@(JB_PC), %sp@
-	rts
+	movel	%a0@(JB_SP), %sp
+	/* 
+	 * What if an interrupt occurs before reading the JB_PC value
+	 * off the old stack frame?  Then JB_PC value might be corrupted.
+	 * Perhaps, it is better to read JB_PC before reading JB_SP.  The 
+	 * latter can be put into %a1. --ilatypov
+	 */
+	moveal	%a0@(JB_PC), %a0
+	jmp	%a0@
 
Index: libc/sysdeps/linux/m68k/bsd-_setjmp.S
===================================================================
RCS file: /usr/local/cvsroot/uClibc/libc/sysdeps/linux/m68k/bsd-_setjmp.S,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- libc/sysdeps/linux/m68k/bsd-_setjmp.S	20 Mar 2002 21:49:15 -0000	1.1.1.1
+++ libc/sysdeps/linux/m68k/bsd-_setjmp.S	1 Apr 2002 17:25:44 -0000	1.2
@@ -12,13 +12,14 @@
 
 _setjmp:
 	moveal	%sp@(4), %a0
+	movel	%sp, %a0@(JB_SP)
 	movel	%sp@(0), %a0@(JB_PC)
-	moveml	%d2-%d7/%a2-%a7, %a0@(JB_REGS)
+	moveml	%d2-%d7/%a2-%a6, %a0@(JB_REGS)
 #if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
 	fmovemx %fp2-%fp7, %a0@(JB_FPREGS)
 #endif
 	clrl	%d0
-	movl	%d0, JB_SIZE(%a0) /* No signal mask set.  */
+	movl	%d0, %a0@(JB_SIZE) /* No signal mask set.  */
 	rts
 
 
Index: libc/sysdeps/linux/m68k/bsd-setjmp.S
===================================================================
RCS file: /usr/local/cvsroot/uClibc/libc/sysdeps/linux/m68k/bsd-setjmp.S,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- libc/sysdeps/linux/m68k/bsd-setjmp.S	20 Mar 2002 21:49:15 -0000	1.1.1.1
+++ libc/sysdeps/linux/m68k/bsd-setjmp.S	1 Apr 2002 17:25:44 -0000	1.2
@@ -12,8 +12,9 @@
 
 setjmp:
 	moveal	%sp@(4), %a0
+	movel	%sp, %a0@(JB_SP)
 	movel	%sp@(0), %a0@(JB_PC)
-	moveml	%d2-%d7/%a2-%a7, %a0@(JB_REGS)
+	moveml	%d2-%d7/%a2-%a6, %a0@(JB_REGS)
 #if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
 	fmovemx %fp2-%fp7, %a0@(JB_FPREGS)
 #endif
Index: libc/sysdeps/linux/m68k/setjmp.S
===================================================================
RCS file: /usr/local/cvsroot/uClibc/libc/sysdeps/linux/m68k/setjmp.S,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- libc/sysdeps/linux/m68k/setjmp.S	20 Mar 2002 21:49:15 -0000	1.1.1.2
+++ libc/sysdeps/linux/m68k/setjmp.S	1 Apr 2002 17:25:44 -0000	1.2
@@ -12,8 +12,9 @@
 
 __sigsetjmp:
 	moveal	%sp@(4), %a0
+	movel	%sp, %a0@(JB_SP)
 	movel	%sp@(0), %a0@(JB_PC)
-	moveml	%d2-%d7/%a2-%a7, %a0@(JB_REGS)
+	moveml	%d2-%d7/%a2-%a6, %a0@(JB_REGS)
 #if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
 	fmovemx %fp2-%fp7, %a0@(JB_FPREGS)
 #endif
Index: libc/sysdeps/linux/m68k/bits/setjmp.h
===================================================================
RCS file: /usr/local/cvsroot/uClibc/libc/sysdeps/linux/m68k/bits/setjmp.h,v
retrieving revision 1.1.1.2
retrieving revision 1.4
diff -u -r1.1.1.2 -r1.4
--- libc/sysdeps/linux/m68k/bits/setjmp.h	20 Mar 2002 21:49:15 -0000	1.1.1.2
+++ libc/sysdeps/linux/m68k/bits/setjmp.h	1 Apr 2002 22:28:58 -0000	1.4
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -16,31 +16,25 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-/* Define the machine-dependent type `jmp_buf'.  m68k version.  */
+/* Define the machine-dependent type `jmp_buf'.  Motorola m68k version.  */
 
 #ifndef _SETJMP_H
 # error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
 #endif
 
-typedef struct
-  {
-    /* There are eight 4-byte data registers, but D0 is not saved.  */
-    long int __dregs[7];
-
-    /* There are six 4-byte address registers, plus the FP and SP.  */
-    int *__aregs[6];
-    int *__fp;
-    int *__sp;
-
-#if defined __HAVE_68881__ || defined __HAVE_FPU__
-    /* There are eight floating point registers which
-       are saved in IEEE 96-bit extended format.  */
-    char __fpregs[8 * (96 / 8)];
+#if defined _ASM
+# define JB_SP	 0
+# define JB_PC	 4
+# define JB_REGS 8
+# define JB_SIZE 4*13
 #endif
 
-  } __jmp_buf[1];
+#ifndef	_ASM
+typedef int __jmp_buf[13];
+#endif
 
 /* Test if longjmp to JMPBUF would unwind the frame
    containing a local variable at ADDRESS.  */
 #define _JMPBUF_UNWINDS(jmpbuf, address) \
-  ((void *) (address) < (void *) (jmpbuf)->__sp)
+  ((void *) (address) < (void *) (jmpbuf)[JB_SP])
+



More information about the uClibc mailing list