File: sysdep.h

package info (click to toggle)
dcap 2.47.8-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,388 kB
  • ctags: 1,474
  • sloc: ansic: 14,235; makefile: 395; python: 75; sh: 58
file content (66 lines) | stat: -rw-r--r-- 1,571 bytes parent folder | download | duplicates (7)
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
/*
 *   DCAP - dCache Access Protocol client interface
 *
 *   Copyright (C) 2000,2004 DESY Hamburg DMG-Division.
 *
 *   AUTHOR: Tigran Mkrtchayn (tigran.mkrtchyan@desy.de)
 *
 *   This program can be distributed under the terms of the GNU LGPL.
 *   See the file COPYING.LIB
 *
 */


/*
 * $Id: sysdep.h,v 1.11 2004-11-01 19:33:30 tigran Exp $
 */
#ifndef SYS_DEP_H
#define SYS_DEP_H

#ifndef NOT_THREAD_SAFE

#include <pthread.h>

#define MUTEX(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER
#define COND(x)  pthread_cond_t  x = PTHREAD_COND_INITIALIZER
#define RDLOCK(x) pthread_rwlock_t x = PTHREAD_RWLOCK_INITIALIZER
#define TKEY pthread_key_t

#define m_init(x) pthread_mutex_init(x,  NULL)
#define m_lock(x) pthread_mutex_lock(x)
#define m_unlock(x) pthread_mutex_unlock(x)
#define m_trylock(x) pthread_mutex_trylock(x)

#define c_wait(a,b) pthread_cond_wait(a,b)
#define c_broadcast(x) pthread_cond_broadcast(x)

#define t_keycreate(a,b) pthread_key_create(a,b)
#define t_setspecific(a,b) pthread_setspecific(a,b)
#define t_getspecific(a,b)  *b = pthread_getspecific(a)


#define rw_wrlock(x) pthread_rwlock_wrlock(x)
#define rw_rdlock(x) pthread_rwlock_rdlock(x)
#define rw_unlock(x) pthread_rwlock_unlock(x)

#else /* NOT_THREAD_SAFE */

#define MUTEX(x) int x
#define COND(x)  int x
#define RDLOCK(x) int x

#define m_init(x) {}
#define m_lock(x) {}
#define m_unlock(x) {}
#define m_trylock(x) 0

#define c_wait(a,b) {}
#define c_broadcast(x) {}


#define rw_wrlock(x) {}
#define rw_rdlock(x) {}
#define rw_unlock(x) {}

#endif /* NOT_THREAD_SAFE */
#endif