~ubuntu-branches/ubuntu/saucy/nspr/saucy-updates

« back to all changes in this revision

Viewing changes to .pc/38_hurd.patch/mozilla/nsprpub/pr/include/md/_pth.h

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-11-27 17:39:22 UTC
  • mfrom: (1.1.15) (27.1.1 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20121127173922-1zfbtwmy1vczqwxq
Tags: 2:4.9.3-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - rules: Enable Thumb2 build on armel, armhf.
  - control: Change Vcs-* to XS-Debian-Vcs-*.
  - control: Add conflicts to evolution-documentation-*,
    language-support-translation-*.
  - control: Add Breaks: evolution-plugins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
 
/* ***** BEGIN LICENSE BLOCK *****
3
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 
 *
5
 
 * The contents of this file are subject to the Mozilla Public License Version
6
 
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 
 * the License. You may obtain a copy of the License at
8
 
 * http://www.mozilla.org/MPL/
9
 
 *
10
 
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 
 * for the specific language governing rights and limitations under the
13
 
 * License.
14
 
 *
15
 
 * The Original Code is the Netscape Portable Runtime (NSPR).
16
 
 *
17
 
 * The Initial Developer of the Original Code is
18
 
 * Netscape Communications Corporation.
19
 
 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20
 
 * the Initial Developer. All Rights Reserved.
21
 
 *
22
 
 * Contributor(s):
23
 
 *
24
 
 * Alternatively, the contents of this file may be used under the terms of
25
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
26
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
28
 
 * of those above. If you wish to allow use of your version of this file only
29
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
30
 
 * use your version of this file under the terms of the MPL, indicate your
31
 
 * decision by deleting the provisions above and replace them with the notice
32
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
33
 
 * the provisions above, a recipient may use your version of this file under
34
 
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 
 *
36
 
 * ***** END LICENSE BLOCK ***** */
37
 
 
38
 
#ifndef nspr_pth_defs_h_
39
 
#define nspr_pth_defs_h_
40
 
 
41
 
/*
42
 
** Appropriate definitions of entry points not used in a pthreads world
43
 
*/
44
 
#define _PR_MD_BLOCK_CLOCK_INTERRUPTS()
45
 
#define _PR_MD_UNBLOCK_CLOCK_INTERRUPTS()
46
 
#define _PR_MD_DISABLE_CLOCK_INTERRUPTS()
47
 
#define _PR_MD_ENABLE_CLOCK_INTERRUPTS()
48
 
 
49
 
/* In good standards fashion, the DCE threads (based on posix-4) are not
50
 
 * quite the same as newer posix implementations.  These are mostly name
51
 
 * changes and small differences, so macros usually do the trick
52
 
 */
53
 
#ifdef _PR_DCETHREADS
54
 
#define _PT_PTHREAD_MUTEXATTR_INIT        pthread_mutexattr_create
55
 
#define _PT_PTHREAD_MUTEXATTR_DESTROY     pthread_mutexattr_delete
56
 
#define _PT_PTHREAD_MUTEX_INIT(m, a)      pthread_mutex_init(&(m), a)
57
 
#define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    (0 == pthread_mutex_trylock(&(m)))
58
 
#define _PT_PTHREAD_CONDATTR_INIT         pthread_condattr_create
59
 
#define _PT_PTHREAD_COND_INIT(m, a)       pthread_cond_init(&(m), a)
60
 
#define _PT_PTHREAD_CONDATTR_DESTROY      pthread_condattr_delete
61
 
 
62
 
/* Notes about differences between DCE threads and pthreads 10:
63
 
 *   1. pthread_mutex_trylock returns 1 when it locks the mutex
64
 
 *      0 when it does not.  The latest pthreads has a set of errno-like
65
 
 *      return values.
66
 
 *   2. return values from pthread_cond_timedwait are different.
67
 
 *
68
 
 *
69
 
 *
70
 
 */
71
 
#elif defined(BSDI)
72
 
/*
73
 
 * Mutex and condition attributes are not supported.  The attr
74
 
 * argument to pthread_mutex_init() and pthread_cond_init() must
75
 
 * be passed as NULL.
76
 
 *
77
 
 * The memset calls in _PT_PTHREAD_MUTEX_INIT and _PT_PTHREAD_COND_INIT
78
 
 * are to work around BSDI's using a single bit to indicate a mutex
79
 
 * or condition variable is initialized.  This entire BSDI section
80
 
 * will go away when BSDI releases updated threads libraries for
81
 
 * BSD/OS 3.1 and 4.0.
82
 
 */
83
 
#define _PT_PTHREAD_MUTEXATTR_INIT(x)     0
84
 
#define _PT_PTHREAD_MUTEXATTR_DESTROY(x)  /* */
85
 
#define _PT_PTHREAD_MUTEX_INIT(m, a)      (memset(&(m), 0, sizeof(m)), \
86
 
                                      pthread_mutex_init(&(m), NULL))
