[PATCH 6/8] lib/sort: Replace insertion sort in exception tables

From: Matt Mackall (mpm_at_selenic.com)
Date: 01/31/05

  • Next message: Christoph Hellwig: "Re: 2.6.11-rc2-mm2"
    Date:	Mon, 31 Jan 2005 01:35:00 -0600
    To: Andrew Morton <akpm@osdl.com>
    
    

    Replace exception table insertion sort with lib/sort

    Signed-off-by: Matt Mackall <mpm@selenic.com>

    Index: mm2/lib/extable.c
    ===================================================================
    --- mm2.orig/lib/extable.c 2005-01-30 20:33:18.000000000 -0800
    +++ mm2/lib/extable.c 2005-01-30 20:40:53.000000000 -0800
    @@ -13,6 +13,7 @@
     #include <linux/config.h>
     #include <linux/module.h>
     #include <linux/init.h>
    +#include <linux/sort.h>
     #include <asm/uaccess.h>
     
     extern struct exception_table_entry __start___ex_table[];
    @@ -25,26 +26,17 @@
      * This is used both for the kernel exception table and for
      * the exception tables of modules that get loaded.
      */
    +static int cmp_ex(const void *a, const void *b)
    +{
    + const struct exception_table_entry *x = a, *y = b;
    + return x->insn - y->insn;
    +}
    +
     void sort_extable(struct exception_table_entry *start,
                       struct exception_table_entry *finish)
     {
    - struct exception_table_entry el, *p, *q;
    -
    - /* insertion sort */
    - for (p = start + 1; p < finish; ++p) {
    - /* start .. p-1 is sorted */
    - if (p[0].insn < p[-1].insn) {
    - /* move element p down to its right place */
    - el = *p;
    - q = p;
    - do {
    - /* el comes before q[-1], move q[-1] up one */
    - q[0] = q[-1];
    - --q;
    - } while (q > start && el.insn < q[-1].insn);
    - *q = el;
    - }
    - }
    + sort(start, finish - start, sizeof(struct exception_table_entry),
    + cmp_ex, 0);
     }
     #endif
     
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Christoph Hellwig: "Re: 2.6.11-rc2-mm2"

    Relevant Pages

    • [patch v2] x86: Add testcases for RODATA and NX protections/attributes
      ... +config DEBUG_RODATA_TEST ... this implies having dynamic exception handling table entries. ... +static void test_exit ...
      (Linux-Kernel)
    • Re: Object reference not set to an instance of an object.
      ... > The event handler WTGDataRowReady10Handler is called by a delegate in the ... > catch (Exception ex) ... > private void WTGDataRowReady10Handler( ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: N1298 - try/finally for C
      ... Using a void*, or something containing a void*, gives ... Then we have a function that potentially throws an exception: ... If you mean some custom allocator, then we generally need to pass yet ... As for function pointers, and besides that throwing function pointers ...
      (comp.std.c)
    • [RFC] Improved versioned pointer algorithms
      ... The orphan test is used in snapshot write and exception delete to ... The current method of determining whether a ghost exception is an ... its child count then the ghost exception is an orphan, ... void set_bit ...
      (Linux-Kernel)
    • RE: Custom permission
      ... exception directly, but to make it rasing if someone in the deeper frame ... void Bar() ... permission is not granted, expection will be raised, too. ... | From: "Marcelo Palladino" ...
      (microsoft.public.dotnet.security)