Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!mips!daver!bungi.com!news From: mea@mea.utu.fi (Matti Aarnio) Newsgroups: comp.sys.nsc.32k Subject: Re: Bug in minix library setjmp.s; lots of GNU tools diffs available Message-ID: <9102080744.AA04983@mea.utu.fi> Date: 8 Feb 91 09:44:49 GMT References: <<9102072159.AA02808@halsoft>> Sender: news@daver.bungi.com Lines: 34 Approved: news@daver.bungi.com Ian writes: >Jyrki Kuoppala (jkp) writes: > - When porting emacs to pc532-Minix, I noticed there's a bug in the > - setjmp library routine - it doesn't save registers r3-r7 (and f4-f7) > - which I think it should do. ... >I believe in ANSI C, there is no requirement to save registers in setjump. >Variables which have to be accessed after the setjump should be marked >volatile. Yes, some people have said that is ugly and nor the way it >should be done, but I pretty sure, that is the way it is! Actually GCC document quite EXPLICITELY tell you to make sure that variables needing to be preserved across setjump()/longjump() MUST NOT STAY IN REGISTERS. A way to force GCC to do this (normally GCC just ignores register keyword and uses own heuristics!) is to take address of variable. Even though that address might not be used, and simplest optimation will drop instructions for it, this is the way: foo() { int a,b,c; /* Have potential to get into registers */ &b; /* Make sure GCC won't let it stay in register. */ /* Across func calls at least. */ do your jumps } But of course you knew it, didn't you ? JKP especially. /Matti Aarnio