Date: Thu, 9 Jan 2003 15:47:25 +0100 From: Stefan Farfeleder <stefan@fafoe.dyndns.org> To: Pawel Jakub Dawidek <P.Dawidek@prioris.mini.pw.edu.pl> Cc: freebsd-hackers@freebsd.org Subject: Re: Exceptions via setjmp/longjmp in kernel. Message-ID: <20030109144724.GA611@frog.fafoe> In-Reply-To: <20030109143059.GC47263@prioris.mini.pw.edu.pl> References: <20030109143059.GC47263@prioris.mini.pw.edu.pl>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jan 09, 2003 at 03:30:59PM +0100, Pawel Jakub Dawidek wrote: > I got strange problem when trying to implement something like exceptions > with setjmp()/longjmp() functions. > > [...] > int ret; > jmpbuf buf; > [...] > ret = setjmp(buf); > KASSERT(ret != 1, ("I never return 1 with longjmp().")); > [...] > longjmp(buf, value_diffrent_than_1); > [...] > > And setjmp() returns only 0 or 1 (when longjmp() is called), but never > returns value that I've put in longjmp() call. > > There could be some other problems in using setjmp()/longjmp() > in kernel? I'm paying attention on memory leaks and locks that are > done before longjmp(). The usage of the setjmp macro in an assignment is not defined by ISO C, which might or might not be your problem. 7.13.1.1 The setjmp macro An invocation of the setjmp macro shall appear only in one of the following contexts: -- the entire controlling expression of a selection or iteration statement; -- one operand of a relational or equality operator with the other operand an integer constant expression, with the resulting expression being the entire controlling expression of a selection or iteration statement; -- the operand of a unary ! operator with the resulting expression being the entire controlling expression of a selection or iteration statement; or -- the entire expression of an expression statement (possibly cast to void). OTOH, vinum and ficl use setjmp in the same way. Stefan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030109144724.GA611>