blob: fa52a94bea66fd8069c0c2e498b1a3bb798c34ea [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26#ifndef _JAVASOFT_PORTING_H_
27#define _JAVASOFT_PORTING_H_
28
29#ifndef USE_PTHREADS
30
31#include <thread.h>
32#include <sys/lwp.h>
33#include <synch.h>
34
35#else /* USE_PTHREADS */
36
37#include <pthread.h>
38
39/* There is a handshake between a newly created thread and its creator
40 * at thread startup because the creator thread needs to suspend the
41 * new thread. Currently there are two ways to do this -- with
42 * semaphores and with mutexes. The semaphore based implementation is
43 * cleaner and hence is the default. We wish the mutex based one will
44 * go away, but turns out the implementation of semaphores on
45 * Linux/ppc etc is flaky, so the mutex based solution lives for now.
46 */
47#ifndef USE_MUTEX_HANDSHAKE
48#include <semaphore.h>
49#endif
50
51#undef BOUND_THREADS
52
53#define thread_t pthread_t
54
55#define mutex_t pthread_mutex_t
56#define mutex_lock pthread_mutex_lock
57#define mutex_trylock pthread_mutex_trylock
58#define mutex_unlock pthread_mutex_unlock
59#define mutex_destroy pthread_mutex_destroy
60
61#define cond_t pthread_cond_t
62#define cond_destroy pthread_cond_destroy
63#define cond_wait pthread_cond_wait
64#define cond_timedwait pthread_cond_timedwait
65#define cond_signal pthread_cond_signal
66#define cond_broadcast pthread_cond_broadcast
67
68#define thread_key_t pthread_key_t
69#define thr_setspecific pthread_setspecific
70#define thr_keycreate pthread_key_create
71
72#define thr_sigsetmask pthread_sigmask
73#define thr_self pthread_self
74#define thr_yield sched_yield
75#define thr_kill pthread_kill
76#define thr_exit pthread_exit
77#ifdef __linux__
78void intrHandler(void*);
79#endif
80#endif /* USE_PTHREADS */
81
82#endif /* !_JAVASOFT_PORTING_H_ */