Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

functions setjmp/longjmp

Status
Not open for further replies.

Piv

Programmer
Apr 28, 2003
5
AR
HI!
I was asked to create two functions similar to setjmp/longjmp, but setjmp has to keep a record not only of the state of registers, but also:
a)the state of the signals in that moment
b)the moment setjmp is called (with a timer)
c)the state of the floating point coprocessor
Longjmp has to restore the state of the signal and the coprocessor
I hope you understand my problem, it was hard to traslate it to english. I really need help to do this.
Thanks-- Pamela
 
Basically what you need is a global array of structures and a global count of the number of structures you are using. The structure will contain an id and the values you wish to save. You can either build up the array dynamically using malloc/realloc or just set a fixed number of entries if you know roughly how many you intend to use.

Setjmp will look for the next available slot, store the id and save all the values in the next available slot, increment the global count and do a C setjmp.

Longjmp will look up the id, restore the values and do a C longjmp.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top