~ubuntu-branches/ubuntu/quantal/nspr/quantal-security

« back to all changes in this revision

Viewing changes to mozilla/nsprpub/pr/include/md/_solaris.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack, Fabien Tassin, Alexander Sack
  • Date: 2009-01-11 13:50:07 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090111135007-butxlx6upwjcakod
Tags: 4.7.3-0ubuntu1
* New upstream version: 4.7.3 from NSPR_4_7_3_RTM tag

[ Fabien Tassin <fta@ubuntu.com> ]
* LP: #269188 - use /dev/urandom for better entropy on LTSP environments
* update diverged patches:
  - update debian/patches/30_pkgconfig.patch
  - update debian/patches/81_sonames.patch
  - update debian/patches/99_configure.patch

[ Alexander Sack <asac@ubuntu.com> ]
Drop debian soname patch for full upstream compatibility
* eliminate soname patch
  - delete debian/patches/81_sonames.patch
  - update debian/patches/series
* refresh configure patch to reflect dropped soname patch
  - update debian/patches/99_configure.patch
* install unversioned .so files
  - update debian/libnspr4-0d.install
* .so.0d links are not created without the soname patch. we create
  backlinks to the unversioned .so libs using debhelper; also we
  cannot dh_install the .0d versioned libs anymore and we drop
  them from .install accordingly
  - add debian/libnspr4-0d.links
  - update debian/libnspr4-0d.install
* implement link shuffeling transition (with abort cases) in
  maintainer scripts; affected libs: libnspr4.so libplc4.so libplds4.so
  - add debian/libnspr4-0d.postinst
  - add debian/libnspr4-0d.postrm
  - add debian/libnspr4-0d.preinst
  - add debian/libnspr4-0d.prerm
* drop soname version suffix from symbol files and reflect this fact by
  adjusting minimum version to this package version (4.7.3-0ubuntu1~)
  - update debian/libnspr4-0d.symbols
  - update debian/libnspr4-0d.symbols.amd64
  - update debian/libnspr4-0d.symbols.i386
  - update debian/libnspr4-0d.symbols.ia64
  - update debian/libnspr4-0d.symbols.lpia
  - update debian/libnspr4-0d.symbols.powerpc
* bump lower shlibs version constraint to 4.7.1+1.9-0ubuntu5~
  - update debian/rules
* rerun autoconf2.13 to apply dropped 81_sonames.patch to configure
  - update debian/patches/99_configure.patch
* explitly define libnspr4_0d_EXPORTED_LIBS and pass those manually
  to dpkg-gensymbols to workaround uncommon SONAME used by nspr libs
  - update debian/rules
* don't pretend to create shlibs-control file anymore; add binary
  lintian override for that
  - update debian/rules
* add #DEBHELPER# token to maintainer scripts
  - update debian/libnspr4-0d.postinst
  - update debian/libnspr4-0d.postrm
  - update debian/libnspr4-0d.preinst
  - update debian/libnspr4-0d.prerm

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
 * Intel x86 has atomic instructions.
76
76
 *
77
77
 * Sparc v8 does not have instructions to efficiently implement
78
 
 * atomic increment/decrement operations.  In the local threads
79
 
 * only and pthreads versions, we use the default atomic routine
80
 
 * implementation in pratom.c.  The obsolete global threads only
81
 
 * version uses a global mutex_t to implement the atomic routines
82
 
 * in solaris.c, which is actually equivalent to the default
83
 
 * implementation.
 
78
 * atomic increment/decrement operations.  We use the default
 
79
 * atomic routine implementation in pratom.c.
84
80
 *
85
81
 * 64-bit Solaris requires sparc v9, which has atomic instructions.
86
82
 */
87
 
#if defined(i386) || defined(_PR_GLOBAL_THREADS_ONLY) || defined(IS_64)
 
83
#if defined(i386) || defined(IS_64)
88
84
#define _PR_HAVE_ATOMIC_OPS
89
85
#endif
90
86
 
140
136
    PRUint32 __sin6_src_id;
