[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Help needed for small assembler script for the iraf package



Dear Itanium 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.

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 ia64 platform.
Maybe someone could help me here? Preferably under the IRAF
license [3], so that it can be included upstream later.

One way that worked for x32 and for arm64 was to compule the C snipped
above (having the sigsetjmp function name by something else) with an
optimizing compiler; however I didn't find cross compiler with the ia64
target?

There is no request from the users to have this ported to ia64, and I
doubt that ever will. My main motivation to get it ported is to check
the package for hidden problems on "unusual" architectures.

Best regards

Ole

[1] https://tracker.debian.org/pkg/iraf
[2] https://github.com/olebole/zsvjmp
[3] https://iraf-community.github.io/COPYRIGHT.html


Reply to: