File: globus_thread_pthreads.h

package info (click to toggle)
globus-common 14.7-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,308 kB
  • sloc: ansic: 33,976; sh: 9,902; makefile: 532; perl: 342; xml: 322
file content (275 lines) | stat: -rw-r--r-- 5,686 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/*
 * Copyright 1999-2006 University of Chicago
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * globus_thread_pthreads.h
 *
 *
 */

#if !defined GLOBUS_INCLUDE_GLOBUS_THREAD
#define GLOBUS_INCLUDE_GLOBUS_THREAD 1

#ifndef EXTERN_C_BEGIN
#ifdef __cplusplus
#define EXTERN_C_BEGIN extern "C" {
#define EXTERN_C_END }
#else
#define EXTERN_C_BEGIN
#define EXTERN_C_END
#endif
#endif

#include "globus_time.h"
#include "globus_module.h"

#if _POSIX_THREADS

#if defined __GNUC__ && defined __EXCEPTIONS
#undef __EXCEPTIONS
#include <pthread.h>
#define __EXCEPTIONS 1
#else
#include <pthread.h>
#endif

EXTERN_C_BEGIN

typedef struct
{
    pthread_cond_t                      cond;
    globus_bool_t                       poll_space;
    int                                 space;
} globus_pthread_cond_t;

typedef struct
{
    pthread_condattr_t                  condattr;
    int                                 space;
} globus_pthread_condattr_t;

extern
int
globus_thread_create(
    pthread_t *                         thread,
    pthreadattr_t *                     attr,
    globus_thread_func_t                func,
    void *                              user_arg);

extern
void
globus_thread_exit(void *status);

extern
int
globus_threadattr_init(
    pthreadattr_t *                     attr);

extern
int
globus_threadattr_destroy(
    pthreadattr_t *                     attr);

extern
int
globus_threadattr_setstacksize(
    pthreadattr_t *                     attr,
    size_t                              stacksize);

extern
int
globus_threadattr_getstacksize(
    globus_threadattr_t *               attr,
    size_t *                            stacksize);

extern
int
globus_thread_key_create(
    pthread_key_t *                     key,
    globus_thread_key_destructor_func_t destructor_func);

extern
int
globus_thread_key_delete(
    pthread_key_t                       key);

extern
int
globus_thread_setspecific(
    pthread_key_t                       key,
    void *                              value);

extern
void *
globus_thread_getspecific(
    pthread_key_t                       key);

extern
pthread_t
globus_thread_self(void);

extern
int
globus_thread_equal(
    pthread_t                           t1,
    pthread_t                           t2);

extern
int
globus_thread_once(
    pthread_once_t *                    once_control,
    void (*init_routine)(void));

extern
void
globus_thread_yield(void);

extern
globus_bool_t
globus_i_am_only_thread(void);

extern
int
globus_mutexattr_init(
    pthread_mutexattr_t *               attr);

extern
int
globus_mutexattr_destroy(
    pthread_mutexattr_t *               attr);

extern
int
globus_mutex_init(
    pthread_mutex_t *                   mutex,
    globus_mutexattr_t *                attr);

extern
int
globus_mutex_destroy(
    pthread_mutex_t *                   mutex);

extern
int
globus_mutex_lock(
    pthread_mutex_t *                   mutex);

extern
int
globus_mutex_trylock(
    pthread_mutex_t *                   mutex);

extern
int
globus_mutex_unlock(
    pthread_mutex_t *                   mutex);

extern
int
globus_condattr_init(
    globus_condattr_t *                 attr);

extern
int
globus_condattr_destroy(
    globus_condattr_t *                 attr);

extern
int
globus_cond_init(
    globus_cond_t *                     cond,
    globus_condattr_t *                 attr);

extern
int
globus_cond_destroy(
    globus_cond_t *                     cond);

extern
int
globus_cond_wait(
    globus_cond_t *                     cond,
    globus_mutex_t *                    mutex);

extern
int
globus_cond_timedwait(
    globus_cond_t *                     cond,
    globus_mutex_t *                    mutex,
    globus_abstime_t *                  abstime);

extern
int
globus_cond_signal(
    globus_cond_t *                     cond);

extern
int
globus_cond_broadcast(
    globus_cond_t *                     cond);

extern
int
globus_condattr_setspace(
    globus_condattr_t *                 attr,
    int                                 space);

extern
int
globus_condattr_getspace(
    globus_condattr_t *                 attr,
    int *                               space);

extern
int
globus_thread_sigmask(
    int                                 how,
    const sigset_t *                    newmask,
    sigset_t *                          oldmask);

extern
int
globus_thread_cancel(
    globus_thread_t                     thread);

extern
void
globus_thread_testcancel(void);

extern
int
globus_thread_setcancelstate(
    int                                 state,
    int *                               oldstate);


/******************************************************************************
                               Module definition
******************************************************************************/
extern int globus_i_thread_pre_activate();

extern globus_module_descriptor_t       globus_i_thread_module;

#define GLOBUS_THREAD_MODULE (&globus_i_thread_module)

EXTERN_C_END

globus_bool_t
globus_thread_preemptive_threads(void);

#endif /* _POSIX_THREADS */

#endif /* GLOBUS_INCLUDE_GLOBUS_THREAD */