simplify-rtx.c (simplify_unary_operation_1): Extend the handling of SUBREG_PROMOTED_V...
[official-gcc.git] / libobjc / thr-irix.c
blobca68e08a49193e05e27bf7c0ed1acbab378cbc6e
1 /* GNU Objective C Runtime Thread Interface - SGI IRIX Implementation
2 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3 Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under the
8 terms of the GNU General Public License as published by the Free Software
9 Foundation; either version 2, or (at your option) any later version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 details.
16 You should have received a copy of the GNU General Public License along with
17 GCC; see the file COPYING. If not, write to the Free Software
18 Foundation, 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
21 /* As a special exception, if you link this library with files compiled with
22 GCC to produce an executable, this does not cause the resulting executable
23 to be covered by the GNU General Public License. This exception does not
24 however invalidate any other reasons why the executable file might be
25 covered by the GNU General Public License. */
27 #include <stdlib.h>
28 #include <sys/types.h>
29 #include <sys/sysmp.h>
30 #include <sys/prctl.h>
31 #include <ulocks.h>
32 #include "objc/thr.h"
33 #include "objc/runtime.h"
35 /* Key structure for maintaining thread specific storage */
36 static void * __objc_shared_arena_handle = NULL;
38 /* Backend initialization functions */
40 /* Initialize the threads subsystem. */
41 int
42 __objc_init_thread_system(void)
44 /* Name of IRIX arena. */
45 char arena_name[64];
47 DEBUG_PRINTF("__objc_init_thread_system\n");
49 /* Construct a temporary name for arena. */
50 sprintf(arena_name, "/usr/tmp/objc_%05u", (unsigned)getpid());
52 /* Up to 256 threads. Arena only for threads. */
53 usconfig(CONF_INITUSERS, 256);
54 usconfig(CONF_ARENATYPE, US_SHAREDONLY);
56 /* Initialize the arena */
57 if (!(__objc_shared_arena_handle = usinit(arena_name)))
58 /* Failed */
59 return -1;
61 return 0;
64 /* Close the threads subsystem. */
65 int
66 __objc_close_thread_system(void)
68 return 0;
71 /* Backend thread functions */
73 /* Create a new thread of execution. */
74 objc_thread_t
75 __objc_thread_detach(void (*func)(void *arg), void *arg)
77 objc_thread_t thread_id;
78 int sys_id;
80 if ((sys_id = sproc((void *)func, PR_SALL, arg)) >= 0)
81 thread_id = (objc_thread_t)sys_id;
82 else
83 thread_id = NULL;
85 return thread_id;
88 /* Set the current thread's priority. */
89 int
90 __objc_thread_set_priority(int priority)
92 /* Not implemented yet */
93 return -1;
96 /* Return the current thread's priority. */
97 int
98 __objc_thread_get_priority(void)
100 /* Not implemented yet */
101 return OBJC_THREAD_INTERACTIVE_PRIORITY;
104 /* Yield our process time to another thread. */
105 void
106 __objc_thread_yield(void)
108 sginap(0);
111 /* Terminate the current thread. */
113 __objc_thread_exit(void)
115 /* IRIX only has exit. */
116 exit(__objc_thread_exit_status);
118 /* Failed if we reached here */
119 return -1;
122 /* Returns an integer value which uniquely describes a thread. */
123 objc_thread_t
124 __objc_thread_id(void)
126 /* Threads are processes. */
127 return (objc_thread_t)get_pid();
130 /* Sets the thread's local storage pointer. */
132 __objc_thread_set_data(void *value)
134 *((void **)&PRDA->usr_prda) = value;
135 return 0;
138 /* Returns the thread's local storage pointer. */
139 void *
140 __objc_thread_get_data(void)
142 return *((void **)&PRDA->usr_prda);
145 /* Backend mutex functions */
147 /* Allocate a mutex. */
149 __objc_mutex_allocate(objc_mutex_t mutex)
151 if (!( (ulock_t)(mutex->backend) = usnewlock(__objc_shared_arena_handle) ))
152 return -1;
153 else
154 return 0;
157 /* Deallocate a mutex. */
159 __objc_mutex_deallocate(objc_mutex_t mutex)
161 usfreelock((ulock_t)(mutex->backend), __objc_shared_arena_handle);
162 return 0;
165 /* Grab a lock on a mutex. */
167 __objc_mutex_lock(objc_mutex_t mutex)
169 if (ussetlock((ulock_t)(mutex->backend)) == 0)
170 return -1;
171 else
172 return 0;
175 /* Try to grab a lock on a mutex. */
177 __objc_mutex_trylock(objc_mutex_t mutex)
179 if (ustestlock((ulock_t)(mutex->backend)) == 0)
180 return -1;
181 else
182 return 0;
185 /* Unlock the mutex */
187 __objc_mutex_unlock(objc_mutex_t mutex)
189 usunsetlock((ulock_t)(mutex->backend));
190 return 0;
193 /* Backend condition mutex functions */
195 /* Allocate a condition. */
197 __objc_condition_allocate(objc_condition_t condition)
199 /* Unimplemented. */
200 return -1;
203 /* Deallocate a condition. */
205 __objc_condition_deallocate(objc_condition_t condition)
207 /* Unimplemented. */
208 return -1;
211 /* Wait on the condition */
213 __objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
215 /* Unimplemented. */
216 return -1;
219 /* Wake up all threads waiting on this condition. */
221 __objc_condition_broadcast(objc_condition_t condition)
223 /* Unimplemented. */
224 return -1;
227 /* Wake up one thread waiting on this condition. */
229 __objc_condition_signal(objc_condition_t condition)
231 /* Unimplemented. */
232 return -1;
235 /* End of File */