141
137
};
142
138
#endif
143
 
#if defined(_PR_GLOBAL_THREADS_ONLY) || defined(_PR_PTHREADS)
 
139
#if defined(_PR_PTHREADS)
144
140
#define _PR_HAVE_GETHOST_R
145
141
#define _PR_HAVE_GETHOST_R_POINTER
146
142
#endif
177
173
#define _MD_EARLY_INIT          _MD_EarlyInit
178
174
#define _MD_FINAL_INIT          _PR_UnixInit
179
175
 
180
 
#elif defined(_PR_GLOBAL_THREADS_ONLY)
181
 
 
182
 
#include "prthread.h"
183
 
 
184
 
#include <ucontext.h>
185
 
 
186
 
/*
187
 
** Iinitialization Related definitions
188
 
*/
189
 
 
190
 
NSPR_API(void)          _MD_EarlyInit(void);
191
 
 
192
 
#define _MD_EARLY_INIT          _MD_EarlyInit
193
 
#define _MD_FINAL_INIT          _PR_UnixInit
194
 
 
195
 
#define _MD_GET_SP(threadp)     threadp->md.sp
196
 
 
197
 
/*
198
 
** Clean-up the thread machine dependent data structure
199
 
*/
200
 
#define _MD_INIT_THREAD                         _MD_InitializeThread
201
 
#define _MD_INIT_ATTACHED_THREAD        _MD_InitializeThread
202
 
 
203
 
NSPR_API(PRStatus) _MD_CreateThread(PRThread *thread, 
204
 
                                        void (*start)(void *), 
205
 
                                        PRThreadPriority priority,
206
 
                                        PRThreadScope scope, 
207
 
                                        PRThreadState state, 
208
 
                                        PRUint32 stackSize);
209
 
#define _MD_CREATE_THREAD _MD_CreateThread
210
 
 
211
 
#define _PR_CONTEXT_TYPE        ucontext_t
212
 
 
213
 
#define CONTEXT(_thread) (&(_thread)->md.context)
214
 
 
215
 
#include <thread.h>
216
 
#include <sys/lwp.h>
217
 
#include <synch.h>
218
 
 
219
 
extern struct PRLock *_pr_schedLock;
220
 
 
221
 
/*
222
 
** Thread Local Storage 
223
 
*/
224
 
 
225
 
#define THREAD_KEY_T thread_key_t
226
 
 
227
 
extern struct PRThread *_pr_attached_thread_tls();
228
 
extern struct PRThread *_pr_current_thread_tls();
229
 
extern struct _PRCPU *_pr_current_cpu_tls();
230
 
extern struct PRThread *_pr_last_thread_tls();
231
 
 
232
 
extern THREAD_KEY_T threadid_key;
233
 
extern THREAD_KEY_T cpuid_key;
234
 
extern THREAD_KEY_T last_thread_key;
235
 
 
236
 
#define _MD_GET_ATTACHED_THREAD() _pr_attached_thread_tls()
237
 
#define _MD_CURRENT_THREAD() _pr_current_thread_tls()
238
 
#define _MD_CURRENT_CPU() _pr_current_cpu_tls()
239
 
#define _MD_LAST_THREAD() _pr_last_thread_tls()
240
 
        
241
 
#define _MD_SET_CURRENT_THREAD(newval)                  \
242
 
        PR_BEGIN_MACRO                                  \
243
 
        thr_setspecific(threadid_key, (void *)newval);  \
244
 
        PR_END_MACRO
245
 
 
246
 
#define _MD_SET_CURRENT_CPU(newval)                     \
247
 
        PR_BEGIN_MACRO                                  \
248
 
        thr_setspecific(cpuid_key, (void *)newval);     \
249
 
        PR_END_MACRO
250
 
 
251
 
#define _MD_SET_LAST_THREAD(newval)                             \
252
 
        PR_BEGIN_MACRO                                          \
253
 
        thr_setspecific(last_thread_key, (void *)newval);       \
254
 
        PR_END_MACRO
255
 
        
256
 
