source: trunk/src/gcc/libobjc/thr-irix.c@ 519

Last change on this file since 519 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.0 KB
Line 
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 ([email protected])
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify it under the
8terms of the GNU General Public License as published by the Free Software
9Foundation; either version 2, or (at your option) any later version.
10
11GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14details.
15
16You should have received a copy of the GNU General Public License along with
17GNU CC; see the file COPYING. If not, write to the Free Software
18Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
20
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. */
26
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 "runtime.h"
34
35/* Key structure for maintaining thread specific storage */
36static void * __objc_shared_arena_handle = NULL;
37
38/* Backend initialization functions */
39
40/* Initialize the threads subsystem. */
41int
42__objc_init_thread_system(void)
43{
44 /* Name of IRIX arena. */
45 char arena_name[64];
46
47 DEBUG_PRINTF("__objc_init_thread_system\n");
48
49 /* Construct a temporary name for arena. */
50 sprintf(arena_name, "/usr/tmp/objc_%05u", (unsigned)getpid());
51
52 /* Up to 256 threads. Arena only for threads. */
53 usconfig(CONF_INITUSERS, 256);
54 usconfig(CONF_ARENATYPE, US_SHAREDONLY);
55
56 /* Initialize the arena */
57 if (!(__objc_shared_arena_handle = usinit(arena_name)))
58 /* Failed */
59 return -1;
60
61 return 0;
62}
63
64/* Close the threads subsystem. */
65int
66__objc_close_thread_system(void)
67{
68 return 0;
69}
70
71/* Backend thread functions */
72
73/* Create a new thread of execution. */
74objc_thread_t
75__objc_thread_detach(void (*func)(void *arg), void *arg)
76{
77 objc_thread_t thread_id;
78 int sys_id;
79
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;
84
85 return thread_id;
86}
87
88/* Set the current thread's priority. */
89int
90__objc_thread_set_priority(int priority)
91{
92 /* Not implemented yet */
93 return -1;
94}
95
96/* Return the current thread's priority. */
97int
98__objc_thread_get_priority(void)
99{
100 /* Not implemented yet */
101 return OBJC_THREAD_INTERACTIVE_PRIORITY;
102}
103
104/* Yield our process time to another thread. */
105void
106__objc_thread_yield(void)
107{
108 sginap(0);
109}
110
111/* Terminate the current thread. */
112int
113__objc_thread_exit(void)
114{
115 /* IRIX only has exit. */
116 exit(__objc_thread_exit_status);
117
118 /* Failed if we reached here */
119 return -1;
120}