Dear x32 specialists,
A while ago, I got the "IRAF" package accepted into Debian [1]. Although
the code is claimed to be portable, it needs a piece of assembler
code for each platform that provides a (sort of) setjmp() to their
Fortran variant.

Advertising

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.
There is already some working code for x64 in the original distribution:
-------------------------------8<-----------------------------------
.file "zsvjmp.s"
.globl zsvjmp_
.type zsvjmp_, @function
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@PLT # let sigsetjmp do the rest
.section .note.GNU-stack,"",@progbits
-------------------------------8<-----------------------------------
The "zdojmp" counterpart is a portable C function.
I created a small repository [2] that contains the assembler I collected
so far as well as two test programs.
However, I have no idea how to write the same for the 32-bit platform
x32. Maybe someone could help me here? Preferably under the IRAF
license [3], so that it can be included upstream later.
There is no request from the users to have this ported to x32, and I
doubt that ever will. My main motivation to get it ported is to check
the package for hidden problems on "unusual" architectures.
One additional question to x32: how do I distinguish on shell level
between i386, x32 and x64?
Best regards
Ole
[1] https://tracker.debian.org/pkg/iraf
[2] https://github.com/olebole/zsvjmp
[3] https://github.com/iraf/iraf-v216/blob/master/local/COPYRIGHTS