#define _MD_CLEAN_THREAD(_thread)       _MD_cleanup_thread(_thread)
257
 
extern void _MD_exit_thread(PRThread *thread);
258
 
#define _MD_EXIT_THREAD(thread)         _MD_exit_thread(thread)
259
 
 
260
 
#define _MD_SUSPEND_THREAD(thread)      _MD_Suspend(thread)
261
 
#define _MD_RESUME_THREAD(thread)       thr_continue((thread)->md.handle)
262
 
 
263
 
/* XXXX Needs to be defined - Prashant */
264
 
#define _MD_SUSPEND_CPU(cpu)
265
 
#define _MD_RESUME_CPU(cpu)
266
 
 
267
 
extern void _MD_Begin_SuspendAll(void);
268
 
extern void _MD_End_SuspendAll(void);
269
 
extern void _MD_End_ResumeAll(void);
270
 
#define _MD_BEGIN_SUSPEND_ALL()         _MD_Begin_SuspendAll()
271
 
#define _MD_BEGIN_RESUME_ALL()          
272
 
#define _MD_END_SUSPEND_ALL()           _MD_End_SuspendAll()
273
 
#define _MD_END_RESUME_ALL()            _MD_End_ResumeAll()
274
 
 
275
 
#define _MD_INIT_LOCKS()
276
 
#define _MD_NEW_LOCK(md_lockp) (mutex_init(&((md_lockp)->lock),USYNC_THREAD,NULL) ? PR_FAILURE : PR_SUCCESS)
277
 
#define _MD_FREE_LOCK(md_lockp) mutex_destroy(&((md_lockp)->lock))
278
 
#define _MD_UNLOCK(md_lockp) mutex_unlock(&((md_lockp)->lock))
279
 
#define _MD_TEST_AND_LOCK(md_lockp) mutex_trylock(&((md_lockp)->lock))
280
 
struct _MDLock;
281
 
NSPR_API(void) _MD_lock(struct _MDLock *md_lock);
282
 
#undef PROFILE_LOCKS
283
 
#ifndef PROFILE_LOCKS
284
 
#define _MD_LOCK(md_lockp) _MD_lock(md_lockp)
285
 
#else
286
 
#define _MD_LOCK(md_lockp)                 \
287
 
    PR_BEGIN_MACRO \
288
 
    int rv = _MD_TEST_AND_LOCK(md_lockp); \
289
 
    if (rv == 0) { \
290
 
        (md_lockp)->hitcount++; \
291
 
    } else { \
292
 
        (md_lockp)->misscount++; \
293
 
        _MD_lock(md_lockp); \
294
 
    } \
295
 
    PR_END_MACRO
296
 
#endif
297
 
 
298
 
#define _PR_LOCK_HEAP() if (_pr_heapLock) _MD_LOCK(&_pr_heapLock->md)
299
 
#define _PR_UNLOCK_HEAP() if (_pr_heapLock) _MD_UNLOCK(&_pr_heapLock->md)
300
 
 
301
 
#define _MD_ATTACH_THREAD(threadp)
302
 
 
303
 
 
304
 
#define THR_KEYCREATE thr_keycreate
305
 
#define THR_SELF thr_self
306
 
#define _MD_NEW_CV(condp) cond_init(&((condp)->cv), USYNC_THREAD, 0)
307
 
#define COND_WAIT(condp, mutexp) cond_wait(condp, mutexp)
308
 
#define COND_TIMEDWAIT(condp, mutexp, tspec) \
309
 
                                     cond_timedwait(condp, mutexp, tspec)
310
 
#define _MD_NOTIFY_CV(condp, lockp) cond_signal(&((condp)->cv))
311
 
#define _MD_NOTIFYALL_CV(condp,unused) cond_broadcast(&((condp)->cv))   
312
 
#define _MD_FREE_CV(condp) cond_destroy(&((condp)->cv))
313
 
#define _MD_YIELD() thr_yield()
314
 
#include <time.h>
315
 
