diff options
| author | Jiri Kosina <jkosina@suse.cz> | 2017-05-02 05:02:41 -0400 | 
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2017-05-02 05:02:41 -0400 | 
| commit | 4d6ca227c768b50b05cf183974b40abe444e9d0c (patch) | |
| tree | bf953d8e895281053548b9967a2c4b58d641df00 /lib/sort.c | |
| parent | 800f3eef8ebc1264e9c135bfa892c8ae41fa4792 (diff) | |
| parent | af22a610bc38508d5ea760507d31be6b6983dfa8 (diff) | |
Merge branch 'for-4.12/asus' into for-linus
Diffstat (limited to 'lib/sort.c')
| -rw-r--r-- | lib/sort.c | 41 | 
1 files changed, 2 insertions, 39 deletions
| diff --git a/lib/sort.c b/lib/sort.c index fc20df42aa6f..975c6ef6fec7 100644 --- a/lib/sort.c +++ b/lib/sort.c | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | * Jan 23 2005 Matt Mackall <mpm@selenic.com> | 4 | * Jan 23 2005 Matt Mackall <mpm@selenic.com> | 
| 5 | */ | 5 | */ | 
| 6 | 6 | ||
| 7 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 8 | |||
| 7 | #include <linux/types.h> | 9 | #include <linux/types.h> | 
| 8 | #include <linux/export.h> | 10 | #include <linux/export.h> | 
| 9 | #include <linux/sort.h> | 11 | #include <linux/sort.h> | 
| @@ -101,42 +103,3 @@ void sort(void *base, size_t num, size_t size, | |||
| 101 | } | 103 | } | 
| 102 | 104 | ||
| 103 | EXPORT_SYMBOL(sort); | 105 | EXPORT_SYMBOL(sort); | 
| 104 | |||
| 105 | #if 0 | ||
| 106 | #include <linux/slab.h> | ||
| 107 | /* a simple boot-time regression test */ | ||
| 108 | |||
| 109 | int cmpint(const void *a, const void *b) | ||
| 110 | { | ||
| 111 | return *(int *)a - *(int *)b; | ||
| 112 | } | ||
| 113 | |||
| 114 | static int sort_test(void) | ||
| 115 | { | ||
| 116 | int *a, i, r = 1; | ||
| 117 | |||
| 118 | a = kmalloc(1000 * sizeof(int), GFP_KERNEL); | ||
| 119 | BUG_ON(!a); | ||
| 120 | |||
| 121 | printk("testing sort()\n"); | ||
| 122 | |||
| 123 | for (i = 0; i < 1000; i++) { | ||
| 124 | r = (r * 725861) % 6599; | ||
| 125 | a[i] = r; | ||
| 126 | } | ||
| 127 | |||
| 128 | sort(a, 1000, sizeof(int), cmpint, NULL); | ||
| 129 | |||
| 130 | for (i = 0; i < 999; i++) | ||
| 131 | if (a[i] > a[i+1]) { | ||
| 132 | printk("sort() failed!\n"); | ||
| 133 | break; | ||
| 134 | } | ||
| 135 | |||
| 136 | kfree(a); | ||
| 137 | |||
| 138 | return 0; | ||
| 139 | } | ||
| 140 | |||
| 141 | module_init(sort_test); | ||
| 142 | #endif | ||
