Hi,
I am working on the packaging of the "IRAF" package
<http://iraf.noao.edu/>. The package uses a special variant of
setjmp()/longjmp() called from Fortran. Due to the nature of setjmp(),
this cannot be called directly from a subroutine. In the package, this
is solved by using some assembler (see f.e. the attached file for
Linux/x86-64). This is, however, highly non-portable (while Debian
supports ~15 architectures) and so I was thinking in using a patched
libunwind-setjmp instead (which is also available for Debian).
Unfortunately, I cannot get it to work. Neither in the version provided
by Debian (resp. Ubuntu), nor in a self-compiled library, I could find
the symbol for longjmp. Is this correct? How could I get a working
versions of these?
The other question I have is how can I write a replacement for the
zsvjmp assembler code using the libunwind. I did some try (see other
attached file); however this requires the "jmpbuf.h" which seems not to
be installed by default. Is there a better way to do that?
Best regards
Ole
.file "zsvjmp.s"
# ZSVJMP, ZDOJMP -- Set up a jump (non-local goto) by saving the processor
# registers in the buffer jmpbuf. A subsequent call to ZDOJMP restores
# the registers, effecting a call in the context of the procedure which
# originally called ZSVJMP, but with the new status code. These are Fortran
# callable procedures.
#
# zsvjmp (jmp_buf, status) # (returns status)
# zdojmp (jmp_buf, status) # (passes status to zsvjmp)
#
# These routines are directly comparable to the UNIX setjmp/longjmp, except
# that they are Fortran callable kernel routines, i.e., trailing underscore,
# call by reference, and no function returns. ZSVJMP requires an assembler
# jacket routine to avoid modifying the call stack, but relies upon setjmp
# to do the real work. ZDOJMP is implemented as a portable C routine in OS,
# calling longjmp to do the restore. In these routines, JMP_BUF consists
# of one longword containing the address of the STATUS variable, followed
# by the "jmp_buf" used by setjmp/longjmp.
#
# This file contains the FreeBSD (x86) version of ZSVJMP.
# Modified to remove leading underscore for ELF (Jan99).
#.globl _zsvjmp_
.globl zsvjmp_
# The following has nothing to do with ZSVJMP, and is included here
# only because this assembler module is loaded with every process.
# This code sets the value of the symbol MEM (the VOS or Fortran Mem
# common) to zero, setting the origin for IRAF pointers to zero
# rather than some arbitrary value, and ensuring that the MEM common
# is aligned for all datatypes as well as page aligned. A further
# advantage is that references to NULL pointers are likely to cause a
# memory violation.
#.globl mem_
#mem_ = 0
.globl _mem_
_mem_ = 0
zsvjmp_:
# %rsi ... &status %rdi ... &jumpbuf
movq %rsi, (%rdi) # store &status in jmpbuf[0]
movl $0, (%rsi) # zero the value of status
addq $8, %rdi # change point to &jmpbuf[1]
movl $0, %esi # change arg2 to zero
jmp __sigsetjmp # let sigsetjmp do the rest
#include <libunwind.h>
#include <setjmp.h>
#include "jmpbuf.h"
//#define import_spp
//#include <iraf.h>
#define XINT long
#define XPOINTER long
int zsvjmp_( XPOINTER *buf, XINT *status )
{
*status = 0;
((XINT **)buf)[0] = status;
jmp_buf *env = (jmp_buf *)((XINT **)buf+1);
void **wp = (void **) *env;
wp[JB_SP] = __builtin_frame_address (0);
wp[JB_RP] = (void *) __builtin_return_address (0);
return 0;
}
_______________________________________________
Libunwind-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/libunwind-devel