87
 
#define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    (EBUSY == pthread_mutex_trylock(&(m)))
88
 
#define _PT_PTHREAD_CONDATTR_INIT(x)      0
89
 
#define _PT_PTHREAD_CONDATTR_DESTROY(x)   /* */
90
 
#define _PT_PTHREAD_COND_INIT(m, a)       (memset(&(m), 0, sizeof(m)), \
91
 
                                      pthread_cond_init(&(m), NULL))
92
 
#else
93
 
#define _PT_PTHREAD_MUTEXATTR_INIT        pthread_mutexattr_init
94
 
#define _PT_PTHREAD_MUTEXATTR_DESTROY     pthread_mutexattr_destroy
95
 
#define _PT_PTHREAD_MUTEX_INIT(m, a)      pthread_mutex_init(&(m), &(a))
96
 
#if defined(FREEBSD)
97
 
#define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    pt_pthread_mutex_is_locked(&(m))
98
 
#else
99
 
#define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    (EBUSY == pthread_mutex_trylock(&(m)))
100
 
#endif
101
 
#if defined(ANDROID)
102
 
/* Conditional attribute init and destroy aren't implemented in bionic. */
103
 
#define _PT_PTHREAD_CONDATTR_INIT(x)      0
104
 
#define _PT_PTHREAD_CONDATTR_DESTROY(x)   /* */
105
 
#else
106
 
#define _PT_PTHREAD_CONDATTR_INIT         pthread_condattr_init
107
 
#define _PT_PTHREAD_CONDATTR_DESTROY      pthread_condattr_destroy
108
 
#endif
109
 
#define _PT_PTHREAD_COND_INIT(m, a)       pthread_cond_init(&(m), &(a))
110
 
#endif
111
 
 
112
 
/* The pthreads standard does not specify an invalid value for the
113
 
 * pthread_t handle.  (0 is usually an invalid pthread identifier
114
 
 * but there are exceptions, for example, DG/UX.)  These macros
115
 
 * define a way to set the handle to or compare the handle with an
116
 
 * invalid identifier.  These macros are not portable and may be
117
 
 * more of a problem as we adapt to more pthreads implementations.
118
 
 * They are only used in the PRMonitor functions.  Do not use them
119
 
 * in new code.
120
 
 *
121
 
 * Unfortunately some of our clients depend on certain properties
122
 
 * of our PRMonitor implementation, preventing us from replacing
123
 
 * it by a portable implementation.
124
 
 * - High-performance servers like the fact that PR_EnterMonitor
125
 
 *   only calls PR_Lock and PR_ExitMonitor only calls PR_Unlock.
126
 
 *   (A portable implementation would use a PRLock and a PRCondVar
127
 
 *   to implement the recursive lock in a monitor and call both
128
 
 *   PR_Lock and PR_Unlock in PR_EnterMonitor and PR_ExitMonitor.)
129
 
 *   Unfortunately this forces us to read the monitor owner field
130
 
 *   without holding a lock.
131
 
 * - One way to make it safe to read the monitor owner field
132
 
 *   without holding a lock is to make that field a PRThread*
133
 
 *   (one should be able to read a pointer with a single machine
134
 
 *   instruction).  However, PR_GetCurrentThread calls calloc if
135
 
 *   it is called by a thread that was not created by NSPR.  The
136
 
 *   malloc tracing tools in the Mozilla client use PRMonitor for
137
 
 *   locking in their malloc, calloc, and free functions.  If
138
 
 *   PR_EnterMonitor calls any of these functions, infinite
139
 
 *   recursion ensues.
140
 
 */
141
 
#if defined(_PR_DCETHREADS)
142
 
#define _PT_PTHREAD_INVALIDATE_THR_HANDLE(t) \
143
 
        memset(&(t), 0, sizeof(pthread_t))
144
 
#define _PT_PTHREAD_THR_HANDLE_IS_INVALID(t) \
145
 
        (!memcmp(&(t), &pt_zero_tid, sizeof(pthread_t)))
146
 
#define _PT_PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)
147
 
#elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(SOLARIS) \
148
 
        || defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
149
 
        || defined(HPUX) || defined(FREEBSD) \
