Xen Test Framework
extable.c
Go to the documentation of this file.
1 
6 #include <xtf/lib.h>
7 #include <xtf/extable.h>
8 
10 
11 const struct extable_entry *search_extable(unsigned long addr)
12 {
13  const struct extable_entry *start = __start_ex_table,
14  *stop = __stop_ex_table, *mid;
15 
16  while ( start <= stop )
17  {
18  mid = start + (stop - start) / 2;
19 
20  if ( addr == mid->fault )
21  return mid;
22  else if ( addr > mid->fault )
23  start = mid + 1;
24  else
25  stop = mid - 1;
26  }
27 
28  return 0;
29 }
30 
31 static int compare_extable_entry(const void *_l, const void *_r)
32 {
33  const struct extable_entry *l = _l, *r = _r;
34 
35  if ( l->fault == r->fault )
36  return 0;
37  else if ( l->fault > r->fault )
38  return 1;
39  else
40  return -1;
41 }
42 
43 static void swap_extable_entry(void *_l, void *_r)
44 {
45  struct extable_entry tmp, *l = _l, *r = _r;
46 
47  tmp = *l;
48  *l = *r;
49  *r = tmp;
50 }
51 
52 void sort_extable(void)
53 {
56  sizeof(__start_ex_table[0]),
59 }
60 
61 /*
62  * Local variables:
63  * mode: C
64  * c-file-style: "BSD"
65  * c-basic-offset: 4
66  * tab-width: 4
67  * indent-tabs-mode: nil
68  * End:
69  */
static int compare_extable_entry(const void *_l, const void *_r)
Definition: extable.c:31
void sort_extable(void)
Sort the exception table.
Definition: extable.c:52
Exception table support.
unsigned long fault
Faulting address.
Definition: extable.h:66
const struct extable_entry * search_extable(unsigned long addr)
Search the exception table to find the entry associated with a specific faulting address.
Definition: extable.c:11
void heapsort(void *base, size_t nmemb, size_t _size, int(*compar)(const void *, const void *), void(*swap)(void *, void *))
Definition: heapsort.c:25
Exception table entry.
Definition: extable.h:64
struct extable_entry __start_ex_table[]
static void swap_extable_entry(void *_l, void *_r)
Definition: extable.c:43
struct extable_entry __stop_ex_table[]