[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] -mint8 problem with setjmp/longjmp
From: |
Nils Kristian Strom |
Subject: |
Re: [avr-libc-dev] -mint8 problem with setjmp/longjmp |
Date: |
Fri, 08 Nov 2002 16:06:57 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2b) Gecko/20021018 |
Joerg Wunsch wrote:
The jmp_buf envelope contains no pointers (in the C sense), it just
contains space for saving registers. Registers are of some integer
type (8-bit in our case).
I agree, that is exactly what it is.
Thinking even more about it, jmp_buf should probably be just an
opaque array to the luser, i. e.
#define _JBLEN 24
typedef struct _jmp_buf { unsigned char _jb[_JBLEN + 1]; } jmp_buf[1];
would do as well, and matches the assembler source.
Can you give that a try?
I like this approach *a lot*, since it will create correct code
regardless of sizeof(int).
Your suggestion is tested and is working (I used the patch below).
Thanks for the feedback Joerg
Regards
Nils
Index: setjmp.h
===================================================================
RCS file: /cvsroot/avr-libc/avr-libc/include/setjmp.h,v
retrieving revision 1.3
diff -c -3 -p -r1.3 setjmp.h
*** setjmp.h 27 Sep 2002 19:11:59 -0000 1.3
--- setjmp.h 8 Nov 2002 14:56:32 -0000
*************** extern "C" {
*** 40,71 ****
21 3 return address (PC) (2 bytes used for <=128K flash)
24 = total size
*/
- typedef struct {
- /* call-saved registers */
- unsigned char __j_r2;
- unsigned char __j_r3;
- unsigned char __j_r4;
- unsigned char __j_r5;
- unsigned char __j_r6;
- unsigned char __j_r7;
- unsigned char __j_r8;
- unsigned char __j_r9;
- unsigned char __j_r10;
- unsigned char __j_r11;
- unsigned char __j_r12;
- unsigned char __j_r13;
- unsigned char __j_r14;
- unsigned char __j_r15;
- unsigned char __j_r16;
- unsigned char __j_r17;
- /* frame pointer, stack pointer, status register, program counter */
- unsigned int __j_fp; /* Y */
- unsigned int __j_sp;
- unsigned char __j_sreg;
- unsigned int __j_pc;
- unsigned char __j_pch; /* only devices with >128K bytes of flash */
- } jmp_buf[1];
/** \defgroup setjmp Setjmp and Longjmp
--- 40,48 ----
21 3 return address (PC) (2 bytes used for <=128K flash)
24 = total size
*/
+ #define _JBLEN 24
+ typedef struct _jmp_buf { unsigned char _jb[_JBLEN + 1]; } jmp_buf[1];
/** \defgroup setjmp Setjmp and Longjmp