/* 
316
 
 * Because clock_gettime() on Solaris/x86 2.4 always generates a
317
 
 * segmentation fault, we use an emulated version _pr_solx86_clock_gettime(),
318
 
 * which is implemented using gettimeofday().
319
 
 */
320
 
#if defined(i386) && defined(SOLARIS2_4)
321
 
extern int _pr_solx86_clock_gettime(clockid_t clock_id, struct timespec *tp);
322
 
#define GETTIME(tt) _pr_solx86_clock_gettime(CLOCK_REALTIME, (tt))
323
 
#else
324
 
#define GETTIME(tt) clock_gettime(CLOCK_REALTIME, (tt))
325
 
#endif  /* i386 && SOLARIS2_4 */
326
 
 
327
 
#define MUTEX_T mutex_t
328
 
#define COND_T cond_t
329
 
 
330
 
#define _MD_NEW_SEM(md_semp,_val)  sema_init(&((md_semp)->sem),_val,USYNC_THREAD,NULL)
331
 
#define _MD_DESTROY_SEM(md_semp) sema_destroy(&((md_semp)->sem))
332
 
#define _MD_WAIT_SEM(md_semp) sema_wait(&((md_semp)->sem))
333
 
#define _MD_POST_SEM(md_semp) sema_post(&((md_semp)->sem))
334
 
 
335
 
#define _MD_SAVE_ERRNO(_thread)
336
 
#define _MD_RESTORE_ERRNO(_thread)
337
 
#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
338
 
 
339
 
extern struct _MDLock _pr_ioq_lock;
340
 
#define _MD_IOQ_LOCK()          _MD_LOCK(&_pr_ioq_lock)
341
 
#define _MD_IOQ_UNLOCK()        _MD_UNLOCK(&_pr_ioq_lock)
342
 
 
343
 
extern PRStatus _MD_wait(struct PRThread *, PRIntervalTime timeout);
344
 
#define _MD_WAIT _MD_wait
345
 
 
346
 
extern PRStatus _MD_WakeupWaiter(struct PRThread *);
347
 
#define _MD_WAKEUP_WAITER _MD_WakeupWaiter
348
 
 
349
 
NSPR_API(void) _MD_InitIO(void);
350
 
#define _MD_INIT_IO _MD_InitIO
351
 
 
352
 
#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
353
 
    PR_BEGIN_MACRO \
354
 
    *status = PR_TRUE; \
355
 
    PR_END_MACRO
356
 
#define _MD_SWITCH_CONTEXT(_thread)
357
 
#define _MD_RESTORE_CONTEXT(_newThread)
358
 
 
359
 
struct _MDLock {
360
 
    MUTEX_T lock;
361
 
#ifdef PROFILE_LOCKS
362
 
    PRInt32 hitcount;
363
 
    PRInt32 misscount;
364
 
#endif
365
 
};
366
 
 
367
 
struct _MDCVar {
368
 
    COND_T cv;
369
 
};
370
 
 
371
 
struct _MDSemaphore {
372
 
    sema_t sem;
373
 
};
374
 
 
375
 
struct _MDThread {
376
 
    _PR_CONTEXT_TYPE context;
377
 
    thread_t handle;
378
 
    lwpid_t lwpid;
379
 
    uint_t sp;          /* stack pointer */
380
 
    uint_t threadID;    /* ptr to solaris-internal thread id structures */
381
 
    struct _MDSemaphore waiter_sem;
382
 
};
383
 
 
384
 
struct _MDThreadStack {
385
 
    PRInt8 notused;
386
 
};
387
 
 
388
 
struct _MDSegment {
389
 
    PRInt8 notused;
390
 
};
391
 
 
392
 
/*
393
 
 * md-specific cpu structure field, common to all Unix platforms
394
 
 */
395
 
#define _PR_MD_MAX_OSFD FD_SETSIZE
396
 
 
397
 
struct _MDCPU_Unix {
398
 
    PRCList ioQ;
399
 
    PRUint32 ioq_timeout;
400
 
    PRInt32 ioq_max_osfd;
401
 
