fnf@well.UUCP (Fred Fish) (01/06/86)
Does anyone know if setjmp/longjmp works on the AMIGA under Lattice C? I apparently don't have the include file <setjmp.h>, but the functions are in the library somewhere, because they are getting resolved at link time. I tried a kluge of defining: typedef int jmp_buf[16]; which solved the problem of making the identifier "jmp_buf" known. What should <setjmp.h> look like? -Fred -- =============================================================================== Fred Fish (415) 644-1230 ext 242 ucbvax!unisoft!fnf well!fnf ===============================================================================
andy@amiga.UUCP (Andy Finkel) (01/08/86)
[ enter your line eater goes here ] In article <431@well.UUCP>, fnf@well.UUCP (Fred Fish) writes: > Does anyone know if setjmp/longjmp works on the AMIGA under > Lattice C? I apparently don't have the include file <setjmp.h>, > What should <setjmp.h> look like? here's what it looks like under Lattice C running under V1.1: /** * * This structure is used by the setjmp/longjmp functions to save the * current environment on the 68000. * */ struct JMP_BUF { long jmpret; /* return address */ long jmp_d1; long jmp_d2; long jmp_d3; long jmp_d4; long jmp_d5; long jmp_d6; long jmp_d7; long jmp_a1; long jmp_a2; long jmp_a3; long jmp_a4; long jmp_a5; long jmp_a6; long jmp_a7; }; typedef struct JMP_BUF jmp_buf[1]; I'd give it a try and see if it helps, but no guarantees are made. It might give problems under V1.0. andy finkel commodore The traditional disclaimers go here.
hamilton@uiucuxc.CSO.UIUC.EDU (01/13/86)
>Does anyone know if setjmp/longjmp works on the AMIGA under Lattice C? >I tried a kluge of defining: > typedef int jmp_buf[16]; >which solved the problem of making the identifier "jmp_buf" known. >What should <setjmp.h> look like? >-Fred i'm in the process of re-organizing my amiga.lib and lc.lib, so i took a look at setjmp/longjmp. here's my disassembly: _setjmp: ;setjmp (buf) movl 4(sp),a0 ;a0=buf movl sp,8(a0) ;buf[2]=sp movl (sp),(a0) ;buf[0]=ret rts _longjmp: ;longjmp (buf, val) movl a1,-(sp) ;save a1 movl a0,-(sp) ;save a0 movl 16(sp),d0 ;d0=val bne 1$ addql #1,d0 ;++d0 1$: movl 12(sp),a0 ;a0=buf movl 8(a0),a1 ;a1=setjmp's sp movl (a0),(a1) ;*(setjmp's sp)=setjmp's ret movl 4(a0),a6 ;a6=buf[1] movl (sp),a0 ;restore a0 movl 4(sp),-(a1) ;push saved a1 onto setjmp's sp movl a1,sp ;sp=setjmp's sp-4 movl (sp)+,a1 ;restore a1 and sp rts so the short anwer is that jmpbuf appears to be: typedef long jmp_buf[3]; however, if you look close, you see that setjmp doesn't save a6 in buf[1], but longjmp does copy buf[1] (garbage) to a6. also notice that setjmp doesn't clear d0 before return. i think setjmp ought to look more like: movl 4(sp),a0 ;a0=buf movl sp,8(a0) ;buf[2]=sp movl a6,4(a0) ;buf[1]=fp movl (sp),(a0) ;buf[0]=ret subl d0,d0 ;return(0) rts wayne hamilton U of Il and US Army Corps of Engineers CERL UUCP: {ihnp4,pur-ee,convex}!uiucdcs!uiucuxc!hamilton ARPA: hamilton@uiucuxc.cso.uiuc.edu CSNET: hamilton%uiucuxc@uiuc.csnet USMail: Box 476, Urbana, IL 61801 Phone: (217)333-8703
hamilton@uiucuxc.CSO.UIUC.EDU (01/15/86)
hmmm, i should point out that i was referring to the 3.02 version of the compiler & libraries. wayne hamilton