Subversion Repositories Kolibri OS

Rev

Rev 5270 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5270 serge 1
#ifndef __ASM_GENERIC_DELAY_H
2
#define __ASM_GENERIC_DELAY_H
3
 
4
/* Undefined functions to get compile-time errors */
5
extern void __bad_udelay(void);
6
extern void __bad_ndelay(void);
7
 
8
extern void __udelay(unsigned long usecs);
9
extern void __ndelay(unsigned long nsecs);
10
extern void __const_udelay(unsigned long xloops);
11
extern void __delay(unsigned long loops);
12
 
13
/*
14
 * The weird n/20000 thing suppresses a "comparison is always false due to
15
 * limited range of data type" warning with non-const 8-bit arguments.
16
 */
17
 
18
/* 0x10c7 is 2**32 / 1000000 (rounded up) */
19
#define udelay(n)							\
20
	({								\
21
		if (__builtin_constant_p(n)) {				\
22
				__const_udelay((n) * 0x10c7ul);		\
23
		} else {						\
24
			__udelay(n);					\
25
		}							\
26
	})
27
 
28
/* 0x5 is 2**32 / 1000000000 (rounded up) */
29
#define ndelay(n)							\
30
	({								\
31
		if (__builtin_constant_p(n)) {				\
32
			if ((n) / 20000 >= 1)				\
33
				__bad_ndelay();				\
34
			else						\
35
				__const_udelay((n) * 5ul);		\
36
		} else {						\
37
			__ndelay(n);					\
38
		}							\
39
	})
40
 
41
#endif /* __ASM_GENERIC_DELAY_H */