Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / mcas / alpha_defns.h
blob75e07dda8682207e96c2a170234fc0fde3618e71
1 /*
2 Copyright (c) 2003, Keir Fraser All rights reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are
6 met:
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials provided
13 * with the distribution. Neither the name of the Keir Fraser
14 * nor the names of its contributors may be used to endorse or
15 * promote products derived from this software without specific
16 * prior written permission.
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef __ALPHA_DEFNS_H__
32 #define __ALPHA_DEFNS_H__
34 #include <c_asm.h>
35 #include <alpha/builtins.h>
36 #include <pthread.h>
38 #ifndef ALPHA
39 #define ALPHA
40 #endif
42 #define CACHE_LINE_SIZE 64
46 * I. Compare-and-swap, fetch-and-store.
49 #define FAS32(_x,_n) asm ( \
50 "1: ldl_l %v0, 0(%a0);" \
51 " bis %a1, 0, %t0;" \
52 " stl_c %t0, 0(%a0);" \
53 " beq %t0, 1b;", (_x), (_n))
54 #define FAS64(_x,_n) asm ( \
55 "1: ldq_l %v0, 0(%a0);" \
56 " bis %a1, 0, %t0;" \
57 " stq_c %t0, 0(%a0);" \
58 " beq %t0, 1b;", (_x), (_n))
59 #define CAS32(_x,_o,_n) asm ( \
60 "1: ldl_l %v0, 0(%a0);" \
61 " cmpeq %v0, %a1, %t0;" \
62 " beq %t0, 3f;" \
63 " bis %a2, 0, %t0;" \
64 " stl_c %t0, 0(%a0);" \
65 " beq %t0, 1b;" \
66 "3:", (_x), (_o), (_n))
67 #define CAS64(_x,_o,_n) asm ( \
68 "1: ldq_l %v0, 0(%a0);" \
69 " cmpeq %v0, %a1, %t0;" \
70 " beq %t0, 3f;" \
71 " bis %a2, 0, %t0;" \
72 " stq_c %t0, 0(%a0);" \
73 " beq %t0, 1b;" \
74 "3:", (_x), (_o), (_n))
75 #define CAS(_x,_o,_n) ((sizeof (*_x) == 4)?CAS32(_x,_o,_n):CAS64(_x,_o,_n))
76 #define FAS(_x,_n) ((sizeof (*_x) == 4)?FAS32(_x,_n) :FAS64(_x,_n))
77 /* Update Integer location, return Old value. */
78 #define CASIO(_x,_o,_n) CAS(_x,_o,_n)
79 #define FASIO(_x,_n) FAS(_x,_n)
80 /* Update Pointer location, return Old value. */
81 #define CASPO(_x,_o,_n) (void*)CAS((_x),(void*)(_o),(void*)(_n))
82 #define FASPO(_x,_n) (void*)FAS((_x),(void*)(_n))
83 #define CAS32O CAS32
84 #define CAS64O CAS64
87 * II. Memory barriers.
88 * WMB(): All preceding write operations must commit before any later writes.
89 * RMB(): All preceding read operations must commit before any later reads.
90 * MB(): All preceding memory accesses must commit before any later accesses.
92 * If the compiler does not observe these barriers (but any sane compiler
93 * will!), then VOLATILE should be defined as 'volatile'.
96 #define MB() asm("mb")
97 #define WMB() asm("wmb")
98 #define RMB() (MB())
99 #define VOLATILE /*volatile*/
103 * III. Cycle counter access.
106 #include <sys/time.h>
107 typedef unsigned long tick_t;
108 #define RDTICK() asm("rpcc %v0")
112 * IV. Types.
115 typedef unsigned char _u8;
116 typedef unsigned short _u16;
117 typedef unsigned int _u32;
118 typedef unsigned long _u64;
120 #endif /* __ALPHA_DEFNS_H__ */