1/*
2 * Copyright (c) 2014 ETH Zurich.
3 * All rights reserved.
4 *
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
8 */
9
10#ifndef BOMP_MUTEX_H
11#define BOMP_MUTEX_H
12
13#ifdef BARRELFISH
14#include <barrelfish/threads.h>
15#include <barrelfish/thread_sync.h>
16typedef struct thread_mutex bomp_mutex_t;
17
18static inline void bomp_mutex_init (bomp_mutex_t *mutex)
19{
20    thread_mutex_init(mutex);
21}
22
23static inline void bomp_mutex_lock (bomp_mutex_t *mutex)
24{
25    thread_mutex_lock (mutex);
26}
27
28static inline void bomp_mutex_unlock (bomp_mutex_t *mutex)
29{
30    thread_mutex_unlock (mutex);
31}
32
33static inline void bomp_mutex_destroy (bomp_mutex_t *mutex)
34{
35    /* nop */
36}
37#else
38/* LINUX */
39
40typedef pthread_mutex_t bomp_mutex_t;
41
42static inline void bomp_mutex_init (bomp_mutex_t *mutex)
43{
44    pthread_mutex_init (mutex, NULL);
45}
46
47static inline void bomp_mutex_lock (bomp_mutex_t *mutex)
48{
49    pthread_mutex_lock (mutex);
50}
51
52static inline void bomp_mutex_unlock (bomp_mutex_t *mutex)
53{
54    pthread_mutex_unlock (mutex);
55}
56
57static inline void bomp_mutex_destroy (bomp_mutex_t *mutex)
58{
59    pthread_mutex_destroy (mutex);
60}
61
62#endif
63
64#endif /* BOMP_MUTEX_H */
65