Make HZ_TO_STD macro name lowercase.
[linux-2.6/linux-mips.git] / include / asm-i386 / rwlock.h
blobac9e8f36bd9db88491f6672ee852b07b0d951212
1 /* include/asm-i386/rwlock.h
3 * Helpers used by both rw spinlocks and rw semaphores.
5 * Based in part on code from semaphore.h and
6 * spinlock.h Copyright 1996 Linus Torvalds.
8 * Copyright 1999 Red Hat, Inc.
10 * Written by Benjamin LaHaise.
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
17 #ifndef _ASM_I386_RWLOCK_H
18 #define _ASM_I386_RWLOCK_H
20 typedef struct { unsigned long a[100]; } __dummy_lock_t;
21 #define __dummy_lock(lock) (*(__dummy_lock_t *)(lock))
23 #define RW_LOCK_BIAS 0x01000000
24 #define RW_LOCK_BIAS_STR "0x01000000"
26 #define __build_read_lock_ptr(rw, helper) \
27 asm volatile(LOCK "subl $1,(%0)\n\t" \
28 "js 2f\n" \
29 "1:\n" \
30 ".section .text.lock,\"ax\"\n" \
31 "2:\tcall " helper "\n\t" \
32 "jmp 1b\n" \
33 ".previous" \
34 ::"a" (rw) : "memory")
36 #define __build_read_lock_const(rw, helper) \
37 asm volatile(LOCK "subl $1,%0\n\t" \
38 "js 2f\n" \
39 "1:\n" \
40 ".section .text.lock,\"ax\"\n" \
41 "2:\tpushl %%eax\n\t" \
42 "leal %0,%%eax\n\t" \
43 "call " helper "\n\t" \
44 "popl %%eax\n\t" \
45 "jmp 1b\n" \
46 ".previous" \
47 :"=m" (__dummy_lock(rw)))
49 #define __build_read_lock(rw, helper) do { \
50 if (__builtin_constant_p(rw)) \
51 __build_read_lock_const(rw, helper); \
52 else \
53 __build_read_lock_ptr(rw, helper); \
54 } while (0)
56 #define __build_write_lock_ptr(rw, helper) \
57 asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
58 "jnz 2f\n" \
59 "1:\n" \
60 ".section .text.lock,\"ax\"\n" \
61 "2:\tcall " helper "\n\t" \
62 "jmp 1b\n" \
63 ".previous" \
64 ::"a" (rw) : "memory")
66 #define __build_write_lock_const(rw, helper) \
67 asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
68 "jnz 2f\n" \
69 "1:\n" \
70 ".section .text.lock,\"ax\"\n" \
71 "2:\tpushl %%eax\n\t" \
72 "leal %0,%%eax\n\t" \
73 "call " helper "\n\t" \
74 "popl %%eax\n\t" \
75 "jmp 1b\n" \
76 ".previous" \
77 :"=m" (__dummy_lock(rw)))
79 #define __build_write_lock(rw, helper) do { \
80 if (__builtin_constant_p(rw)) \
81 __build_write_lock_const(rw, helper); \
82 else \
83 __build_write_lock_ptr(rw, helper); \
84 } while (0)
86 #endif