ia64/xen-unstable

view linux-2.4.30-xen-sparse/arch/xen/lib/delay.c @ 5527:a787d0c6f797

bitkeeper revision 1.1713.2.14 (42b83897l9yCwRifZXvfuWUtymljvA)

Fix typo in cmpxchg_user (causes compile error in some compilers)
author djm@kirby.fc.hp.com
date Tue Jun 21 15:56:07 2005 +0000 (2005-06-21)
parents 85fcf3b1b7a5
children 56a63f9f378f
line source
1 /*
2 * Precise Delay Loops for i386
3 *
4 * Copyright (C) 1993 Linus Torvalds
5 * Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6 *
7 * The __delay function must _NOT_ be inlined as its execution time
8 * depends wildly on alignment on many x86 processors. The additional
9 * jump magic is needed to get the timing stable on all the CPU's
10 * we have to worry about.
11 */
13 #include <linux/config.h>
14 #include <linux/sched.h>
15 #include <linux/delay.h>
16 #include <asm/processor.h>
17 #include <asm/delay.h>
19 #ifdef CONFIG_SMP
20 #include <asm/smp.h>
21 #endif
23 void __delay(unsigned long loops)
24 {
25 unsigned long bclock, now;
27 rdtscl(bclock);
28 do
29 {
30 rep_nop();
31 rdtscl(now);
32 } while ((now-bclock) < loops);
33 }
35 inline void __const_udelay(unsigned long xloops)
36 {
37 int d0;
38 __asm__("mull %0"
39 :"=d" (xloops), "=&a" (d0)
40 :"1" (xloops),"0" (current_cpu_data.loops_per_jiffy));
41 __delay(xloops * HZ);
42 }
44 void __udelay(unsigned long usecs)
45 {
46 __const_udelay(usecs * 0x000010c6); /* 2**32 / 1000000 */
47 }
49 void __ndelay(unsigned long nsecs)
50 {
51 __const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
52 }