ia64/xen-unstable

view unmodified_drivers/linux-2.6/platform-pci/platform-compat.c @ 14100:e47738923a05

[LINUX] Purge include <linux/config.h>. It has been obsolete for some time now.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Fri Feb 23 16:56:45 2007 +0000 (2007-02-23)
parents df25547d7638
children 6e7ef794cdbc
line source
1 #include <linux/version.h>
3 #include <linux/mm.h>
4 #include <linux/module.h>
5 #include <linux/sched.h>
6 #include <linux/slab.h>
8 #include <xen/platform-compat.h>
10 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)
11 static int system_state = 1;
12 EXPORT_SYMBOL(system_state);
13 #endif
15 static inline void ctrl_alt_del(void)
16 {
17 kill_proc(1, SIGINT, 1); /* interrupt init */
18 }
19 EXPORT_SYMBOL(ctrl_alt_del);
21 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
22 size_t strcspn(const char *s, const char *reject)
23 {
24 const char *p;
25 const char *r;
26 size_t count = 0;
28 for (p = s; *p != '\0'; ++p) {
29 for (r = reject; *r != '\0'; ++r) {
30 if (*p == *r)
31 return count;
32 }
33 ++count;
34 }
36 return count;
37 }
38 EXPORT_SYMBOL(strcspn);
39 #endif
41 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
42 /*
43 * Map a vmalloc()-space virtual address to the physical page frame number.
44 */
45 unsigned long vmalloc_to_pfn(void * vmalloc_addr)
46 {
47 return page_to_pfn(vmalloc_to_page(vmalloc_addr));
48 }
49 EXPORT_SYMBOL(vmalloc_to_pfn);
50 #endif
52 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
53 unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout)
54 {
55 might_sleep();
57 spin_lock_irq(&x->wait.lock);
58 if (!x->done) {
59 DECLARE_WAITQUEUE(wait, current);
61 wait.flags |= WQ_FLAG_EXCLUSIVE;
62 __add_wait_queue_tail(&x->wait, &wait);
63 do {
64 __set_current_state(TASK_UNINTERRUPTIBLE);
65 spin_unlock_irq(&x->wait.lock);
66 timeout = schedule_timeout(timeout);
67 spin_lock_irq(&x->wait.lock);
68 if (!timeout) {
69 __remove_wait_queue(&x->wait, &wait);
70 goto out;
71 }
72 } while (!x->done);
73 __remove_wait_queue(&x->wait, &wait);
74 }
75 x->done--;
76 out:
77 spin_unlock_irq(&x->wait.lock);
78 return timeout;
79 }
80 EXPORT_SYMBOL(wait_for_completion_timeout);
81 #endif
83 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
84 /*
85 fake do_exit using complete_and_exit
86 */
87 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
88 asmlinkage NORET_TYPE void do_exit(long code)
89 #else
90 fastcall NORET_TYPE void do_exit(long code)
91 #endif
92 {
93 complete_and_exit(NULL, code);
94 }
95 EXPORT_SYMBOL_GPL(do_exit);
96 #endif
98 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
99 signed long schedule_timeout_interruptible(signed long timeout)
100 {
101 __set_current_state(TASK_INTERRUPTIBLE);
102 return schedule_timeout(timeout);
103 }
104 EXPORT_SYMBOL(schedule_timeout_interruptible);
105 #endif
107 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
108 /**
109 * kzalloc - allocate memory. The memory is set to zero.
110 * @size: how many bytes of memory are required.
111 * @flags: the type of memory to allocate.
112 */
113 void *kzalloc(size_t size, int flags)
114 {
115 void *ret = kmalloc(size, flags);
116 if (ret)
117 memset(ret, 0, size);
118 return ret;
119 }
120 EXPORT_SYMBOL(kzalloc);
121 #endif
123 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
124 /* Simplified asprintf. */
125 char *kasprintf(gfp_t gfp, const char *fmt, ...)
126 {
127 va_list ap;
128 unsigned int len;
129 char *p, dummy[1];
131 va_start(ap, fmt);
132 len = vsnprintf(dummy, 0, fmt, ap);
133 va_end(ap);
135 p = kmalloc(len + 1, gfp);
136 if (!p)
137 return NULL;
138 va_start(ap, fmt);
139 vsprintf(p, fmt, ap);
140 va_end(ap);
141 return p;
142 }
143 EXPORT_SYMBOL(kasprintf);
144 #endif