$NetBSD: patch-ah,v 1.1 2002/03/14 07:44:23 jmc Exp $ --- ../ffcall/callback/trampoline_r/trampoline.c.orig Thu Mar 14 07:23:32 2002 +++ ../ffcall/callback/trampoline_r/trampoline.c Thu Mar 14 07:23:35 2002 @@ -21,12 +21,16 @@ #endif #endif #if defined(__rs6000__) +#if defined(__NetBSD__) +#define __powerpcnetbsd__ +#else #if !defined(_AIX) #define __rs6000sysv4__ /* SysV.4 ABI, real machine code. */ #else #define __rs6000aix__ /* AIX ABI, just a closure. */ #endif #endif +#endif #if defined(__hppanew__) /* * A function pointer is a biased pointer to a data area whose first word @@ -259,7 +263,7 @@ #include #endif /* Inline assembly function for instruction cache flush. */ -#if defined(__sparc__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppaold__) || defined(__rs6000sysv4__) || defined(__convex__) +#if defined(__sparc__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppaold__) || defined(__rs6000sysv4__) || defined(__convex__) || defined(__powerpcnetbsd__) #ifdef __GNUC__ extern inline #if defined(__sparc__) || defined(__sparc64__) @@ -336,7 +340,7 @@ #define TRAMP_LENGTH 32 #define TRAMP_ALIGN 4 #endif -#ifdef __rs6000sysv4__ +#if defined(__rs6000sysv4__) || defined(__powerpcnetbsd__) #define TRAMP_LENGTH 24 #define TRAMP_ALIGN 4 #endif @@ -872,6 +876,39 @@ #define is_tramp(function) \ *(unsigned short *) (function + 0) == 0x3D60 && \ *(unsigned short *) (function + 4) == 0x616B && \ + *(unsigned short *) (function + 8) == 0x3C00 && \ + *(unsigned short *) (function +12) == 0x6000 && \ + *(unsigned long *) (function +16) == 0x7C0903A6 && \ + *(unsigned long *) (function +20) == 0x4E800420 +#define hilo(hiword,loword) \ + (((unsigned long) (hiword) << 16) | (unsigned long) (loword)) +#define tramp_address(function) \ + hilo(*(unsigned short *) (function +10), *(unsigned short *) (function +14)) +#define tramp_data(function) \ + hilo(*(unsigned short *) (function + 2), *(unsigned short *) (function + 6)) +#endif +#ifdef __powerpcnetbsd__ + /* function: + * {liu|lis} 13,hi16() 3D A0 hi16() + * {oril|ori} 13,13,lo16() 61 AD lo16() + * {liu|lis} 0,hi16(
) 3C 00 hi16(
) + * {oril|ori} 0,0,lo16(
) 60 00 lo16(
) + * mtctr 0 7C 09 03 A6 + * bctr 4E 80 04 20 + */ + *(short *) (function + 0) = 0x3DA0; + *(short *) (function + 2) = (unsigned long) data >> 16; + *(short *) (function + 4) = 0x61AD; + *(short *) (function + 6) = (unsigned long) data & 0xffff; + *(short *) (function + 8) = 0x3C00; + *(short *) (function +10) = (unsigned long) address >> 16; + *(short *) (function +12) = 0x6000; + *(short *) (function +14) = (unsigned long) address & 0xffff; + *(long *) (function +16) = 0x7C0903A6; + *(long *) (function +20) = 0x4E800420; +#define is_tramp(function) \ + *(unsigned short *) (function + 0) == 0x3DA0 && \ + *(unsigned short *) (function + 4) == 0x61AD && \ *(unsigned short *) (function + 8) == 0x3C00 && \ *(unsigned short *) (function +12) == 0x6000 && \ *(unsigned long *) (function +16) == 0x7C0903A6 && \