Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   setjmp,longjmp, sigsetjmp implementation (http://www.velocityreviews.com/forums/t955363-setjmp-longjmp-sigsetjmp-implementation.html)

Borneq 12-11-2012 11:36 AM

setjmp,longjmp, sigsetjmp implementation
 
Where I can find setjmp,longjmp, sigsetjmp implementation? In GCC source I
can't find.


Borneq 12-11-2012 11:47 AM

Re: setjmp,longjmp, sigsetjmp implementation
 
Użytkownik "Borneq" <borneq@antyspam.hidden.pl> napisał w wiadomości
news:ka75r3$66s$1@node2.news.atman.pl...
> Where I can find setjmp,longjmp, sigsetjmp implementation? In GCC source I
> can't find.


I found one:
https://www-asim.lip6.fr/trac/netbsd...v=3&order=name


Borneq 12-11-2012 11:56 AM

Re: setjmp,longjmp, sigsetjmp implementation
 
Użytkownik "Borneq" <borneq@antyspam.hidden.pl> napisał w wiadomości
news:ka76g3$6v1$1@node2.news.atman.pl...
> I found one:
> https://www-asim.lip6.fr/trac/netbsd...v=3&order=name


Is setjmp but not longjmp


Noob 12-11-2012 12:03 PM

Re: setjmp,longjmp, sigsetjmp implementation
 
Borneq wrote:

> Where I can find setjmp, longjmp, sigsetjmp implementation?


e.g. http://sourceware.org/git/?p=glibc.git;a=tree;f=setjmp


Borneq 12-11-2012 12:47 PM

Re: setjmp,longjmp, sigsetjmp implementation
 
Uzytkownik "Noob" <root@127.0.0.1> napisal w wiadomosci
news:ka7744$178$1@dont-email.me...
>> Where I can find setjmp, longjmp, sigsetjmp implementation?

>
> e.g. http://sourceware.org/git/?p=glibc.git;a=tree;f=setjmp


This call low level functions, longjmp.c :

#include <setjmp.h>
void
__libc_siglongjmp (sigjmp_buf env, int val)
{
/* Perform any cleanups needed by the frames being unwound. */
_longjmp_unwind (env, val);

if (env[0].__mask_was_saved)
/* Restore the saved signal mask. */
(void) __sigprocmask (SIG_SETMASK, &env[0].__saved_mask,
(sigset_t *) NULL);

/* Call the machine-dependent function to restore machine state. */
__longjmp (env[0].__jmpbuf, val ?: 1);
}

longjmp_unwind ,__sigprocmask, __longjmp are in other library? In assembly?


Noob 12-11-2012 01:10 PM

Re: setjmp,longjmp, sigsetjmp implementation
 
Borneq wrote:

> longjmp_unwind, __sigprocmask, __longjmp are in other library?


1) tar xjf glibc-2.16.0.tar.bz2
2) grep -rn __longjmp glibc-2.16.0

e.g. http://sourceware.org/git/?p=glibc.g...86/__longjmp.S


Borneq 12-11-2012 02:02 PM

Re: setjmp,longjmp, sigsetjmp implementation
 
Uzytkownik "Noob" <root@127.0.0.1> napisal w wiadomosci
news:ka7b08$n4m$1@dont-email.me...
> Borneq wrote:
>
>> longjmp_unwind, __sigprocmask, __longjmp are in other library?

>
> 1) tar xjf glibc-2.16.0.tar.bz2
> 2) grep -rn __longjmp glibc-2.16.0
>
> e.g.
> http://sourceware.org/git/?p=glibc.g...86/__longjmp.S


Thanks


BartC 12-12-2012 12:21 PM

Re: setjmp,longjmp, sigsetjmp implementation
 


"Noob" <root@127.0.0.1> wrote in message news:ka7b08$n4m$1@dont-email.me...
> Borneq wrote:
>
>> longjmp_unwind, __sigprocmask, __longjmp are in other library?

>
> 1) tar xjf glibc-2.16.0.tar.bz2
> 2) grep -rn __longjmp glibc-2.16.0
>
> e.g.
> http://sourceware.org/git/?p=glibc.g...86/__longjmp.S


This is not C. In that case why does it need to be that complicated? I used
to do this in just 3 instructions:

mov esp,[spsave]
mov ebp,[bpsave]
jmp [....]

It worked.

--
Bartc




Johann Klammer 12-12-2012 02:19 PM

Re: setjmp,longjmp, sigsetjmp implementation
 
BartC wrote:
>
>
> "Noob" <root@127.0.0.1> wrote in message news:ka7b08$n4m$1@dont-email.me...
>> Borneq wrote:
>>
>>> longjmp_unwind, __sigprocmask, __longjmp are in other library?

>>
>> 1) tar xjf glibc-2.16.0.tar.bz2
>> 2) grep -rn __longjmp glibc-2.16.0
>>
>> e.g.
>> http://sourceware.org/git/?p=glibc.g...86/__longjmp.S

>
> This is not C. In that case why does it need to be that complicated? I
> used to do this in just 3 instructions:
>
> mov esp,[spsave]
> mov ebp,[bpsave]
> jmp [....]
>
> It worked.
>


Doesn't the whole machine state have to be
saved/restored(registers/Fp/SSE/flags etc)? What if the calling function
was using some regs for local vars etc ?!...


Nobody 12-12-2012 02:38 PM

Re: setjmp,longjmp, sigsetjmp implementation
 
On Wed, 12 Dec 2012 15:19:57 +0100, Johann Klammer wrote:

> Doesn't the whole machine state have to be
> saved/restored(registers/Fp/SSE/flags etc)?


No.

> What if the calling function was using some regs for local vars etc ?!...


7.13.2.1p3:

All accessible objects have values as of the time longjmp was
called, except that the values of objects of automatic storage
duration that are local to the function containing the
invocation of the corresponding setjmp macro that do not have
volatile-qualified type and have been changed between the
setjmp invocation and longjmp call are indeterminate.

gcc will warn about such cases with e.g.:

warning: variable ‘foo’ might be clobbered by ‘longjmp’ or ‘vfork’

Typically, only the "essential" registers (program counter, stack pointer,
frame pointer) are preserved. Registers holding local variables or
intermediate results aren't required to be preserved (and usually aren't).
"Global" state isn't modified by longjmp and, AIUI, that includes the FP
environment (<fenv.h>).



All times are GMT. The time now is 08:58 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57