Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel'
[palacios.git] / kitten / arch / x86_64 / lib / extable.c
1 /*
2  * lwk/arch/x86_64/lib/extable.c
3  */
4
5 #include <lwk/stddef.h>
6 #include <lwk/extable.h>
7
8 /* Simple binary search */
9 const struct exception_table_entry *
10 search_extable(const struct exception_table_entry *first,
11                const struct exception_table_entry *last,
12                unsigned long value)
13 {
14         /* Work around a B stepping K8 bug */
15         if ((value >> 32) == 0)
16                 value |= 0xffffffffUL << 32; 
17
18         while (first <= last) {
19                 const struct exception_table_entry *mid;
20                 long diff;
21
22                 mid = (last - first) / 2 + first;
23                 diff = mid->insn - value;
24                 if (diff == 0)
25                         return mid;
26                 else if (diff < 0)
27                         first = mid+1;
28                 else
29                         last = mid-1;
30         }
31         return NULL;
32 }