File: globus_thread_none.c

package info (click to toggle)
globus-common 11.5-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 6,352 kB
  • ctags: 4,592
  • sloc: ansic: 35,631; sh: 10,368; makefile: 590; perl: 408
file content (522 lines) | stat: -rw-r--r-- 10,635 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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
/*
 * 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_none.c

Description:

  Stubs for the Globus threads package, to be used when Globus has been
  configured not to use threads.

CVS Information:

  $Source: /home/globdev/CVS/globus-packages/common/source/library/globus_thread_none.c,v $
  $Date: 2006/01/19 05:54:14 $
  $Revision: 1.10 $
  $State: Exp $
  $Author: mlink $
******************************************************************************/

/******************************************************************************
			     Include header files
******************************************************************************/
#include "globus_common_include.h"
#include "globus_thread_none.h"
#include "globus_thread_common.h"
#include "globus_i_thread.h"
#include "version.h"
#include "globus_time.h"
#include "globus_libc.h"
#include "globus_common.h"

/******************************************************************************
			       Define macros
******************************************************************************/


/******************************************************************************
                    Module activation function prototypes
******************************************************************************/
static int
globus_l_thread_activate(void);

static int
globus_l_thread_deactivate(void);


/******************************************************************************
                              Module definition
******************************************************************************/
globus_module_descriptor_t             globus_i_thread_module =
{
    "globus_thread_none",
    globus_l_thread_activate,
    globus_l_thread_deactivate,
    GLOBUS_NULL,
    GLOBUS_NULL,
    &local_version
};



/******************************************************************************
			      Function prototypes
******************************************************************************/

/*
 * globus_i_thread_pre_activate()
 *
 * Since globus_module depends on threads and globus_thread depends on
 * globus_module, we need this bootstrapping function.
 * 
 */
int
globus_i_thread_pre_activate()
{
#ifndef WIN32
    return globus_i_thread_ignore_sigpipe();
#else
    return 1;
#endif
}

/*
 * globus_l_thread_activate()
 */
static int
globus_l_thread_activate()
{
    return globus_module_activate(GLOBUS_THREAD_COMMON_MODULE);
}
/* globus_l_thread_activate() */


/*
 * globus_l_thread_deactivate()
 */
static int
globus_l_thread_deactivate()
{
    return globus_module_deactivate(GLOBUS_THREAD_COMMON_MODULE);
}
/* globus_l_thread_deactivate() */


/*
 * globus_thread_preemptive_threads
 *
 * Return GLOBUS_TRUE (non-zero) if we are using preemptive threads.
 */
globus_bool_t
globus_thread_preemptive_threads(void)
{
    return GLOBUS_FALSE;/* globus_macro_thread_is_preemptive();*/
}
/* globus_thread_preemptive_threads() */


/*
 * globus_thread_key_create()
 */
#undef globus_thread_key_create
int
globus_thread_key_create(
    globus_thread_key_t *		key,
    globus_thread_key_destructor_func_t	func)
{
    int rc;

    rc = globus_macro_thread_key_create(key, func);
    globus_i_thread_test_rc(rc, _GCSL("NEXUS: globusthread_key_create() failed\n"));
    return (rc);
}
/* globus_key_create() */


/*
 * globus_thread_setspecific()
 */
#undef globus_thread_setspecific
int
globus_thread_setspecific(
    globus_thread_key_t			key,
    void *				value)
{
    int rc;

    rc = globus_macro_thread_setspecific(key, value);
    globus_i_thread_test_rc(rc, _GCSL("NEXUS: globus_thread_setspecific() failed\n"));
    return (rc);
}
/* globus_thread_setspecific() */

#undef globus_thread_key_delete
int
globus_thread_key_delete(
    globus_thread_key_t key)
{
    return globus_macro_thread_key_delete(key);
} /* globus_thread_key_delete() */

/*
 * globus_thread_getspecific()
 */
#undef globus_thread_getspecific
void *
globus_thread_getspecific(
    globus_thread_key_t			key)
{
    void *value;

    value = globus_macro_thread_getspecific(key);
    return (value);
}
/* globus_thread_getspecific() */



/*
 * globus_thread_once()
 */
#undef globus_thread_once
int
globus_thread_once(
    globus_thread_once_t *		once_control,
    void				(*init_routine)(void))
{
    return (globus_macro_thread_once(once_control, init_routine));
}
/* globus_thread_once() */


/*
 * globus_thread_self()
 */
#undef globus_thread_self
globus_thread_t
globus_thread_self(void)
{
    return(globus_macro_thread_self());
}
/* globus_thread_self() */


/*
 * globus_thread_equal()
 */
#undef globus_thread_equal
int
globus_thread_equal(
    globus_thread_t			thread1,
    globus_thread_t			thread2)
{
    return (globus_macro_thread_equal(thread1, thread2));
}
/* globus_thread_equal() */


/*
 * globus_thread_create()
 */
#undef globus_thread_create
int
globus_thread_create(
    globus_thread_t *			thread,
    globus_threadattr_t *		attr,
    globus_thread_func_t		func,
    void *				user_arg)
{
    return (globus_macro_thread_create(thread, attr, func, user_arg));
}

/*
 * globus_thread_yield()
 */
#undef globus_thread_yield
void
globus_thread_yield(void)
{
    globus_macro_thread_yield();
}
/* globus_thread_yield() */


/*
 * globus_mutex_init()
 */
#undef globus_mutex_init
int
globus_mutex_init(
    globus_mutex_t *			mut,
    globus_mutexattr_t *		attr)
{
    int rc;

    rc = globus_macro_mutex_init(mut, attr);
    globus_i_thread_test_rc(rc, _GCSL("NEXUS: globus_mutex_init() failed\n"));
    return (rc);
}
/* globus_mutex_init() */


