From: Matt Mackall <mpm@selenic.com>
To: Andrew Morton <akpm@osdl.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 7/8] lib/sort: Replace insertion sort in IA64 exception tables
Date: Mon, 31 Jan 2005 01:35:01 -0600 [thread overview]
Message-ID: <8.416337461@selenic.com> (raw)
In-Reply-To: <7.416337461@selenic.com>
Switch IA64 exception tables to lib/sort.
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: tq/arch/ia64/mm/extable.c
===================================================================
--- tq.orig/arch/ia64/mm/extable.c 2005-01-25 09:20:53.000000000 -0800
+++ tq/arch/ia64/mm/extable.c 2005-01-30 13:56:18.000000000 -0800
@@ -6,29 +6,24 @@
*/
#include <linux/config.h>
+#include <linux/sort.h>
#include <asm/uaccess.h>
#include <asm/module.h>
-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;
- if (lip < rip)
- return -1;
- if (lip == rip)
- return 0;
- else
- return 1;
+ return lip - rip;
}
-static inline void
-swap_entries (struct exception_table_entry *l, struct exception_table_entry *r)
+static void swap_ex(void *a, void *b)
{
+ 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 +33,20 @@
}
/*
- * 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 *
next prev parent reply other threads:[~2005-01-31 7:41 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-31 7:34 [PATCH 0/8] lib/sort: Add generic sort to lib/ Matt Mackall
2005-01-31 7:34 ` [PATCH 1/8] lib/sort: Heapsort implementation of sort() Matt Mackall
2005-01-31 7:34 ` [PATCH 2/8] lib/sort: Replace qsort in XFS Matt Mackall
2005-01-31 7:35 ` [PATCH 3/8] lib/sort: Replace qsort in NFS ACL code Matt Mackall
2005-01-31 7:35 ` [PATCH 4/8] lib/sort: Kill qsort() Matt Mackall
2005-01-31 7:35 ` [PATCH 5/8] lib/sort: Replace open-coded O(pids**2) bubblesort in cpusets Matt Mackall
2005-01-31 7:35 ` [PATCH 6/8] lib/sort: Replace insertion sort in exception tables Matt Mackall
2005-01-31 7:35 ` Matt Mackall [this message]
2005-01-31 7:35 ` [PATCH 8/8] lib/sort: Use generic sort on x86_64 Matt Mackall
2005-01-31 12:02 ` [PATCH 5/8] lib/sort: Replace open-coded O(pids**2) bubblesort in cpusets Paul Jackson
2005-02-01 22:29 ` [PATCH 2/8] lib/sort: Replace qsort in XFS Chris Wedgwood
2005-02-01 22:22 ` Randy.Dunlap
2005-02-02 4:31 ` Zan Lynx
2005-02-02 10:48 ` Herbert Xu
2005-02-01 22:48 ` Matt Mackall
2005-01-31 17:16 ` [PATCH 1/8] lib/sort: Heapsort implementation of sort() Andreas Gruenbacher
2005-01-31 17:30 ` Paulo Marques
2005-02-01 17:54 ` Andreas Gruenbacher
2005-02-01 18:11 ` linux-os
2005-02-01 19:04 ` linux-os
2005-02-01 19:47 ` Andreas Gruenbacher
2005-01-31 19:30 ` Matt Mackall
2005-02-01 17:50 ` Andreas Gruenbacher
2005-02-02 1:00 ` Horst von Brand
2005-02-02 10:50 ` Herbert Xu
2005-02-02 11:14 ` Andreas Gruenbacher
2005-02-03 23:19 ` Junio C Hamano
2005-02-01 2:10 ` Horst von Brand
2005-02-27 13:17 ` Andreas Gruenbacher
2005-02-27 21:25 ` Matt Mackall
2005-02-27 21:53 ` Andreas Gruenbacher
2005-02-27 22:10 ` Andreas Gruenbacher
2005-03-01 13:23 ` Andreas Gruenbacher
2005-03-01 19:06 ` Christophe Saout
2005-03-01 20:12 ` Matt Mackall
2005-03-01 21:47 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8.416337461@selenic.com \
--to=mpm@selenic.com \
--cc=akpm@osdl.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox