$NetBSD: patch-ad,v 1.2 2004/03/02 16:05:01 adam Exp $ --- callback/trampoline_r/trampoline.c.orig 2004-01-26 15:00:05.000000000 +0000 +++ callback/trampoline_r/trampoline.c @@ -283,7 +283,7 @@ extern void __TR_clear_cache(); #define TRAMP_LENGTH 32 #define TRAMP_ALIGN 4 #endif -#ifdef __rs6000sysv4__ +#if defined(__rs6000sysv4__) || defined(__rs6000netbsd__) #define TRAMP_LENGTH 24 #define TRAMP_ALIGN 4 #endif @@ -878,6 +878,39 @@ __TR_function alloc_trampoline_r (addres #define tramp_data(function) \ hilo(*(unsigned short *) (function + 2), *(unsigned short *) (function + 6)) #endif +#ifdef __rs6000netbsd__ + /* 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 && \ + *(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