    PRInt32 ioq_osfd_cnt;
402
 
#ifndef _PR_USE_POLL
403
 
    fd_set fd_read_set, fd_write_set, fd_exception_set;
404
 
    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
405
 
                                fd_exception_cnt[_PR_MD_MAX_OSFD];
406
 
#else
407
 
        struct pollfd *ioq_pollfds;
408
 
        int ioq_pollfds_size;
409
 
#endif  /* _PR_USE_POLL */
410
 
};
411
 
 
412
 
#define _PR_IOQ(_cpu)                   ((_cpu)->md.md_unix.ioQ)
413
 
#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
414
 
#define _PR_FD_READ_SET(_cpu)           ((_cpu)->md.md_unix.fd_read_set)
415
 
#define _PR_FD_READ_CNT(_cpu)           ((_cpu)->md.md_unix.fd_read_cnt)
416
 
#define _PR_FD_WRITE_SET(_cpu)          ((_cpu)->md.md_unix.fd_write_set)
417
 
#define _PR_FD_WRITE_CNT(_cpu)          ((_cpu)->md.md_unix.fd_write_cnt)
418
 
#define _PR_FD_EXCEPTION_SET(_cpu)      ((_cpu)->md.md_unix.fd_exception_set)
419
 
#define _PR_FD_EXCEPTION_CNT(_cpu)      ((_cpu)->md.md_unix.fd_exception_cnt)
420
 
#define _PR_IOQ_TIMEOUT(_cpu)           ((_cpu)->md.md_unix.ioq_timeout)
421
 
#define _PR_IOQ_MAX_OSFD(_cpu)          ((_cpu)->md.md_unix.ioq_max_osfd)
422
 
#define _PR_IOQ_OSFD_CNT(_cpu)          ((_cpu)->md.md_unix.ioq_osfd_cnt)
423
 
#define _PR_IOQ_POLLFDS(_cpu)           ((_cpu)->md.md_unix.ioq_pollfds)
424
 
#define _PR_IOQ_POLLFDS_SIZE(_cpu)      ((_cpu)->md.md_unix.ioq_pollfds_size)
425
 
 
426
 
#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)  32
427
 
 
428
 
 
429
 
struct _MDCPU {
430
 
        struct _MDCPU_Unix md_unix;
431
 
};
432
 
 
433
 
/* The following defines the unwrapped versions of select() and poll(). */
434
 
extern int _select(int nfds, fd_set *readfds, fd_set *writefds,
435
 
        fd_set *exceptfds, struct timeval *timeout);
436
 
#define _MD_SELECT      _select
437
 
 
438
 
#include <poll.h>
439
 
#define _MD_POLL _poll
440
 
extern int _poll(struct pollfd *fds, unsigned long nfds, int timeout);
441
 
 
442
 
PR_BEGIN_EXTERN_C
443
 
 
444
 
/*
445
 
** Missing function prototypes
446
 
*/
447
 
extern int gethostname (char *name, int namelen);
448
 
 
449
 
PR_END_EXTERN_C
450
 
 
451
 
#else /* _PR_GLOBAL_THREADS_ONLY */
452
 
 
453
 
/*
454
 
 * LOCAL_THREADS_ONLY implementation on Solaris
 
176
#else /* _PR_PTHREADS */
 
177
 
 
178
/*
 
179
 * _PR_LOCAL_THREADS_ONLY implementation on Solaris
455
180
 */
456
181
 
457
182
#include "prthread.h"
462
187
#include <synch.h>
463
188
 
464
189
/*
465
 
** Iinitialization Related definitions
 
190
** Initialization Related definitions
466
191
*/
467
192
 
468
193
NSPR_API(void)                          _MD_EarlyInit(void);
798
523
 
799
524
PR_END_EXTERN_C
800
525
 
801
 
#endif /* _PR_GLOBAL_THREADS_ONLY */
 
526
#endif /* _PR_PTHREADS */
802
527
 
803
528
extern void _MD_solaris_map_sendfile_error(int err);
804
529