~ubuntu-branches/ubuntu/quantal/mesa-glw/quantal

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/r200/r200_lock.h

  • Committer: Bazaar Package Importer
  • Author(s): Morten Kjeldgaard
  • Date: 2008-05-06 16:19:15 UTC
  • Revision ID: james.westby@ubuntu.com-20080506161915-uynz7nftmfixu6bq
Tags: upstream-7.0.3
ImportĀ upstreamĀ versionĀ 7.0.3

Show diffs side-by-side

added added

removed removed

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