diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Kconfig | 6 | ||||
-rw-r--r-- | lib/Kconfig.debug | 30 | ||||
-rw-r--r-- | lib/Makefile | 1 | ||||
-rw-r--r-- | lib/idr.c | 43 | ||||
-rw-r--r-- | lib/kernel_lock.c | 4 | ||||
-rw-r--r-- | lib/plist.c | 118 | ||||
-rw-r--r-- | lib/zlib_inflate/inffast.c | 6 | ||||
-rw-r--r-- | lib/zlib_inflate/inftrees.c | 18 |
8 files changed, 203 insertions, 23 deletions
diff --git a/lib/Kconfig b/lib/Kconfig index 3de93357f5..f6299342b8 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
@@ -86,4 +86,10 @@ config TEXTSEARCH_BM | |||
86 | config TEXTSEARCH_FSM | 86 | config TEXTSEARCH_FSM |
87 | tristate | 87 | tristate |
88 | 88 | ||
89 | # | ||
90 | # plist support is select#ed if needed | ||
91 | # | ||
92 | config PLIST | ||
93 | boolean | ||
94 | |||
89 | endmenu | 95 | endmenu |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index ccb0c1fdf1..5330911ebd 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -107,6 +107,24 @@ config DEBUG_MUTEXES | |||
107 | This allows mutex semantics violations and mutex related deadlocks | 107 | This allows mutex semantics violations and mutex related deadlocks |
108 | (lockups) to be detected and reported automatically. | 108 | (lockups) to be detected and reported automatically. |
109 | 109 | ||
110 | config DEBUG_RT_MUTEXES | ||
111 | bool "RT Mutex debugging, deadlock detection" | ||
112 | depends on DEBUG_KERNEL && RT_MUTEXES | ||
113 | help | ||
114 | This allows rt mutex semantics violations and rt mutex related | ||
115 | deadlocks (lockups) to be detected and reported automatically. | ||
116 | |||
117 | config DEBUG_PI_LIST | ||
118 | bool | ||
119 | default y | ||
120 | depends on DEBUG_RT_MUTEXES | ||
121 | |||
122 | config RT_MUTEX_TESTER | ||
123 | bool "Built-in scriptable tester for rt-mutexes" | ||
124 | depends on DEBUG_KERNEL && RT_MUTEXES | ||
125 | help | ||
126 | This option enables a rt-mutex tester. | ||
127 | |||
110 | config DEBUG_SPINLOCK | 128 | config DEBUG_SPINLOCK |
111 | bool "Spinlock debugging" | 129 | bool "Spinlock debugging" |
112 | depends on DEBUG_KERNEL | 130 | depends on DEBUG_KERNEL |
@@ -188,14 +206,22 @@ config FRAME_POINTER | |||
188 | 206 | ||
189 | config UNWIND_INFO | 207 | config UNWIND_INFO |
190 | bool "Compile the kernel with frame unwind information" | 208 | bool "Compile the kernel with frame unwind information" |
191 | depends on !IA64 | 209 | depends on !IA64 && !PARISC |
192 | depends on !MODULES || !(MIPS || PARISC || PPC || SUPERH || V850) | 210 | depends on !MODULES || !(MIPS || PPC || SUPERH || V850) |
193 | help | 211 | help |
194 | If you say Y here the resulting kernel image will be slightly larger | 212 | If you say Y here the resulting kernel image will be slightly larger |
195 | but not slower, and it will give very useful debugging information. | 213 | but not slower, and it will give very useful debugging information. |
196 | If you don't debug the kernel, you can say N, but we may not be able | 214 | If you don't debug the kernel, you can say N, but we may not be able |
197 | to solve problems without frame unwind information or frame pointers. | 215 | to solve problems without frame unwind information or frame pointers. |
198 | 216 | ||
217 | config STACK_UNWIND | ||
218 | bool "Stack unwind support" | ||
219 | depends on UNWIND_INFO | ||
220 | depends on X86 | ||
221 | help | ||
222 | This enables more precise stack traces, omitting all unrelated | ||
223 | occurrences of pointers into kernel code from the dump. | ||
224 | |||
199 | config FORCED_INLINING | 225 | config FORCED_INLINING |
200 | bool "Force gcc to inline functions marked 'inline'" | 226 | bool "Force gcc to inline functions marked 'inline'" |
201 | depends on DEBUG_KERNEL | 227 | depends on DEBUG_KERNEL |
diff --git a/lib/Makefile b/lib/Makefile index 79358ad1f1..10c13c9d78 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -25,6 +25,7 @@ lib-$(CONFIG_SEMAPHORE_SLEEPERS) += semaphore-sleepers.o | |||
25 | lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o | 25 | lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o |
26 | lib-$(CONFIG_GENERIC_HWEIGHT) += hweight.o | 26 | lib-$(CONFIG_GENERIC_HWEIGHT) += hweight.o |
27 | obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o | 27 | obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o |
28 | obj-$(CONFIG_PLIST) += plist.o | ||
28 | obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o | 29 | obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o |
29 | 30 | ||
30 | ifneq ($(CONFIG_HAVE_DEC_LOCK),y) | 31 | ifneq ($(CONFIG_HAVE_DEC_LOCK),y) |
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #endif | 31 | #endif |
32 | #include <linux/err.h> | ||
32 | #include <linux/string.h> | 33 | #include <linux/string.h> |
33 | #include <linux/idr.h> | 34 | #include <linux/idr.h> |
34 | 35 | ||
@@ -398,6 +399,48 @@ void *idr_find(struct idr *idp, int id) | |||
398 | } | 399 | } |
399 | EXPORT_SYMBOL(idr_find); | 400 | EXPORT_SYMBOL(idr_find); |
400 | 401 | ||
402 | /** | ||
403 | * idr_replace - replace pointer for given id | ||
404 | * @idp: idr handle | ||
405 | * @ptr: pointer you want associated with the id | ||
406 | * @id: lookup key | ||
407 | * | ||
408 | * Replace the pointer registered with an id and return the old value. | ||
409 | * A -ENOENT return indicates that @id was not found. | ||
410 | * A -EINVAL return indicates that @id was not within valid constraints. | ||
411 | * | ||
412 | * The caller must serialize vs idr_find(), idr_get_new(), and idr_remove(). | ||
413 | */ | ||
414 | void *idr_replace(struct idr *idp, void *ptr, int id) | ||
415 | { | ||
416 | int n; | ||
417 | struct idr_layer *p, *old_p; | ||
418 | |||
419 | n = idp->layers * IDR_BITS; | ||
420 | p = idp->top; | ||
421 | |||
422 | id &= MAX_ID_MASK; | ||
423 | |||
424 | if (id >= (1 << n)) | ||
425 | return ERR_PTR(-EINVAL); | ||
426 | |||
427 | n -= IDR_BITS; | ||
428 | while ((n > 0) && p) { | ||
429 | p = p->ary[(id >> n) & IDR_MASK]; | ||
430 | n -= IDR_BITS; | ||
431 | } | ||
432 | |||
433 | n = id & IDR_MASK; | ||
434 | if (unlikely(p == NULL || !test_bit(n, &p->bitmap))) | ||
435 | return ERR_PTR(-ENOENT); | ||
436 | |||
437 | old_p = p->ary[n]; | ||
438 | p->ary[n] = ptr; | ||
439 | |||
440 | return old_p; | ||
441 | } | ||
442 | EXPORT_SYMBOL(idr_replace); | ||
443 | |||
401 | static void idr_cache_ctor(void * idr_layer, kmem_cache_t *idr_layer_cache, | 444 | static void idr_cache_ctor(void * idr_layer, kmem_cache_t *idr_layer_cache, |
402 | unsigned long flags) | 445 | unsigned long flags) |
403 | { | 446 | { |
diff --git a/lib/kernel_lock.c b/lib/kernel_lock.c index cb5490ec00..e713e86811 100644 --- a/lib/kernel_lock.c +++ b/lib/kernel_lock.c | |||
@@ -14,7 +14,7 @@ | |||
14 | * The 'big kernel semaphore' | 14 | * The 'big kernel semaphore' |
15 | * | 15 | * |
16 | * This mutex is taken and released recursively by lock_kernel() | 16 | * This mutex is taken and released recursively by lock_kernel() |
17 | * and unlock_kernel(). It is transparently dropped and reaquired | 17 | * and unlock_kernel(). It is transparently dropped and reacquired |
18 | * over schedule(). It is used to protect legacy code that hasn't | 18 | * over schedule(). It is used to protect legacy code that hasn't |
19 | * been migrated to a proper locking design yet. | 19 | * been migrated to a proper locking design yet. |
20 | * | 20 | * |
@@ -92,7 +92,7 @@ void __lockfunc unlock_kernel(void) | |||
92 | * The 'big kernel lock' | 92 | * The 'big kernel lock' |
93 | * | 93 | * |
94 | * This spinlock is taken and released recursively by lock_kernel() | 94 | * This spinlock is taken and released recursively by lock_kernel() |
95 | * and unlock_kernel(). It is transparently dropped and reaquired | 95 | * and unlock_kernel(). It is transparently dropped and reacquired |
96 | * over schedule(). It is used to protect legacy code that hasn't | 96 | * over schedule(). It is used to protect legacy code that hasn't |
97 | * been migrated to a proper locking design yet. | 97 | * been migrated to a proper locking design yet. |
98 | * | 98 | * |
diff --git a/lib/plist.c b/lib/plist.c new file mode 100644 index 0000000000..3074a02272 --- /dev/null +++ b/lib/plist.c | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | * lib/plist.c | ||
3 | * | ||
4 | * Descending-priority-sorted double-linked list | ||
5 | * | ||
6 | * (C) 2002-2003 Intel Corp | ||
7 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>. | ||
8 | * | ||
9 | * 2001-2005 (c) MontaVista Software, Inc. | ||
10 | * Daniel Walker <dwalker@mvista.com> | ||
11 | * | ||
12 | * (C) 2005 Thomas Gleixner <tglx@linutronix.de> | ||
13 | * | ||
14 | * Simplifications of the original code by | ||
15 | * Oleg Nesterov <oleg@tv-sign.ru> | ||
16 | * | ||
17 | * Licensed under the FSF's GNU Public License v2 or later. | ||
18 | * | ||
19 | * Based on simple lists (include/linux/list.h). | ||
20 | * | ||
21 | * This file contains the add / del functions which are considered to | ||
22 | * be too large to inline. See include/linux/plist.h for further | ||
23 | * information. | ||
24 | */ | ||
25 | |||
26 | #include <linux/plist.h> | ||
27 | #include <linux/spinlock.h> | ||
28 | |||
29 | #ifdef CONFIG_DEBUG_PI_LIST | ||
30 | |||
31 | static void plist_check_prev_next(struct list_head *t, struct list_head *p, | ||
32 | struct list_head *n) | ||
33 | { | ||
34 | if (n->prev != p || p->next != n) { | ||
35 | printk("top: %p, n: %p, p: %p\n", t, t->next, t->prev); | ||
36 | printk("prev: %p, n: %p, p: %p\n", p, p->next, p->prev); | ||
37 | printk("next: %p, n: %p, p: %p\n", n, n->next, n->prev); | ||
38 | WARN_ON(1); | ||
39 | } | ||
40 | } | ||
41 | |||
42 | static void plist_check_list(struct list_head *top) | ||
43 | { | ||
44 | struct list_head *prev = top, *next = top->next; | ||
45 | |||
46 | plist_check_prev_next(top, prev, next); | ||
47 | while (next != top) { | ||
48 | prev = next; | ||
49 | next = prev->next; | ||
50 | plist_check_prev_next(top, prev, next); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | static void plist_check_head(struct plist_head *head) | ||
55 | { | ||
56 | WARN_ON(!head->lock); | ||
57 | if (head->lock) | ||
58 | WARN_ON_SMP(!spin_is_locked(head->lock)); | ||
59 | plist_check_list(&head->prio_list); | ||
60 | plist_check_list(&head->node_list); | ||
61 | } | ||
62 | |||
63 | #else | ||
64 | # define plist_check_head(h) do { } while (0) | ||
65 | #endif | ||
66 | |||
67 | /** | ||
68 | * plist_add - add @node to @head | ||
69 | * | ||
70 | * @node: &struct plist_node pointer | ||
71 | * @head: &struct plist_head pointer | ||
72 | */ | ||
73 | void plist_add(struct plist_node *node, struct plist_head *head) | ||
74 | { | ||
75 | struct plist_node *iter; | ||
76 | |||
77 | plist_check_head(head); | ||
78 | WARN_ON(!plist_node_empty(node)); | ||
79 | |||
80 | list_for_each_entry(iter, &head->prio_list, plist.prio_list) { | ||
81 | if (node->prio < iter->prio) | ||
82 | goto lt_prio; | ||
83 | else if (node->prio == iter->prio) { | ||
84 | iter = list_entry(iter->plist.prio_list.next, | ||
85 | struct plist_node, plist.prio_list); | ||
86 | goto eq_prio; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | lt_prio: | ||
91 | list_add_tail(&node->plist.prio_list, &iter->plist.prio_list); | ||
92 | eq_prio: | ||
93 | list_add_tail(&node->plist.node_list, &iter->plist.node_list); | ||
94 | |||
95 | plist_check_head(head); | ||
96 | } | ||
97 | |||
98 | /** | ||
99 | * plist_del - Remove a @node from plist. | ||
100 | * | ||
101 | * @node: &struct plist_node pointer - entry to be removed | ||
102 | * @head: &struct plist_head pointer - list head | ||
103 | */ | ||
104 | void plist_del(struct plist_node *node, struct plist_head *head) | ||
105 | { | ||
106 | plist_check_head(head); | ||
107 | |||
108 | if (!list_empty(&node->plist.prio_list)) { | ||
109 | struct plist_node *next = plist_first(&node->plist); | ||
110 | |||
111 | list_move_tail(&next->plist.prio_list, &node->plist.prio_list); | ||
112 | list_del_init(&node->plist.prio_list); | ||
113 | } | ||
114 | |||
115 | list_del_init(&node->plist.node_list); | ||
116 | |||
117 | plist_check_head(head); | ||
118 | } | ||
diff --git a/lib/zlib_inflate/inffast.c b/lib/zlib_inflate/inffast.c index 02a16eacb7..d84560c076 100644 --- a/lib/zlib_inflate/inffast.c +++ b/lib/zlib_inflate/inffast.c | |||
@@ -63,10 +63,10 @@ | |||
63 | bytes, which is the maximum length that can be coded. inflate_fast() | 63 | bytes, which is the maximum length that can be coded. inflate_fast() |
64 | requires strm->avail_out >= 258 for each loop to avoid checking for | 64 | requires strm->avail_out >= 258 for each loop to avoid checking for |
65 | output space. | 65 | output space. |
66 | |||
67 | - @start: inflate()'s starting value for strm->avail_out | ||
66 | */ | 68 | */ |
67 | void inflate_fast(strm, start) | 69 | void inflate_fast(z_streamp strm, unsigned start) |
68 | z_streamp strm; | ||
69 | unsigned start; /* inflate()'s starting value for strm->avail_out */ | ||
70 | { | 70 | { |
71 | struct inflate_state *state; | 71 | struct inflate_state *state; |
72 | unsigned char *in; /* local strm->next_in */ | 72 | unsigned char *in; /* local strm->next_in */ |
diff --git a/lib/zlib_inflate/inftrees.c b/lib/zlib_inflate/inftrees.c index 62343c53bf..3fe6ce5b53 100644 --- a/lib/zlib_inflate/inftrees.c +++ b/lib/zlib_inflate/inftrees.c | |||
@@ -8,15 +8,6 @@ | |||
8 | 8 | ||
9 | #define MAXBITS 15 | 9 | #define MAXBITS 15 |
10 | 10 | ||
11 | const char inflate_copyright[] = | ||
12 | " inflate 1.2.3 Copyright 1995-2005 Mark Adler "; | ||
13 | /* | ||
14 | If you use the zlib library in a product, an acknowledgment is welcome | ||
15 | in the documentation of your product. If for some reason you cannot | ||
16 | include such an acknowledgment, I would appreciate that you keep this | ||
17 | copyright string in the executable of your product. | ||
18 | */ | ||
19 | |||
20 | /* | 11 | /* |
21 | Build a set of tables to decode the provided canonical Huffman code. | 12 | Build a set of tables to decode the provided canonical Huffman code. |
22 | The code lengths are lens[0..codes-1]. The result starts at *table, | 13 | The code lengths are lens[0..codes-1]. The result starts at *table, |
@@ -29,13 +20,8 @@ const char inflate_copyright[] = | |||
29 | table index bits. It will differ if the request is greater than the | 20 | table index bits. It will differ if the request is greater than the |
30 | longest code or if it is less than the shortest code. | 21 | longest code or if it is less than the shortest code. |
31 | */ | 22 | */ |
32 | int zlib_inflate_table(type, lens, codes, table, bits, work) | 23 | int zlib_inflate_table(codetype type, unsigned short *lens, unsigned codes, |
33 | codetype type; | 24 | code **table, unsigned *bits, unsigned short *work) |
34 | unsigned short *lens; | ||
35 | unsigned codes; | ||
36 | code **table; | ||
37 | unsigned *bits; | ||
38 | unsigned short *work; | ||
39 | { | 25 | { |
40 | unsigned len; /* a code's length in bits */ | 26 | unsigned len; /* a code's length in bits */ |
41 | unsigned sym; /* index of code symbols */ | 27 | unsigned sym; /* index of code symbols */ |