150
 
        || defined(NETBSD) || defined(OPENBSD) || defined(BSDI) \
151
 
        || defined(NTO) || defined(DARWIN) \
152
 
        || defined(UNIXWARE) || defined(RISCOS) || defined(SYMBIAN)
153
 
#ifdef __GNU__
154
 
/* Hurd pthreads don't have an invalid value for pthread_t. -- rmh */
155
 
#error Using Hurd pthreads
156
 
#endif
157
 
#define _PT_PTHREAD_INVALIDATE_THR_HANDLE(t)  (t) = 0
158
 
#define _PT_PTHREAD_THR_HANDLE_IS_INVALID(t)  (t) == 0
159
 
#define _PT_PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)
160
 
#else 
161
 
#error "pthreads is not supported for this architecture"
162
 
#endif
163
 
 
164
 
#if defined(_PR_DCETHREADS)
165
 
#define _PT_PTHREAD_ATTR_INIT            pthread_attr_create
166
 
#define _PT_PTHREAD_ATTR_DESTROY         pthread_attr_delete
167
 
#define _PT_PTHREAD_CREATE(t, a, f, r)   pthread_create(t, a, f, r) 
168
 
#define _PT_PTHREAD_KEY_CREATE           pthread_keycreate
169
 
#define _PT_PTHREAD_ATTR_SETSCHEDPOLICY  pthread_attr_setsched
170
 
#define _PT_PTHREAD_ATTR_GETSTACKSIZE(a, s) \
171
 
                                     (*(s) = pthread_attr_getstacksize(*(a)), 0)
172
 
#define _PT_PTHREAD_GETSPECIFIC(k, r) \
173
 
                pthread_getspecific((k), (pthread_addr_t *) &(r))
174
 
#elif defined(_PR_PTHREADS)
175
 
#define _PT_PTHREAD_ATTR_INIT            pthread_attr_init
176
 
#define _PT_PTHREAD_ATTR_DESTROY         pthread_attr_destroy
177
 
#define _PT_PTHREAD_CREATE(t, a, f, r)   pthread_create(t, &a, f, r) 
178
 
#define _PT_PTHREAD_KEY_CREATE           pthread_key_create
179
 
#define _PT_PTHREAD_ATTR_SETSCHEDPOLICY  pthread_attr_setschedpolicy
180
 
#define _PT_PTHREAD_ATTR_GETSTACKSIZE(a, s) pthread_attr_getstacksize(a, s)
181
 
#define _PT_PTHREAD_GETSPECIFIC(k, r)    (r) = pthread_getspecific(k)
182
 
#else
183
 
#error "Cannot determine pthread strategy"
184
 
#endif
185
 
 
186
 
#if defined(_PR_DCETHREADS)
187
 
#define _PT_PTHREAD_EXPLICIT_SCHED      _PT_PTHREAD_DEFAULT_SCHED
188
 
#endif
189
 
 
190
 
/*
191
 
 * pthread_mutex_trylock returns different values in DCE threads and
192
 
 * pthreads.
193
 
 */
194
 
#if defined(_PR_DCETHREADS)
195
 
#define PT_TRYLOCK_SUCCESS 1
196
 
#define PT_TRYLOCK_BUSY    0
197
 
#else
198
 
#define PT_TRYLOCK_SUCCESS 0
199
 
#define PT_TRYLOCK_BUSY    EBUSY
200
 
#endif
201
 
 
202
 
/*
203
 
 * These platforms don't have sigtimedwait()
204
 
 */
205
 
#if (defined(AIX) && !defined(AIX4_3_PLUS)) \
206
 
        || defined(LINUX) || defined(__GNU__)|| defined(__GLIBC__) \
207
 
        || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \
208
 
        || defined(BSDI) || defined(UNIXWARE) \
209
 
        || defined(DARWIN) || defined(SYMBIAN)
210
 
#define PT_NO_SIGTIMEDWAIT
211
 
#endif
212
 
 
213
 
#if defined(OSF1)
214
 
#define PT_PRIO_MIN            PRI_OTHER_MIN
215
 
#define PT_PRIO_MAX            PRI_OTHER_MAX
216
 
#elif defined(IRIX)
217
 
#include <sys/sched.h>
218
 
#define PT_PRIO_MIN            PX_PRIO_MIN
219
 
#define PT_PRIO_MAX            PX_PRIO_MAX
220
 
#elif defined(AIX)
221
 
#include <sys/priv.h>
222
 
#include <sys/sched.h>
223
 
