X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fia64%2Fmm%2Fextable.c;h=71c50dd8f8706da65a0362dc2ee8e15888c42060;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=2353cc795939b4a5be12f19a9f9f303e6cc5a2ef;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/arch/ia64/mm/extable.c b/arch/ia64/mm/extable.c index 2353cc795..71c50dd8f 100644 --- a/arch/ia64/mm/extable.c +++ b/arch/ia64/mm/extable.c @@ -5,30 +5,29 @@ * David Mosberger-Tang */ -#include +#include #include #include -static inline int -compare_entries (struct exception_table_entry *l, struct exception_table_entry *r) +static int cmp_ex(const void *a, const void *b) { + const struct exception_table_entry *l = a, *r = b; u64 lip = (u64) &l->addr + l->addr; u64 rip = (u64) &r->addr + r->addr; + /* avoid overflow */ + if (lip > rip) + return 1; if (lip < rip) return -1; - if (lip == rip) - return 0; - else - return 1; + return 0; } -static inline void -swap_entries (struct exception_table_entry *l, struct exception_table_entry *r) +static void swap_ex(void *a, void *b, int size) { + struct exception_table_entry *l = a, *r = b, tmp; u64 delta = (u64) r - (u64) l; - struct exception_table_entry tmp; tmp = *l; l->addr = r->addr + delta; @@ -38,23 +37,20 @@ swap_entries (struct exception_table_entry *l, struct exception_table_entry *r) } /* - * Sort the exception table. It's usually already sorted, but there may be unordered - * entries due to multiple text sections (such as the .init text section). Note that the - * exception-table-entries contain location-relative addresses, which requires a bit of - * care during sorting to avoid overflows in the offset members (e.g., it would not be - * safe to make a temporary copy of an exception-table entry on the stack, because the - * stack may be more than 2GB away from the exception-table). + * Sort the exception table. It's usually already sorted, but there + * may be unordered entries due to multiple text sections (such as the + * .init text section). Note that the exception-table-entries contain + * location-relative addresses, which requires a bit of care during + * sorting to avoid overflows in the offset members (e.g., it would + * not be safe to make a temporary copy of an exception-table entry on + * the stack, because the stack may be more than 2GB away from the + * exception-table). */ -void -sort_extable (struct exception_table_entry *start, struct exception_table_entry *finish) +void sort_extable (struct exception_table_entry *start, + struct exception_table_entry *finish) { - struct exception_table_entry *p, *q; - - /* insertion sort */ - for (p = start + 1; p < finish; ++p) - /* start .. p-1 is sorted; push p down to it's proper place */ - for (q = p; q > start && compare_entries(&q[0], &q[-1]) < 0; --q) - swap_entries(&q[0], &q[-1]); + sort(start, finish - start, sizeof(struct exception_table_entry), + cmp_ex, swap_ex); } const struct exception_table_entry * @@ -77,7 +73,7 @@ search_extable (const struct exception_table_entry *first, else last = mid - 1; } - return 0; + return NULL; } void