ia64/xen-unstable

view xen/arch/x86/extable.c @ 5310:226484ec5fb0

bitkeeper revision 1.1665.1.2 (42a09c3c5379JgWLZ0YowQ5DA_wjHg)

Fix compilation problem when perf counters are enabled.
author mafetter@fleming.research
date Fri Jun 03 18:06:52 2005 +0000 (2005-06-03)
parents 65b28c74cec2
children fea2f7f8df31
line source
2 #include <xen/config.h>
3 #include <xen/spinlock.h>
4 #include <asm/uaccess.h>
6 #ifdef PERF_COUNTERS
7 #include <xen/sched.h>
8 #include <xen/perfc.h>
9 #include <asm/current.h>
10 #endif
12 extern struct exception_table_entry __start___ex_table[];
13 extern struct exception_table_entry __stop___ex_table[];
14 extern struct exception_table_entry __start___pre_ex_table[];
15 extern struct exception_table_entry __stop___pre_ex_table[];
17 static void sort_exception_table(struct exception_table_entry *start,
18 struct exception_table_entry *end)
19 {
20 struct exception_table_entry *p, *q, tmp;
22 for ( p = start; p < end; p++ )
23 {
24 for ( q = p-1; q > start; q-- )
25 if ( p->insn > q->insn )
26 break;
27 if ( ++q != p )
28 {
29 tmp = *p;
30 memmove(q+1, q, (p-q)*sizeof(*p));
31 *q = tmp;
32 }
33 }
34 }
36 void sort_exception_tables(void)
37 {
38 sort_exception_table(__start___ex_table, __stop___ex_table);
39 sort_exception_table(__start___pre_ex_table, __stop___pre_ex_table);
40 }
42 static inline unsigned long
43 search_one_table(const struct exception_table_entry *first,
44 const struct exception_table_entry *last,
45 unsigned long value)
46 {
47 const struct exception_table_entry *mid;
48 long diff;
50 while ( first <= last )
51 {
52 mid = (last - first) / 2 + first;
53 diff = mid->insn - value;
54 if (diff == 0)
55 return mid->fixup;
56 else if (diff < 0)
57 first = mid+1;
58 else
59 last = mid-1;
60 }
61 return 0;
62 }
64 unsigned long
65 search_exception_table(unsigned long addr)
66 {
67 return search_one_table(
68 __start___ex_table, __stop___ex_table-1, addr);
69 }
71 unsigned long
72 search_pre_exception_table(struct cpu_user_regs *regs)
73 {
74 unsigned long addr = (unsigned long)regs->eip;
75 unsigned long fixup = search_one_table(
76 __start___pre_ex_table, __stop___pre_ex_table-1, addr);
77 DPRINTK("Pre-exception: %p -> %p\n", _p(addr), _p(fixup));
78 #ifdef PERF_COUNTERS
79 if ( fixup )
80 perfc_incrc(exception_fixed);
81 #endif
82 return fixup;
83 }