#ifndef PTHREAD_CREATE_JOINABLE
224
 
#define PTHREAD_CREATE_JOINABLE     PTHREAD_CREATE_UNDETACHED
225
 
#endif
226
 
#define PT_PRIO_MIN            DEFAULT_PRIO
227
 
#define PT_PRIO_MAX            DEFAULT_PRIO
228
 
#elif defined(HPUX)
229
 
 
230
 
#if defined(_PR_DCETHREADS)
231
 
#define PT_PRIO_MIN            PRI_OTHER_MIN
232
 
#define PT_PRIO_MAX            PRI_OTHER_MAX
233
 
#else /* defined(_PR_DCETHREADS) */
234
 
#include <sys/sched.h>
235
 
#define PT_PRIO_MIN            sched_get_priority_min(SCHED_OTHER)
236
 
#define PT_PRIO_MAX            sched_get_priority_max(SCHED_OTHER)
237
 
#endif /* defined(_PR_DCETHREADS) */
238
 
 
239
 
#elif defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
240
 
        || defined(FREEBSD) || defined(SYMBIAN)
241
 
#define PT_PRIO_MIN            sched_get_priority_min(SCHED_OTHER)
242
 
#define PT_PRIO_MAX            sched_get_priority_max(SCHED_OTHER)
243
 
#elif defined(NTO)
244
 
/*
245
 
 * Neutrino has functions that return the priority range but
246
 
 * they return invalid numbers, so I just hard coded these here
247
 
 * for now.  Jerry.Kirk@Nexarecorp.com
248
 
 */
249
 
#define PT_PRIO_MIN            0
250
 
#define PT_PRIO_MAX            30
251
 
#elif defined(SOLARIS)
252
 
/*
253
 
 * Solaris doesn't seem to have macros for the min/max priorities.
254
 
 * The range of 0-127 is mentioned in the pthread_setschedparam(3T)
255
 
 * man pages, and pthread_setschedparam indeed allows 0-127.  However,
256
 
 * pthread_attr_setschedparam does not allow 0; it allows 1-127.
257
 
 */
258
 
#define PT_PRIO_MIN            1
259
 
#define PT_PRIO_MAX            127
260
 
#elif defined(OPENBSD)
261
 
#define PT_PRIO_MIN            0
262
 
#define PT_PRIO_MAX            31
263
 
#elif defined(NETBSD) \
264
 
        || defined(BSDI) || defined(DARWIN) || defined(UNIXWARE) \
265
 
        || defined(RISCOS) /* XXX */
266
 
#define PT_PRIO_MIN            0
267
 
#define PT_PRIO_MAX            126
268
 
#else
269
 
#error "pthreads is not supported for this architecture"
270
 
#endif
271
 
 
272
 
/*
273
 
 * The _PT_PTHREAD_YIELD function is called from a signal handler.
274
 
 * Needed for garbage collection -- Look at PR_Suspend/PR_Resume
275
 
 * implementation.
276
 
 */
277
 
#if defined(_PR_DCETHREADS)
278
 
#define _PT_PTHREAD_YIELD()             pthread_yield()
279
 
#elif defined(OSF1)
280
 
/*
281
 
 * sched_yield can't be called from a signal handler.  Must use
282
 
 * the _np version.
283
 
 */
284
 
#define _PT_PTHREAD_YIELD()             pthread_yield_np()
285
 
#elif defined(AIX)
286
 
extern int (*_PT_aix_yield_fcn)();
287
 
#define _PT_PTHREAD_YIELD()                     (*_PT_aix_yield_fcn)()
288
 
#elif defined(IRIX)
289
 
#include <time.h>
290
 
#define _PT_PTHREAD_YIELD() \
291
 
    PR_BEGIN_MACRO                                              \
292
 
                struct timespec onemillisec = {0};              \
293
 
                onemillisec.tv_nsec = 1000000L;                 \
294
 
        nanosleep(&onemillisec,NULL);                   \
295
 
    PR_END_MACRO
296
 
#elif defined(HPUX) || defined(SOLARIS) \
297
 
        || defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
298
 
        || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \
299
 
        || defined(BSDI) || defined(NTO) || defined(DARWIN) \
300
 
        || defined(UNIXWARE) || defined(RISCOS) || defined(SYMBIAN)
301
 
#define _PT_PTHREAD_YIELD()             sched_yield()
302
 
#else
303
 
#error "Need to define _PT_PTHREAD_YIELD for this platform"
304
 
#endif
305
 
 
306
 
#endif /* nspr_pth_defs_h_ */