| 1 | // -*- c++ -*-
|
|---|
| 2 | // posix-threads.h - Defines for using POSIX threads.
|
|---|
| 3 |
|
|---|
| 4 | /* Copyright (C) 1998, 1999, 2001 Free Software Foundation
|
|---|
| 5 |
|
|---|
| 6 | This file is part of libgcj.
|
|---|
| 7 |
|
|---|
| 8 | This software is copyrighted work licensed under the terms of the
|
|---|
| 9 | Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
|---|
| 10 | details. */
|
|---|
| 11 |
|
|---|
| 12 | #ifndef __JV_POSIX_THREADS__
|
|---|
| 13 | #define __JV_POSIX_THREADS__
|
|---|
| 14 |
|
|---|
| 15 | // NOTE: This file may only reference those pthread functions which
|
|---|
| 16 | // are known not to be overridden by the Boehm GC. If in doubt, scan
|
|---|
| 17 | // boehm-gc/gc.h. This is yucky but lets us avoid including gc.h
|
|---|
| 18 | // everywhere (which would be truly yucky).
|
|---|
| 19 |
|
|---|
| 20 | #include <pthread.h>
|
|---|
| 21 | #include <sched.h>
|
|---|
| 22 |
|
|---|
| 23 | //
|
|---|
| 24 | // Typedefs.
|
|---|
| 25 | //
|
|---|
| 26 |
|
|---|
| 27 | typedef struct _Jv_Thread_t
|
|---|
| 28 | {
|
|---|
| 29 | // Flag values are defined in implementation.
|
|---|
| 30 | int flags;
|
|---|
| 31 |
|
|---|
| 32 | // Actual thread id.
|
|---|
| 33 | pthread_t thread;
|
|---|
| 34 |
|
|---|
| 35 | // Java Thread object.
|
|---|
| 36 | java::lang::Thread *thread_obj;
|
|---|
| 37 |
|
|---|
| 38 | // Condition variable and corresponding mutex, used to implement the
|
|---|
| 39 | // interruptable wait/notify mechanism.
|
|---|
| 40 | pthread_cond_t wait_cond;
|
|---|
| 41 | pthread_mutex_t wait_mutex;
|
|---|
| 42 |
|
|---|
| 43 | // Next thread for Condition Variable wait-list chain.
|
|---|
| 44 | _Jv_Thread_t *next;
|
|---|
| 45 |
|
|---|
| 46 | } _Jv_Thread_t;
|
|---|
| 47 |
|
|---|
| 48 | typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | // Condition Variables used to implement wait/notify/sleep/interrupt.
|
|---|
| 52 | typedef struct
|
|---|
| 53 | {
|
|---|
|
|---|