Date: Fri, 16 Jan 1998 12:39:04 +1030 From: Greg Lehey <grog@lemis.com> To: Terry Lambert <tlambert@primenet.com> Cc: hackers@FreeBSD.ORG Subject: Re: Why no sys/setjmp.h? Message-ID: <19980116123904.45753@lemis.com> In-Reply-To: <199801152211.PAA26217@usr01.primenet.com>; from Terry Lambert on Thu, Jan 15, 1998 at 10:11:53PM %2B0000 References: <19980115144234.52624@lemis.com> <199801152211.PAA26217@usr01.primenet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jan 15, 1998 at 10:11:53PM +0000, Terry Lambert wrote: >> I'm just writing kernel code which uses setjmp and longjmp, and I >> discover that there are no header files with declarations of these >> functions. How come? Are they deprecated in the kernel? Should I be >> using something else instead? > > The setjmp() call says "save my stack, reigster set, and signal mask > at this point" and the longjmp() rewinds the information, except that > the return value of the setjmp() is expected to be zero when it > returns, and the longjmp() is non-zero when it returns for setjmp(). > > Forget that there's no signal mask in the kernel. 8-). There's always > _setjmp()/_longjmp()... In fact, there's setjmp and longjmp too. They're there, alright. > In general, setjmp()/longjmp() prevent all sorts of optimizations > from being used. In the kernel? > There are also problems because of kernel stacks. If I tsleep() > in a driver, I'm not guaranteed to be on the same stack un some > particular situations, etc.. It would be easy to introduce > errors if you do a lot of stack unwinding. I can't see a way of using them in this environment. I'm in the top half of a driver, where things are more like in user space. > Finally, the purpose of these functions is to allow the throwing of > exceptions, and the kernel has it's own exception mechanisms. Which are? That was my question. > Technically, you could write your own setjmp/longjmp, use them, and > if you were careful, not screw up. But it makes debugging and other > tasks so difficult for so little gain (in an already difficult place, > unless you have two machines and use a source debugger) that it's > probably better to use a different approach. So what are kernel setjmp and longjmp there for? Greg
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980116123904.45753>