OSDN Git Service

* jump.c (jump_optimize, follow_jumps, mark_jump_label): Disable some
[pf3gnuchains/gcc-fork.git] / gcc / objc / thr.h
1 /* Thread and mutex controls for Objective C.
2    Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3    Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 GNU CC is free software; you can redistribute it and/or modify it under the
18 terms of the GNU General Public License as published by the Free Software
19 Foundation; either version 2, or (at your option) any later version.
20
21 GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
22 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
23 FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
24 details.
25
26 You should have received a copy of the GNU General Public License along with
27 GNU CC; see the file COPYING.  If not, write to the Free Software
28 Foundation, 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA.  */
30
31 /* As a special exception, if you link this library with files
32    compiled with GCC to produce an executable, this does not cause
33    the resulting executable to be covered by the GNU General Public License.
34    This exception does not however invalidate any other reasons why
35    the executable file might be covered by the GNU General Public License.  */
36
37
38 #ifndef __thread_INCLUDE_GNU
39 #define __thread_INCLUDE_GNU
40
41 #include "objc/objc.h"
42
43 /*************************************************************************
44  *  Universal static variables:
45  */
46 extern int __objc_thread_exit_status;      /* Global exit status.   */
47
48 /********
49  *  Thread safe implementation types and functions.  
50  */
51
52 #define OBJC_THREAD_INTERACTIVE_PRIORITY        2
53 #define OBJC_THREAD_BACKGROUND_PRIORITY         1
54 #define OBJC_THREAD_LOW_PRIORITY                0
55
56 typedef void * objc_thread_t;
57 typedef struct objc_mutex *objc_mutex_t;
58 typedef struct objc_condition *objc_condition_t;
59
60 objc_mutex_t objc_mutex_allocate(void);
61 int     objc_mutex_deallocate(objc_mutex_t mutex);
62 int     objc_mutex_lock(objc_mutex_t mutex);
63 int     objc_mutex_unlock(objc_mutex_t mutex);
64 int     objc_mutex_trylock(objc_mutex_t mutex);
65
66 objc_condition_t objc_condition_allocate(void);
67 int     objc_condition_deallocate(objc_condition_t condition);
68 int     objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex);
69 int     objc_condition_signal(objc_condition_t condition);
70 int     objc_condition_broadcast(objc_condition_t condition);
71
72 objc_thread_t objc_thread_create(void (*func)(void *arg), void *arg);
73 void    objc_thread_yield(void);
74 int     objc_thread_exit(void);
75 int     objc_thread_set_priority(int priority);
76 int     objc_thread_get_priority(void);
77 void *  objc_thread_get_data(void);
78 int     objc_thread_set_data(void *value);
79 objc_thread_t objc_thread_id(void);
80
81 objc_thread_t objc_thread_detach(SEL selector, id object, id argument);
82 int     objc_mutex_lock_x(objc_mutex_t mutex, const char *f, int l);
83 int     objc_mutex_unlock_x(objc_mutex_t mutex, const char *f, int l);
84
85 /*
86   Use this to set the hook function that will be called when the 
87   runtime initially becomes multi threaded.
88   The hook function is only called once, meaning only when the 
89   2nd thread is spawned, not for each and every thread.
90
91   It returns the previous hook function or NULL if there is none.
92
93   A program outside of the runtime could set this to some function so
94   it can be informed; for example, the GNUstep Base Library sets it 
95   so it can implement the NSBecomingMultiThreaded notification.
96   */
97 typedef void (*objc_thread_callback)();
98 objc_thread_callback objc_set_thread_callback(objc_thread_callback func);
99
100 /* For debugging of locks, uncomment these two macros: */
101 /* #define objc_mutex_lock(x)      objc_mutex_lock_x(x, __FILE__, __LINE__) */
102 /* #define objc_mutex_unlock(x)    objc_mutex_unlock_x(x, __FILE__, __LINE__)*/
103
104 #endif /* not __thread_INCLUDE_GNU */