Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > setjmp,longjmp, sigsetjmp implementation

Reply
Thread Tools

setjmp,longjmp, sigsetjmp implementation

 
 
Borneq
Guest
Posts: n/a
 
      12-11-2012
Where I can find setjmp,longjmp, sigsetjmp implementation? In GCC source I
can't find.

 
Reply With Quote
 
 
 
 
Borneq
Guest
Posts: n/a
 
      12-11-2012
Użytkownik "Borneq" <> napisał w wiadomości
news:ka75r3$66s$...
> 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

 
Reply With Quote
 
 
 
 
Borneq
Guest
Posts: n/a
 
      12-11-2012
Użytkownik "Borneq" <> napisał w wiadomości
news:ka76g3$6v1$...
> I found one:
> https://www-asim.lip6.fr/trac/netbsd...v=3&order=name


Is setjmp but not longjmp

 
Reply With Quote
 
Noob
Guest
Posts: n/a
 
      12-11-2012
Borneq wrote:

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


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

 
Reply With Quote
 
Borneq
Guest
Posts: n/a
 
      12-11-2012
Uzytkownik "Noob" <root@127.0.0.1> napisal w wiadomosci
news:ka7744$178$...
>> 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?

 
Reply With Quote
 
Noob
Guest
Posts: n/a
 
      12-11-2012
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

 
Reply With Quote
 
Borneq
Guest
Posts: n/a
 
      12-11-2012
Uzytkownik "Noob" <root@127.0.0.1> napisal w wiadomosci
news:ka7b08$n4m$...
> 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

 
Reply With Quote
 
BartC
Guest
Posts: n/a
 
      12-12-2012


"Noob" <root@127.0.0.1> wrote in message news:ka7b08$n4m$...
> 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



 
Reply With Quote
 
Johann Klammer
Guest
Posts: n/a
 
      12-12-2012
BartC wrote:
>
>
> "Noob" <root@127.0.0.1> wrote in message news:ka7b08$n4m$...
>> 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 ?!...

 
Reply With Quote
 
Nobody
Guest
Posts: n/a
 
      12-12-2012
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>).

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insertion Sort : C++ implementation 100 times slower than C implementation sanket C++ 7 11-03-2011 05:00 AM
Knowing the implementation, are all undefined behaviours become implementation-defined behaviours? Michael Tsang C Programming 54 03-30-2010 07:46 AM
Knowing the implementation, are all undefined behaviours become implementation-defined behaviours? Michael Tsang C++ 32 03-01-2010 09:15 PM
can anyone guide me in flight-mode implementation for Windows mobile 5.0? vivekanand holla Wireless Networking 1 11-10-2005 11:15 AM
transport protocol implementation in NDIS zenhwa Wireless Networking 0 09-14-2004 11:38 PM



Advertisments
 



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