home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!pgroup!lfm
- From: lfm@pgroup.com (Larry Meadows)
- Subject: Re: ENTRY in main (was re: Jumping from nested subroutine)
- Message-ID: <By6Ast.BA1@pgroup.com>
- Date: Mon, 23 Nov 1992 14:26:53 GMT
- References: <By4xpo.FG@iapa.uucp%mailhost.ecn.uoknor.edu> <1992Nov23.114807.4734@monu6.cc.monash.edu.au>
- Organization: The Portland Group, Portland, OR
- Lines: 28
-
- Well, I can't resist...
-
- What the original poster wants is called non-local GOTO in pascal, and
- setjmp/longjmp in C. In either case, the return stack is unwound to
- the invocation record of the function to which control is being returned.
- In pascal this is the function containing the label to which control
- is being transferred; in C, it is the function that called setjmp.
-
- Ordinarily, unwinding the stack consists of restoring the stack pointer,
- possibly the frame pointer; then, control transfer is performed by loading
- the program counter (i.e., performing an indirect branch). Machines
- with register windows are more complicated; I'm sure someone can tell us
- exactly how it is done on the Sparc.
-
- So, anyway, it should be possible to call setjmp and longjmp from fortran,
- assuming they exist on the original poster's system. Problem is, they
- would need fortran entry points, since wrapping a C function around
- the original setjmp/longjmp won't work (setjmp must be called from the
- function to which control is to return, then that function must not return
- before longjmp is called). If fortran entry point's don't exist, I'd
- be inclined to hack the object to create them.
-
- Of course, the ability to do all this is entirely system dependent.
-
- Good luck.
- --
- Larry Meadows The Portland Group
- lfm@pgroup.com
-