5 void *func[8], **pfunc;
7 typedef struct xxx xxx_t;
20 #define EXPORT_FUNC(x) \
22 " .globl mon_" #x "\n" \
25 " movl pfunc, %%ecx\n" \
26 " jmp *(%%ecx,%%eax)\n" \
27 : : "i"(XF_ ## x * sizeof(void *)) : "eax", "ecx");
28 #elif defined(__powerpc__)
29 #define EXPORT_FUNC(x) \
31 " .globl mon_" #x "\n" \
33 " lwz %%r11, %0(%%r2)\n" \
34 " lwz %%r11, %1(%%r11)\n" \
37 : : "i"(offsetof(xxx_t, pfunc)), "i"(XF_ ## x * sizeof(void *)) : "r11", "r2");
38 #elif defined(__arm__)
39 #define EXPORT_FUNC(x) \
41 " .globl mon_" #x "\n" \
43 " ldr ip, [r8, %0]\n" \
44 " ldr pc, [ip, %1]\n" \
45 : : "i"(offsetof(xxx_t, pfunc)), "i"(XF_ ## x * sizeof(void *)) : "ip");
46 #elif defined(__mips__)
47 #define EXPORT_FUNC(x) \
49 " .globl mon_" #x "\n" \
51 " lw $25, %0($26)\n" \
52 " lw $25, %1($25)\n" \
54 : : "i"(offsetof(xxx_t, pfunc)), "i"(XF_ ## x * sizeof(void *)) : "t9");
56 #error [No stub code for this arch]
69 #elif defined(__powerpc__)
70 register volatile xxx_t *pq asm("r2");
71 #elif defined(__arm__)
72 register volatile xxx_t *pq asm("r8");
73 #elif defined(__mips__)
74 register volatile xxx_t *pq asm("k0");
78 func[XF_strcpy] = strcpy;
79 func[XF_printf] = printf;
81 pq->pfunc = pfunc = func;
83 mon_strcpy(buf, "test");
84 mon_printf("hi %s %d z\n", buf, 444);