home
NEWS       BLOGS       FORUMS       NEWSLETTERS       RESEARCH       EVENTS       DIGITAL LIBRARY       CAREERS  
Network Computing Network Computing Powered by InformationWeek Business Technology Network

IMMERSE YOURSELF:

SOA

  |

Data Center

  |

802.11n

  |

Data Privacy

  |
APO  |

Virtualization

  |

NAC

  |

Security

  |

Network Mgmt

  |

Enterprise Apps

  |

Storage & Servers


SETJMP(3V) C LIBRARY FUNCTIONS SETJMP(3V) NAME setjmp, longjmp, sigsetjmp, siglongjmp - non-local goto SYNOPSIS #include int setjmp(env) jmp_buf env; void longjmp(env, val) jmp_buf env; int val; int _setjmp(env) jmp_buf env; void _longjmp(env, val) jmp_buf env; int val; int sigsetjmp(env, savemask) sigjmp_buf env; int savemask; void siglongjmp(env, val) sigjmp_buf env; int val; DESCRIPTION setjmp() and longjmp() are useful for dealing with errors and interrupts encountered in a low-level subroutine of a program. The macro setjmp() saves its stack environment in env for later use by longjmp(). A normal call to setjmp() returns zero. setjmp() also saves the register environment. If a longjmp() call will be made, the routine which called setjmp() should not return until after the longjmp() has returned control (see below). longjmp() restores the environment saved by the last call of setjmp, and then returns in such a way that execution con- tinues as if the call of setjmp() had just returned the value val to the function that invoked setjmp(); however, if val were zero, execution would continue as if the call of setjmp() had returned one. This ensures that a ``return'' from setjmp() caused by a call to longjmp() can be dis- tinguished from a regular return from setjmp(). The calling function must not itself have returned in the interim, oth- erwise longjmp() will be returning control to a possibly non-existent environment. All memory-bound data have values as of the time longjmp() was called. The CPU and floating- point data registers are restored to the values they had at the time that setjmp() was called. But, because the regis- ter storage class is only a hint to the C compiler, variables declared as register variables may not necessarily be assigned to machine registers, so their values are unpredictable after a longjmp(). This is especially a prob- lem for programmers trying to write machine-independent C routines. setjmp() and longjmp() save and restore the signal mask (see sigsetmask(2)), while _setjmp() and _longjmp() manipulate only the C stack and registers. If the savemask flag to sigsetjmp() is non-zero, the signal mask is saved, and a subsequent siglongjmp() using the same env will restore the signal mask. If the savemask flag is zero, the signal mask is not saved, and a subsequent siglongjmp() using the same env will not restore the signal mask. In all other ways, _setjmp() and sigsetjmp() function in the same way that setjmp() does, and _longjmp() and siglongjmp() function in the same way that longjmp() does. None of these functions save or restore any floating-point status or control registers, in particular the MC68881 fpsr, fpcr, or fpiar, the Sun-3 FPA fpamode or fpastatus, and the Sun-4 %fsr. See ieee_flags(3M) to save and restore floating-point status or control information. SYSTEM V DESCRIPTION setjmp() and longjmp() manipulate only the C stack and registers; they do not save or restore the signal mask. _setjmp() behaves identically to setjmp(), and _longjmp() behaves identically to longjmp(). EXAMPLE The following code fragment indicates the flow of control of the setjmp() and longjmp() combination: function declaration ... jmp_buf my_environment; ... if (setjmp(my_environment)) { /* register variables have unpredictable values */ code after the return from longjmp ... } else { /* do not modify register vars in this leg of code */ this is the return from setjmp ... } SEE ALSO cc(1V), sigsetmask(2), sigvec(2), ieee_flags(3M), signal(3V), setjmp(3V) BUGS setjmp() does not save the current notion of whether the process is executing on the signal stack. The result is that a longjmp() to some place on the signal stack leaves the signal stack state incorrect. On Sun-2 and Sun-3 systems setjmp() also saves the register environment. Therefore, all data that are bound to regis- ters are restored to the values they had at the time that setjmp() was called. All memory-bound data have values as of the time longjmp() was called. However, because the register storage class is only a hint to the C compiler, variables declared as register variables may not necessarily be assigned to machine registers, so their values are unpredictable after a longjmp(). When using compiler options that specify automatic register allocation (see cc(1V)), the compiler will not attempt to assign variables to registers in routines that call setjmp(). Sun Release 4.1 Last change: 5 October 1989





Ready to take that job and shove it?

Function:

Keyword(s):

State:
SPONSOR
RECENT JOB POSTINGS
CAREER NEWS
Go beyond Google and get vertical. These specialized search sites will help you find the business information you need -- fast.

Ari Balogh was named to the post of chief technology officer as the companys for a "realignment" of employees.










InformationWeek U.S. IT Salary Survey 2008
Salaries for business technology professionals are falling. Here's what you need to know in order to make good hiring decisions and personal career choices. Download Today
 
ROLLING RIGHT ALONG
Follow key Network Computing Reviews from conception to completion. This Week: Holistic APM.



Network Computing Reports Emerging Enterprise Podcast Series: Secrets to Success








TechSearch


Microsite of the Week


Powerful Information at Your Fingertips



InformationWeek Business Technology Network
InformationWeekInformationWeek 500InformationWeek 500 ConferenceInformationWeek AnalyticsInformationWeek CIO
InformationWeek EventsInformationWeek ReportsInformationWeek MagazinebMightyByte and SwitchDark Reading
Digital LibraryIntelligent EnterpriseInternet EvolutionNetwork ComputingNo JitterPlug Into The Cloud
space
Techweb Events Network
InteropVoiceConWeb 2.0 ExpoWeb 2.0 SummitEnterprise 2.0 ConferenceMobile Business ExpoSoftware ConferenceCSI - Computer Security Institute
Black HatGTECEnergy CampMashup CampStartup Camp
space
Light Reading Communications Network
Light ReadingLight Reading EuropeUnstrungLight Reading's Cable Digital NewsConstantinopleInternet EvolutionPyramid Research
Heavy ReadingLight Reading Live!Light Reading InsiderEthernet ExpoOptical ExpoTeleco TVTower Technology Summit
space
Financial Technology Network
Advanced TradingBank Systems & TechnologyInsurance & TechnologyWall Street & TechnologyAccelerating Wall StreetBank Systems & Technology Executive SummitBuyside Trading SummitInsurance & Technology Executive Summit
space
Microsoft Technology Network
MSDN MagazineTechNetThe Architecture Journal
space


App Infrastructure   |   Messaging & Collaboration   |   Network & Systems Mgmt   |   Network Infrastructure   |   Security  |   Storage & Servers   |   Wireless   |   Enterprise Apps
About Us  |  Contact Us  |  Site Map  |  Technology Marketing Solutions  |  Advertising Contacts  |   Briefing Centers
Copyright © 2008  United Business Media LLC  |  Privacy Statement  |  Terms of Service  |  Your California Privacy Rights