Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
/* cairo - a vector graphics library with display and print output
2
 *
3
 * Copyright © 2002 University of Southern California
4
 * Copyright © 2005,2007 Red Hat, Inc.
5
 * Copyright © 2007 Mathias Hasselmann
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it either under the terms of the GNU Lesser General Public
9
 * License version 2.1 as published by the Free Software Foundation
10
 * (the "LGPL") or, at your option, under the terms of the Mozilla
11
 * Public License Version 1.1 (the "MPL"). If you do not alter this
12
 * notice, a recipient may use your version of this file under either
13
 * the MPL or the LGPL.
14
 *
15
 * You should have received a copy of the LGPL along with this library
16
 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
18
 * You should have received a copy of the MPL along with this library
19
 * in the file COPYING-MPL-1.1
20
 *
21
 * The contents of this file are subject to the Mozilla Public License
22
 * Version 1.1 (the "License"); you may not use this file except in
23
 * compliance with the License. You may obtain a copy of the License at
24
 * http://www.mozilla.org/MPL/
25
 *
26
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
27
 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
28
 * the specific language governing rights and limitations.
29
 *
30
 * The Original Code is the cairo graphics library.
31
 *
32
 * The Initial Developer of the Original Code is University of Southern
33
 * California.
34
 *
35
 * Contributor(s):
36
 *	Carl D. Worth 
37
 *	Mathias Hasselmann 
38
 *	Behdad Esfahbod 
39
 */
40
 
41
#ifndef CAIRO_MUTEX_TYPE_PRIVATE_H
42
#define CAIRO_MUTEX_TYPE_PRIVATE_H
43
 
44
#include "cairo-compiler-private.h"
45
#include "cairo-mutex-impl-private.h"
46
 
47
/* Only the following four are mandatory at this point */
48
#ifndef CAIRO_MUTEX_IMPL_LOCK
49
# error "CAIRO_MUTEX_IMPL_LOCK not defined.  Check cairo-mutex-impl-private.h."
50
#endif
51
#ifndef CAIRO_MUTEX_IMPL_UNLOCK
52
# error "CAIRO_MUTEX_IMPL_UNLOCK not defined.  Check cairo-mutex-impl-private.h."
53
#endif
54
#ifndef CAIRO_MUTEX_IMPL_NIL_INITIALIZER
55
# error "CAIRO_MUTEX_IMPL_NIL_INITIALIZER not defined.  Check cairo-mutex-impl-private.h."
56
#endif
57
#ifndef CAIRO_RECURSIVE_MUTEX_IMPL_INIT
58
# error "CAIRO_RECURSIVE_MUTEX_IMPL_INIT not defined.  Check cairo-mutex-impl-private.h."
59
#endif
60
 
61
 
62
/* make sure implementations don't fool us: we decide these ourself */
63
#undef _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER
64
#undef _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER
65
 
66
 
67
#ifdef CAIRO_MUTEX_IMPL_INIT
68
 
69
/* If %CAIRO_MUTEX_IMPL_INIT is defined, we may need to initialize all
70
 * static mutex'es. */
71
# ifndef CAIRO_MUTEX_IMPL_INITIALIZE
72
#  define CAIRO_MUTEX_IMPL_INITIALIZE() do {	\
73
       if (!_cairo_mutex_initialized)	\
74
           _cairo_mutex_initialize ();	\
75
    } while(0)
76
 
77
/* and make sure we implement the above */
78
#  define _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER 1
79
# endif /* CAIRO_MUTEX_IMPL_INITIALIZE */
80
 
81
#else /* no CAIRO_MUTEX_IMPL_INIT */
82
 
83
/* Otherwise we probably don't need to initialize static mutex'es, */
84
# ifndef CAIRO_MUTEX_IMPL_INITIALIZE
85
#  define CAIRO_MUTEX_IMPL_INITIALIZE() CAIRO_MUTEX_IMPL_NOOP
86
# endif /* CAIRO_MUTEX_IMPL_INITIALIZE */
87
 
88
/* and dynamic ones can be initialized using the static initializer. */
89
# define CAIRO_MUTEX_IMPL_INIT(mutex) do {				\
90
      cairo_mutex_t _tmp_mutex = CAIRO_MUTEX_IMPL_NIL_INITIALIZER;	\
91
      memcpy (&(mutex), &_tmp_mutex, sizeof (_tmp_mutex));	\
92
  } while (0)
93
 
94
#endif /* CAIRO_MUTEX_IMPL_INIT */
95
 
96
#ifdef CAIRO_MUTEX_IMPL_FINI
97
 
98
/* If %CAIRO_MUTEX_IMPL_FINI is defined, we may need to finalize all
99
 * static mutex'es. */
100
# ifndef CAIRO_MUTEX_IMPL_FINALIZE
101
#  define CAIRO_MUTEX_IMPL_FINALIZE() do {	\
102
       if (_cairo_mutex_initialized)	\
