From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,a64f76630f5174ec,start X-Google-Attributes: gidfee84,public From: David Gadbois Subject: Sleazy jmp_buf hacks Date: 1998/04/01 Message-ID: <%HyU.271$Tp.385823@news.giganews.com>#1/1 X-Deja-AN: 339969686 Organization: Cycorp, Inc. (Austin, TX) NNTP-Posting-Date: Wed, 01 Apr 1998 15:54:03 CST Newsgroups: comp.unix.osf.osf1 Originator: gadbois@proton I am trying to port a run-time system that hacks jmp_bufs in order to implement coroutines. The idea is to set up a jmp_buf and modify it so that longjmp()ing to it runs a given function in a new stack. It appears that Alpha OSF/1 3.0 longjmp() does not restore the Procedure Value register (27), which callees in the standard calling convention use to get at their global pointer. Is this analysis correct? Is there some workaround? #include #include #include static void fun(void) { printf("Eureka!\n"); exit(0); } #define STACK_SIZE (1L << 20L) int main() { jmp_buf env; setjmp(env); env[30] /* JB_RA */ = (long) fun; env[31] /* JB_PV */ = (long) fun; /* Doesn't get restored! */ env[34] /* JB_SP */ = ((long) malloc(STACK_SIZE)) + STACK_SIZE; longjmp(env, 1); } Thanks, --David Gadbois