$NetBSD: patch-ad,v 1.1 2003/03/06 23:50:53 jmc Exp $ --- ./callback/trampoline_r/trampoline.c.orig Thu Mar 6 23:19:30 2003 +++ ./callback/trampoline_r/trampoline.c Thu Mar 6 23:35:53 2003 @@ -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 <sys/syslocal.h> #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 @@ -876,6 +880,39 @@ #define tramp_data(function) \ hilo(*(unsigned short *) (function + 2), *(unsigned short *) (function + 6)) #endif +#ifdef __powerpcnetbsd__ + /* function: + * {liu|lis} 13,hi16(<data>) 3D A0 hi16(<data>) + * {oril|ori} 13,13,lo16(<data>) 61 AD lo16(<data>) + * {liu|lis} 0,hi16(<address>) 3C 00 hi16(<address>) + * {oril|ori} 0,0,lo16(<address>) 60 00 lo16(<address>) + * 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 && \ + *(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 __rs6000aix__ /* function: * .long .tramp_r