103
           _cairo_mutex_finalize ();	\
104
    } while(0)
105
 
106
/* and make sure we implement the above */
107
#  define _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER 1
108
# endif /* CAIRO_MUTEX_IMPL_FINALIZE */
109
 
110
#else /* no CAIRO_MUTEX_IMPL_FINI */
111
 
112
/* Otherwise we probably don't need to finalize static mutex'es, */
113
# ifndef CAIRO_MUTEX_IMPL_FINALIZE
114
#  define CAIRO_MUTEX_IMPL_FINALIZE() CAIRO_MUTEX_IMPL_NOOP
115
# endif /* CAIRO_MUTEX_IMPL_FINALIZE */
116
 
117
/* neither do the dynamic ones. */
118
# define CAIRO_MUTEX_IMPL_FINI(mutex)	CAIRO_MUTEX_IMPL_NOOP1(mutex)
119
 
120
#endif /* CAIRO_MUTEX_IMPL_FINI */
121
 
122
 
123
#ifndef _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER
124
#define _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER 0
125
#endif
126
#ifndef _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER
127
#define _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER 0
128
#endif
129
 
130
 
131
/* Make sure everything we want is defined */
132
#ifndef CAIRO_MUTEX_IMPL_INITIALIZE
133
# error "CAIRO_MUTEX_IMPL_INITIALIZE not defined"
134
#endif
135
#ifndef CAIRO_MUTEX_IMPL_FINALIZE
136
# error "CAIRO_MUTEX_IMPL_FINALIZE not defined"
137
#endif
138
#ifndef CAIRO_MUTEX_IMPL_LOCK
139
# error "CAIRO_MUTEX_IMPL_LOCK not defined"
140
#endif
141
#ifndef CAIRO_MUTEX_IMPL_UNLOCK
142
# error "CAIRO_MUTEX_IMPL_UNLOCK not defined"
143
#endif
144
#ifndef CAIRO_MUTEX_IMPL_INIT
145
# error "CAIRO_MUTEX_IMPL_INIT not defined"
146
#endif
147
#ifndef CAIRO_MUTEX_IMPL_FINI
148
# error "CAIRO_MUTEX_IMPL_FINI not defined"
149
#endif
150
#ifndef CAIRO_MUTEX_IMPL_NIL_INITIALIZER
151
# error "CAIRO_MUTEX_IMPL_NIL_INITIALIZER not defined"
152
#endif
153
 
154
 
155
/* Public interface. */
156
 
157
/* By default it simply uses the implementation provided.
158
 * But we can provide for debugging features by overriding them */
159
 
160
#ifndef CAIRO_MUTEX_DEBUG
161
typedef cairo_mutex_impl_t cairo_mutex_t;
162
typedef cairo_recursive_mutex_impl_t cairo_recursive_mutex_t;
163
#else
164
# define cairo_mutex_t			cairo_mutex_impl_t
165
#endif
166
 
167
#define CAIRO_MUTEX_INITIALIZE		CAIRO_MUTEX_IMPL_INITIALIZE
168
#define CAIRO_MUTEX_FINALIZE		CAIRO_MUTEX_IMPL_FINALIZE
169
#define CAIRO_MUTEX_LOCK		CAIRO_MUTEX_IMPL_LOCK
170
#define CAIRO_MUTEX_UNLOCK		CAIRO_MUTEX_IMPL_UNLOCK
171
#define CAIRO_MUTEX_INIT		CAIRO_MUTEX_IMPL_INIT
172
#define CAIRO_MUTEX_FINI		CAIRO_MUTEX_IMPL_FINI
173
#define CAIRO_MUTEX_NIL_INITIALIZER	CAIRO_MUTEX_IMPL_NIL_INITIALIZER
174
 
175
#define CAIRO_RECURSIVE_MUTEX_INIT		CAIRO_RECURSIVE_MUTEX_IMPL_INIT
176
#define CAIRO_RECURSIVE_MUTEX_NIL_INITIALIZER	CAIRO_RECURSIVE_MUTEX_IMPL_NIL_INITIALIZER
177
 
178
#ifndef CAIRO_MUTEX_IS_LOCKED
179
# define CAIRO_MUTEX_IS_LOCKED(name) 1
180
#endif
181
#ifndef CAIRO_MUTEX_IS_UNLOCKED
182
# define CAIRO_MUTEX_IS_UNLOCKED(name) 1
183
#endif
184
 
185
 
186
/* Debugging support */
187
 
188
#ifdef CAIRO_MUTEX_DEBUG
189
 
190
/* TODO add mutex debugging facilities here (eg deadlock detection) */
191
 
192
#endif /* CAIRO_MUTEX_DEBUG */
193
 
194
#endif