aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-01-10 21:41:39 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-10 21:41:39 -0500
commitabede81c4fb2e3b85d8760f25e3da39d2c69a134 (patch)
tree26c893ec108d837eb9171d678c55a1cea7b22af4 /lib
parentc9d557c19f94df42db78d4a5de4d25feee694bad (diff)
parentc59765042f53a79a7a65585042ff463b69cb248c (diff)
Merge commit 'v2.6.29-rc1' into core/urgent
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig.debug23
-rw-r--r--lib/rbtree.c12
-rw-r--r--lib/sort.c30
3 files changed, 37 insertions, 28 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 2e75478e9c69..4c9ae6085c75 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -512,6 +512,13 @@ config DEBUG_VIRTUAL
512 512
513 If unsure, say N. 513 If unsure, say N.
514 514
515config DEBUG_NOMMU_REGIONS
516 bool "Debug the global anon/private NOMMU mapping region tree"
517 depends on DEBUG_KERNEL && !MMU
518 help
519 This option causes the global tree of anonymous and private mapping
520 regions to be regularly checked for invalid topology.
521
515config DEBUG_WRITECOUNT 522config DEBUG_WRITECOUNT
516 bool "Debug filesystem writers count" 523 bool "Debug filesystem writers count"
517 depends on DEBUG_KERNEL 524 depends on DEBUG_KERNEL
@@ -566,14 +573,14 @@ config DEBUG_NOTIFIERS
566config FRAME_POINTER 573config FRAME_POINTER
567 bool "Compile the kernel with frame pointers" 574 bool "Compile the kernel with frame pointers"
568 depends on DEBUG_KERNEL && \ 575 depends on DEBUG_KERNEL && \
569 (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390 || \ 576 (CRIS || M68K || M68KNOMMU || FRV || UML || S390 || \
570 AVR32 || SUPERH || BLACKFIN || MN10300) 577 AVR32 || SUPERH || BLACKFIN || MN10300) || \
571 default y if DEBUG_INFO && UML 578 ARCH_WANT_FRAME_POINTERS
572 help 579 default y if (DEBUG_INFO && UML) || ARCH_WANT_FRAME_POINTERS
573 If you say Y here the resulting kernel image will be slightly larger 580 help
574 and slower, but it might give very useful debugging information on 581 If you say Y here the resulting kernel image will be slightly
575 some architectures or if you use external debuggers. 582 larger and slower, but it gives very useful debugging information
576 If you don't debug the kernel, you can say N. 583 in case of kernel bugs. (precise oopses/stacktraces/warnings)
577 584
578config BOOT_PRINTK_DELAY 585config BOOT_PRINTK_DELAY
579 bool "Delay each boot printk message by N milliseconds" 586 bool "Delay each boot printk message by N milliseconds"
diff --git a/lib/rbtree.c b/lib/rbtree.c
index 48499c2d88cc..9956b99649f0 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -292,7 +292,7 @@ EXPORT_SYMBOL(rb_erase);
292/* 292/*
293 * This function returns the first node (in sort order) of the tree. 293 * This function returns the first node (in sort order) of the tree.
294 */ 294 */
295struct rb_node *rb_first(struct rb_root *root) 295struct rb_node *rb_first(const struct rb_root *root)
296{ 296{
297 struct rb_node *n; 297 struct rb_node *n;
298 298
@@ -305,7 +305,7 @@ struct rb_node *rb_first(struct rb_root *root)
305} 305}
306EXPORT_SYMBOL(rb_first); 306EXPORT_SYMBOL(rb_first);
307 307
308struct rb_node *rb_last(struct rb_root *root) 308struct rb_node *rb_last(const struct rb_root *root)
309{ 309{
310 struct rb_node *n; 310 struct rb_node *n;
311 311
@@ -318,7 +318,7 @@ struct rb_node *rb_last(struct rb_root *root)
318} 318}
319EXPORT_SYMBOL(rb_last); 319EXPORT_SYMBOL(rb_last);
320 320
321struct rb_node *rb_next(struct rb_node *node) 321struct rb_node *rb_next(const struct rb_node *node)
322{ 322{
323 struct rb_node *parent; 323 struct rb_node *parent;
324 324
@@ -331,7 +331,7 @@ struct rb_node *rb_next(struct rb_node *node)
331 node = node->rb_right; 331 node = node->rb_right;
332 while (node->rb_left) 332 while (node->rb_left)
333 node=node->rb_left; 333 node=node->rb_left;
334 return node; 334 return (struct rb_node *)node;
335 } 335 }
336 336
337 /* No right-hand children. Everything down and left is 337 /* No right-hand children. Everything down and left is
@@ -347,7 +347,7 @@ struct rb_node *rb_next(struct rb_node *node)
347} 347}
348EXPORT_SYMBOL(rb_next); 348EXPORT_SYMBOL(rb_next);
349 349
350struct rb_node *rb_prev(struct rb_node *node) 350struct rb_node *rb_prev(const struct rb_node *node)
351{ 351{
352 struct rb_node *parent; 352 struct rb_node *parent;
353 353
@@ -360,7 +360,7 @@ struct rb_node *rb_prev(struct rb_node *node)
360 node = node->rb_left; 360 node = node->rb_left;
361 while (node->rb_right) 361 while (node->rb_right)
362 node=node->rb_right; 362 node=node->rb_right;
363 return node; 363 return (struct rb_node *)node;
364 } 364 }
365 365
366 /* No left-hand children. Go up till we find an ancestor which 366 /* No left-hand children. Go up till we find an ancestor which
diff --git a/lib/sort.c b/lib/sort.c
index 6abbaf3d5858..926d00429ed2 100644
--- a/lib/sort.c
+++ b/lib/sort.c
@@ -32,11 +32,11 @@ static void generic_swap(void *a, void *b, int size)
32 * @base: pointer to data to sort 32 * @base: pointer to data to sort
33 * @num: number of elements 33 * @num: number of elements
34 * @size: size of each element 34 * @size: size of each element
35 * @cmp: pointer to comparison function 35 * @cmp_func: pointer to comparison function
36 * @swap: pointer to swap function or NULL 36 * @swap_func: pointer to swap function or NULL
37 * 37 *
38 * This function does a heapsort on the given array. You may provide a 38 * This function does a heapsort on the given array. You may provide a
39 * swap function optimized to your element type. 39 * swap_func function optimized to your element type.
40 * 40 *
41 * Sorting time is O(n log n) both on average and worst-case. While 41 * Sorting time is O(n log n) both on average and worst-case. While
42 * qsort is about 20% faster on average, it suffers from exploitable 42 * qsort is about 20% faster on average, it suffers from exploitable
@@ -45,37 +45,39 @@ static void generic_swap(void *a, void *b, int size)
45 */ 45 */
46 46
47void sort(void *base, size_t num, size_t size, 47void sort(void *base, size_t num, size_t size,
48 int (*cmp)(const void *, const void *), 48 int (*cmp_func)(const void *, const void *),
49 void (*swap)(void *, void *, int size)) 49 void (*swap_func)(void *, void *, int size))
50{ 50{
51 /* pre-scale counters for performance */ 51 /* pre-scale counters for performance */
52 int i = (num/2 - 1) * size, n = num * size, c, r; 52 int i = (num/2 - 1) * size, n = num * size, c, r;
53 53
54 if (!swap) 54 if (!swap_func)
55 swap = (size == 4 ? u32_swap : generic_swap); 55 swap_func = (size == 4 ? u32_swap : generic_swap);
56 56
57 /* heapify */ 57 /* heapify */
58 for ( ; i >= 0; i -= size) { 58 for ( ; i >= 0; i -= size) {
59 for (r = i; r * 2 + size < n; r = c) { 59 for (r = i; r * 2 + size < n; r = c) {
60 c = r * 2 + size; 60 c = r * 2 + size;
61 if (c < n - size && cmp(base + c, base + c + size) < 0) 61 if (c < n - size &&
62 cmp_func(base + c, base + c + size) < 0)
62 c += size; 63 c += size;
63 if (cmp(base + r, base + c) >= 0) 64 if (cmp_func(base + r, base + c) >= 0)
64 break; 65 break;
65 swap(base + r, base + c, size); 66 swap_func(base + r, base + c, size);
66 } 67 }
67 } 68 }
68 69
69 /* sort */ 70 /* sort */
70 for (i = n - size; i > 0; i -= size) { 71 for (i = n - size; i > 0; i -= size) {
71 swap(base, base + i, size); 72 swap_func(base, base + i, size);
72 for (r = 0; r * 2 + size < i; r = c) { 73 for (r = 0; r * 2 + size < i; r = c) {
73 c = r * 2 + size; 74 c = r * 2 + size;
74 if (c < i - size && cmp(base + c, base + c + size) < 0) 75 if (c < i - size &&
76 cmp_func(base + c, base + c + size) < 0)
75 c += size; 77 c += size;
76 if (cmp(base + r, base + c) >= 0) 78 if (cmp_func(base + r, base + c) >= 0)
77 break; 79 break;
78 swap(base + r, base + c, size); 80 swap_func(base + r, base + c, size);
79 } 81 }
80 } 82 }
81} 83}