OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libobjc/] [objc/] [thr.h] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* Thread and mutex controls for Objective C.
2
   Copyright (C) 1996, 1997, 2002, 2004 Free Software Foundation, Inc.
3
   Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
4
 
5
This file is part of GCC.
6
 
7
GCC 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
GCC 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
GCC 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
GCC 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
GCC; see the file COPYING.  If not, write to the Free Software
28
Foundation, 51 Franklin Street, Fifth Floor,
29
Boston, MA 02110-1301, 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.h"
42
 
43
#ifdef __cplusplus
44
extern "C" {
45
#endif /* __cplusplus */
46
 
47
/*************************************************************************
48
 *  Universal static variables:
49
 */
50
extern int __objc_thread_exit_status;      /* Global exit status.   */
51
 
52
/********
53
 *  Thread safe implementation types and functions.
54
 */
55
 
56
/* Thread priorities */
57
#define OBJC_THREAD_INTERACTIVE_PRIORITY        2
58
#define OBJC_THREAD_BACKGROUND_PRIORITY         1
59
#define OBJC_THREAD_LOW_PRIORITY                0
60
 
61
/* A thread */
62
typedef void * objc_thread_t;
63
 
64
/* This structure represents a single mutual exclusion lock. */
65
struct objc_mutex
66
{
67
  volatile objc_thread_t owner;     /* Id of thread that owns. */
68
  volatile int depth;               /* # of acquires. */
69
  void * backend;                   /* Specific to backend */
70
};
71
typedef struct objc_mutex *objc_mutex_t;
72
 
73
/* This structure represents a single condition mutex */
74
struct objc_condition
75
{
76
  void * backend;                   /* Specific to backend */
77
};
78
typedef struct objc_condition *objc_condition_t;
79
 
80
/* Frontend mutex functions */
81
objc_mutex_t objc_mutex_allocate (void);
82
int objc_mutex_deallocate (objc_mutex_t mutex);
83
int objc_mutex_lock (objc_mutex_t mutex);
84
int objc_mutex_unlock (objc_mutex_t mutex);
85
int objc_mutex_trylock (objc_mutex_t mutex);
86
 
87
/* Frontend condition mutex functions */
88
objc_condition_t objc_condition_allocate (void);
89
int objc_condition_deallocate (objc_condition_t condition);
90
int objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex);
91
int objc_condition_signal (objc_condition_t condition);
92
int objc_condition_broadcast (objc_condition_t condition);
93
 
94
/* Frontend thread functions */
95
objc_thread_t objc_thread_detach (SEL selector, id object, id argument);
96
void objc_thread_yield (void);
97
int objc_thread_exit (void);
98
int objc_thread_set_priority (int priority);
99
int objc_thread_get_priority (void);
100
void * objc_thread_get_data (void);
101
int objc_thread_set_data (void *value);
102
objc_thread_t objc_thread_id (void);
103
void objc_thread_add (void);
104
void objc_thread_remove (void);
105
 
106
/*
107
  Use this to set the hook function that will be called when the
108
  runtime initially becomes multi threaded.
109
  The hook function is only called once, meaning only when the
110
  2nd thread is spawned, not for each and every thread.
111
 
112
  It returns the previous hook function or NULL if there is none.
113
 
114
  A program outside of the runtime could set this to some function so
115
  it can be informed; for example, the GNUstep Base Library sets it
116
  so it can implement the NSBecomingMultiThreaded notification.
117
  */
118
typedef void (*objc_thread_callback) (void);
119
objc_thread_callback objc_set_thread_callback (objc_thread_callback func);
120
 
121
/* Backend initialization functions */
122
int __objc_init_thread_system (void);
123
int __objc_fini_thread_system (void);
124
 
125
/* Backend mutex functions */
126
int __objc_mutex_allocate (objc_mutex_t mutex);
127
int __objc_mutex_deallocate (objc_mutex_t mutex);
128
int __objc_mutex_lock (objc_mutex_t mutex);
129
int __objc_mutex_trylock (objc_mutex_t mutex);
130
int __objc_mutex_unlock (objc_mutex_t mutex);
131
 
132
/* Backend condition mutex functions */
133
int __objc_condition_allocate (objc_condition_t condition);
134
int __objc_condition_deallocate (objc_condition_t condition);
135
int __objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex);
136
int __objc_condition_broadcast (objc_condition_t condition);
137
int __objc_condition_signal (objc_condition_t condition);
138
 
139
/* Backend thread functions */
140
objc_thread_t __objc_thread_detach (void (*func) (void *arg), void *arg);
141
int __objc_thread_set_priority (int priority);
142
int __objc_thread_get_priority (void);
143
void __objc_thread_yield (void);
144
int __objc_thread_exit (void);
145
objc_thread_t __objc_thread_id (void);
146
int __objc_thread_set_data (void *value);
147
void * __objc_thread_get_data (void);
148
 
149
#ifdef __cplusplus
150
}
151
#endif /* __cplusplus */
152
 
153
#endif /* not __thread_INCLUDE_GNU */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.