File: mutex.h

package info (click to toggle)
twin 0.4.0-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,804 kB
  • ctags: 23,904
  • sloc: ansic: 61,860; cpp: 1,023; makefile: 777; sh: 552; lex: 302; yacc: 231
file content (46 lines) | stat: -rw-r--r-- 1,288 bytes parent folder | download | duplicates (2)
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
/*
 *  mutex.h  --  mutex locking functions for libTw
 *
 *  Copyright (C) 2001 by Massimiliano Ghilardi
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 */

#ifndef _TWIN_MUTEX_H
#define _TWIN_MUTEX_H


#ifdef CONF_SOCKET_PTHREADS

# define tw_self                 pthread_t
# define tw_mutex                pthread_mutex_t
# define TW_MUTEX_INITIALIZER    PTHREAD_MUTEX_INITIALIZER
# define tw_self_get()	         pthread_self()
# define tw_mutex_init(mutex)    pthread_mutex_init(&(mutex), NULL)
# define tw_mutex_lock(mutex)    pthread_mutex_lock(&(mutex))
# define tw_mutex_unlock(mutex)  pthread_mutex_unlock(&(mutex))
# define tw_mutex_destroy(mutex) pthread_mutex_destroy(&(mutex))

#else /* !CONF_SOCKET_PTHREADS */


# undef  tw_self
# undef  tw_mutex

# define tw_self_get()	         (0)
# define tw_mutex_init(mutex)    do { } while (0)
# define tw_mutex_lock(mutex)    do { } while (0)
# define tw_mutex_unlock(mutex)  do { } while (0)
# define tw_mutex_destroy(mutex) do { } while (0)


#endif /* CONF_SOCKET_PTHREADS */



#endif /* _TWIN_MUTEX_H */