Ole Streicher
2014-05-05 09:00:02 UTC
Hi,
since a while, I am working to bring the IRAF package [1] into Debian
[2]. I'd like to make the package working on as many Debian platforms as
possible.
The major problem here is that IRAF needs a small piece of assembler
code that provides a (sort of) setjmp() to their Fortran variant.
A "C" implementation for this looks like:
#include <setjmp.h>
int zsvjmp_( long *buf, long *status ) {
*status = 0;
((long **)buf)[0] = status;
return sigsetjmp ((void *)((long **)buf+1),0);
}
however this does not work, since the "sigsetjmp" call needs to be
replaced by a jump to sigsetjmp instead.
As example, I show here the assembler for x86-64 (from the IRAF sources):
.globl zsvjmp_
.type zsvjmp_, @function
zsvjmp_:
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
.section .note.GNU-stack,"",@progbits
The "zdojmp" counterpart is a portable C function.
I created a small tar file that contains the assembler I collected so
far as well as two test programs. The function of the Fortran test
program is still not so important since IRAF uses its own Fortran
calling interface.
Since I have no experience with s390 machines and no glue at all for
their assembler and the (C) calling conventions: could someone help me here?
Best regards
Ole
[1] http://http://iraf.noao.edu/
[2] http://bugs.debian.org/690531
since a while, I am working to bring the IRAF package [1] into Debian
[2]. I'd like to make the package working on as many Debian platforms as
possible.
The major problem here is that IRAF needs a small piece of assembler
code that provides a (sort of) setjmp() to their Fortran variant.
A "C" implementation for this looks like:
#include <setjmp.h>
int zsvjmp_( long *buf, long *status ) {
*status = 0;
((long **)buf)[0] = status;
return sigsetjmp ((void *)((long **)buf+1),0);
}
however this does not work, since the "sigsetjmp" call needs to be
replaced by a jump to sigsetjmp instead.
As example, I show here the assembler for x86-64 (from the IRAF sources):
.globl zsvjmp_
.type zsvjmp_, @function
zsvjmp_:
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
.section .note.GNU-stack,"",@progbits
The "zdojmp" counterpart is a portable C function.
I created a small tar file that contains the assembler I collected so
far as well as two test programs. The function of the Fortran test
program is still not so important since IRAF uses its own Fortran
calling interface.
Since I have no experience with s390 machines and no glue at all for
their assembler and the (C) calling conventions: could someone help me here?
Best regards
Ole
[1] http://http://iraf.noao.edu/
[2] http://bugs.debian.org/690531