Path: utzoo!attcan!uunet!clyde.concordia.ca!mcgill-vision!snorkelwacker!bloom-beacon!eru!luth!sunic!tut!santra!hemuli.tik.vtt.fi!tml From: tml@hemuli.tik.vtt.fi (Tor Lillqvist) Newsgroups: comp.sys.hp Subject: Re: Xtank port and jmp_buf puzzle Keywords: xtank jmp_buf Message-ID: <4943@hemuli.tik.vtt.fi> Date: 2 Jun 90 07:50:21 GMT References: <3160@bnr-rsc.UUCP> Organization: Technical Research Centre of Finland, Laboratory for Information Processing (VTT/TIK) Lines: 39 In article <3160@bnr-rsc.UUCP> uunet!chekov!hounsell writes: - /* Modify current state's stack pointer in jmp_buf state */ - bufend = (unsigned int)buf + bufsize - 1 - sizeof(thd->state); - /* Set stack pointer in jmp_buf to bufend. - * This is extremely machine and OS dependent. - * Often you can find out what register of the jmp_buf has the - * stack pointer by looking in /usr/include/setjmp.h on your machine. - */ -#ifdef vax /* Vaxen */ - bufend -= sizeof(Thread); - thd->state[0] = bufend; -#endif -#if (defined(ibm032) || defined(ibm370)) /* IBM RT */ - thd->state[0] = bufend; -#endif - The setjump.h for HPUX 6.5 running on HP300 series workstations does NOT give -a clue what register to use, or how to set bufend. Can anyone suggest the -correct values?? I did once port xtank to the hp9000 series 800, but I haven't tried porting it to the series 300. However, the best way to understand setjmp is to use your friendly machine level debugger adb: Compile some small dummy program that uses setjmp/longjmp and disassemble it, and step through its execution instruction by instruction. This should give you enough information to know how to proceed. Specifically, look where the stack pointer register is stored in the jmp_buf. Btw, the port to the series 800 was a bit different because the stack on the series 800 grows upward. Most other machines with Unix seem to have downward-growing stacks. The stack direction of course doesn't matter to portable code, but I had to give up on porting XView (Sun's freely available SunView compatibility package for X), which does very dirty tricks with varargs. -- Tor Lillqvist, working, but not speaking, for the Technical Research Centre of Finland