fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / linux / delay.h
1 #ifndef _LINUX_DELAY_H
2 #define _LINUX_DELAY_H
3
4 /*
5  * Copyright (C) 1993 Linus Torvalds
6  *
7  * Delay routines, using a pre-computed "loops_per_jiffy" value.
8  */
9
10 extern unsigned long loops_per_jiffy;
11
12 #include <asm/delay.h>
13 #include <linux/hardirq.h>
14
15 /*
16  * Using udelay() for intervals greater than a few milliseconds can
17  * risk overflow for high loops_per_jiffy (high bogomips) machines. The
18  * mdelay() provides a wrapper to prevent this.  For delays greater
19  * than MAX_UDELAY_MS milliseconds, the wrapper is used.  Architecture
20  * specific values can be defined in asm-???/delay.h as an override.
21  * The 2nd mdelay() definition ensures GCC will optimize away the 
22  * while loop for the common cases where n <= MAX_UDELAY_MS  --  Paul G.
23  */
24
25 #ifndef MAX_UDELAY_MS
26 #define MAX_UDELAY_MS   5
27 #endif
28
29 #ifndef mdelay
30 #ifdef CONFIG_DEBUG_SLEEP_IN_IRQ
31 #define mdelay(n) (                       \
32 {                                         \
33         static int warned=0;              \
34         unsigned long __ms=(n);           \
35         WARN_ON(in_irq() && !(warned++)); \
36         while (__ms--) udelay(1000);      \
37 })
38 #else
39 #define mdelay(n) (\
40         (__builtin_constant_p(n) && (n)<=MAX_UDELAY_MS) ? udelay((n)*1000) : \
41         ({unsigned long __ms=(n); while (__ms--) udelay(1000);}))
42 #endif
43 #endif
44
45 #ifndef ndelay
46 #define ndelay(x)       udelay(((x)+999)/1000)
47 #endif
48
49 void calibrate_delay(void);
50 void msleep(unsigned int msecs);
51 unsigned long msleep_interruptible(unsigned int msecs);
52
53 static inline void ssleep(unsigned int seconds)
54 {
55         msleep(seconds * 1000);
56 }
57
58 #endif /* defined(_LINUX_DELAY_H) */