/*
 *  globus_mutex_destroy()
 */
#undef globus_mutex_destroy
int
globus_mutex_destroy(
    globus_mutex_t *			mut)
{
    int rc;

    rc = globus_macro_mutex_destroy(mut);
    globus_i_thread_test_rc(rc, _GCSL("NEXUS: globus_mutex_destroy() failed\n"));
    return (rc);
}
/* globus_mutex_destroy() */


/* 
 *  globus_mutex_lock()
 */
#undef globus_mutex_lock
int
globus_mutex_lock(
    globus_mutex_t *			mut)
{
    int rc;

    rc = globus_macro_mutex_lock(mut);
    globus_i_thread_test_rc(rc, _GCSL("NEXUS: globus_mutex_lock() failed\n"));
    return (rc);
}
/* globus_mutex_lock() */


/*
 *  globus_mutex_unlock()
 */
#undef globus_mutex_unlock
int
globus_mutex_unlock(
    globus_mutex_t *			mut)
{
    int rc;

    rc = globus_macro_mutex_unlock(mut);
    globus_i_thread_test_rc(rc, _GCSL("NEXUS: globus_mutex_unlock() failed\n"));
    return (rc);
}
/* globus_mutex_unlock() */


/*
 *  globus_mutex_trylock()
 */
#undef globus_mutex_trylock
int
globus_mutex_trylock(
    globus_mutex_t *			mut)
{
    int rc;

    rc = globus_macro_mutex_trylock(mut);
    /*
     * trylock is allowed to return non-0 value, so don't call
     * globus_i_thread_test_rc() on the return code
     */
#   if 0
    {
	/* 
	 * This could probably be checked in all cases except EBUSY, though.
	 */
	globus_i_thread_test_rc(rc, "NEXUS: globus_mutex_trylock() failed\n");
    }
#   endif
    return (rc);
}
/* globus_mutex_trylock() */


/*
 * globus_condattr_init()
 */
#undef globus_condattr_init
int globus_condattr_init(globus_condattr_t *attr)
{
    int rc;
    rc = globus_macro_condattr_init(attr);
    return (rc);
}

/*
 * globus_condattr_destroy()
 */
#undef globus_condattr_destroy
int globus_condattr_destroy(globus_condattr_t *attr)
{
    int rc;
    rc = globus_macro_condattr_destroy(attr);
    return (rc);
}

/*
 * globus_condattr_setspace()
 */
#undef globus_condattr_setspace
int globus_condattr_setspace(
    globus_condattr_t *                 attr,
    int                                 space)
{
    int rc;
    rc = globus_macro_condattr_setspace(attr, space);
    return (rc);
}

/*
 * globus_condattr_getspace()
 */
#undef globus_condattr_getspace
int globus_condattr_getspace(
    globus_condattr_t *                 attr,
    int *                               space)
{
    int rc;
    rc = globus_macro_condattr_getspace(attr, space);
    return (rc);
}

/*
 * globus_cond_init()
 */
#undef globus_cond_init
int
globus_cond_init(
    globus_cond_t *			cv,
    globus_condattr_t *			attr)
{
    int rc;

    rc = globus_macro_cond_init(cv, attr);
    globus_i_thread_test_rc(rc, _GCSL("NEXUS: globus_cond_init() failed\n"));
    return (rc);
}
/* globus_cond_init() */


/*
 *  globus_cond_destroy()
 */
#undef globus_cond_destroy
int
globus_cond_destroy(
    globus_cond_t *			cv)
{
    int rc;

    rc = globus_macro_cond_destroy(cv);
    globus_i_thread_test_rc(rc, _GCSL("NEXUS: globus_cond_destroy() failed\n"));
    return (rc);
}
/* globus_cond_destroy() */


/*
 *  globus_cond_wait()
 */
#undef globus_cond_wait
int
globus_cond_wait(
    globus_cond_t *			cv,
    globus_mutex_t *			mut)
{
    int rc;

    rc = globus_macro_cond_wait(cv, mut);
    globus_i_thread_test_rc(rc, _GCSL("NEXUS: globus_cond_wait() failed\n"));
    return (rc);
}
/* globus_cond_wait() */

/*
 *  globus_cond_timedwait()
 */
#undef globus_cond_timedwait
int
globus_cond_timedwait(
    globus_cond_t *			cv,
    globus_mutex_t *			mut,
    globus_abstime_t *                  abstime)
{
    int rc;

    rc = globus_macro_cond_timedwait(cv, mut, abstime);
    globus_i_thread_test_rc(rc, _GCSL("NEXUS: globus_cond_wait() failed\n"));
    return (rc);
}
/* globus_cond_timedwait() */


/*
 *  globus_cond_signal()
 */
#undef globus_cond_signal
int
globus_cond_signal(
    globus_cond_t *			cv)
{
    int rc;

    rc = globus_macro_cond_signal(cv);
    globus_i_thread_test_rc(rc, _GCSL("NEXUS: globus_cond_signal() failed\n"));
    return (rc);
}
/* globus_cond_signal () */


/*
 *  globus_cond_broadcast()
 */
#undef globus_cond_broadcast
int
globus_cond_broadcast(
    globus_cond_t *			cv)
{
    int rc;

    rc = globus_macro_cond_broadcast(cv);
    globus_i_thread_test_rc(rc, _GCSL("NEXUS: globus_cond_broadcast() failed\n"));
    return (rc);
}
/* globus_cond_broadcast() */

void
globus_thread_prefork(void)
{
}

void
globus_thread_postfork(void)
{
}

void
globus_i_thread_id(globus_thread_t *Thread_ID)
{
    *Thread_ID = 0;
}