Fix build failures on HP-UX (#792)
authorMichael Osipov <1983-01-06@gmx.net>
Mon, 4 Sep 2023 11:27:01 +0000 (13:27 +0200)
committerGitHub <noreply@github.com>
Mon, 4 Sep 2023 11:27:01 +0000 (07:27 -0400)
This fixes #328

Co-authored-by: Chris Hunt <chrahunt@gmail.com>
src/ia64/ffi.c
src/ia64/unix.S

index b1d04c3e749b0c6111f32207fad873b64c347a9b..1395f26a88feabe6d9a47bb825af71a1a601bd13 100644 (file)
 /* A 64-bit pointer value.  In LP64 mode, this is effectively a plain
    pointer.  In ILP32 mode, it's a pointer that's been extended to 
    64 bits by "addp4".  */
+#ifdef __hpux
+typedef void *PTR64;
+#else // some other unix
 typedef void *PTR64 __attribute__((mode(DI)));
+#endif
 
 /* Memory image of fp register contents.  This is the implementation
    specific format used by ldf.fill/stf.spill.  All we care about is
@@ -76,14 +80,22 @@ endian_adjust (void *addr, size_t len)
    point types without type conversions.  Type conversion to long double breaks
    the denorm support.  */
 
+#ifdef __hpux
+#define stf_spill(addr, value)
+#else
 #define stf_spill(addr, value) \
   asm ("stf.spill %0 = %1%P0" : "=m" (*addr) : "f"(value));
+#endif
 
 /* Load a value from ADDR, which is in the current cpu implementation's
    fp spill format.  As above, this must also be a macro.  */
 
+#ifdef __hpux
+#define ldf_fill(result, addr)
+#else
 #define ldf_fill(result, addr) \
   asm ("ldf.fill %0 = %1%P1" : "=f"(result) : "m"(*addr));
+#endif
 
 /* Return the size of the C type associated with with TYPE.  Which will
    be one of the FFI_IA64_TYPE_HFA_* values.  */
index e2547e02b3aa1c173bdbc80fc8ef78c00194c34f..04908368c3e26a20f716d14d499f986905168bb7 100644 (file)
 
        .pred.safe_across_calls p1-p5,p16-p63
 .text
+/* HPUX assembler needs to see these symbols, otherwise compilation
+   fails */
+#ifdef __hpux
+      .global memcpy
+      .global ffi_closure_unix_inner
+#endif
 
 /* int ffi_call_unix (struct ia64_args *stack, PTR64 rvalue,
                      void (*fn)(void), int flags);
@@ -104,7 +110,12 @@ ffi_call_unix:
        mov     ar.pfs = loc0
        addl    r18 = @ltoffx(.Lst_table), gp
        ;;
+       /* default assembler on HP-UX does not support LDXMOV */
+#ifdef __hpux
+       ld8     r18 = [r18]
+#else
        ld8.mov r18 = [r18], .Lst_table
+#endif
        mov     b0 = loc1
        ;;
        shladd  r18 = r16, 3, r18
@@ -357,7 +368,11 @@ ffi_closure_unix:
        addl    r18 = @ltoffx(.Lld_table), gp
        mov     ar.pfs = loc0
        ;;
-       ld8.mov r18 = [r18], .Lld_table
+#ifdef __hpux
+       ld8     r18 = [r18]
+#else
+       ld8.mov r18 = [r18], .Lst_table
+#endif
        mov     b0 = loc1
        ;;
        shladd  r18 = r16, 3, r18
@@ -515,8 +530,11 @@ ffi_closure_unix:
        ;;
 
        .endp   ffi_closure_unix
-
+#ifdef __hpux
+       .rodata
+#else
        .section .rodata
+#endif
        .align  8
 .Lst_table:
        data8   @pcrel(.Lst_void)               // FFI_TYPE_VOID