remove CVS/XFree86 keywords
[mesa.git] / src / mesa / drivers / dri / r200 / r200_lock.h
1 /*
2 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
3
4 The Weather Channel (TM) funded Tungsten Graphics to develop the
5 initial release of the Radeon 8500 driver under the XFree86 license.
6 This notice must be preserved.
7
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 "Software"), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
15
16 The above copyright notice and this permission notice (including the
17 next paragraph) shall be included in all copies or substantial
18 portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
24 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 **************************************************************************/
29
30 /*
31 * Authors:
32 * Keith Whitwell <keith@tungstengraphics.com>
33 */
34
35 #ifndef __R200_LOCK_H__
36 #define __R200_LOCK_H__
37
38 extern void r200GetLock( r200ContextPtr rmesa, GLuint flags );
39
40 /* Turn DEBUG_LOCKING on to find locking conflicts.
41 */
42 #define DEBUG_LOCKING 0
43
44 #if DEBUG_LOCKING
45 extern char *prevLockFile;
46 extern int prevLockLine;
47
48 #define DEBUG_LOCK() \
49 do { \
50 prevLockFile = (__FILE__); \
51 prevLockLine = (__LINE__); \
52 } while (0)
53
54 #define DEBUG_RESET() \
55 do { \
56 prevLockFile = 0; \
57 prevLockLine = 0; \
58 } while (0)
59
60 #define DEBUG_CHECK_LOCK() \
61 do { \
62 if ( prevLockFile ) { \
63 fprintf( stderr, \
64 "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
65 prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
66 exit( 1 ); \
67 } \
68 } while (0)
69
70 #else
71
72 #define DEBUG_LOCK()
73 #define DEBUG_RESET()
74 #define DEBUG_CHECK_LOCK()
75
76 #endif
77
78 /*
79 * !!! We may want to separate locks from locks with validation. This
80 * could be used to improve performance for those things commands that
81 * do not do any drawing !!!
82 */
83
84
85 /* Lock the hardware and validate our state.
86 */
87 #define LOCK_HARDWARE( rmesa ) \
88 do { \
89 char __ret = 0; \
90 DEBUG_CHECK_LOCK(); \
91 DRM_CAS( rmesa->dri.hwLock, rmesa->dri.hwContext, \
92 (DRM_LOCK_HELD | rmesa->dri.hwContext), __ret ); \
93 if ( __ret ) \
94 r200GetLock( rmesa, 0 ); \
95 DEBUG_LOCK(); \
96 } while (0)
97
98 #define UNLOCK_HARDWARE( rmesa ) \
99 do { \
100 DRM_UNLOCK( rmesa->dri.fd, \
101 rmesa->dri.hwLock, \
102 rmesa->dri.hwContext ); \
103 DEBUG_RESET(); \
104 } while (0)
105
106 #endif /* __R200_LOCK_H__ */