ROFL-pipeline  v0.6.0dev
lock.h
Go to the documentation of this file.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef __PLATFORM_LOCK_H__
6 #define __PLATFORM_LOCK_H__
7 
8 #include "rofl.h"
9 
29 typedef void platform_mutex_t;
30 typedef void platform_rwlock_t;
31 
32 #if defined(__COMPILING_ROFL_PIPELINE__) || !defined(ROFL_PIPELINE_PP_PRESENT) || !defined(ROFL_PIPELINE_INLINE_PP_PLATFORM_FUNCS)
33 
34 //C++ extern C
35 ROFL_BEGIN_DECLS
36 
37 /* MUTEX operations */
38 
47 platform_mutex_t* platform_mutex_init(void* params);
48 
58 void platform_mutex_destroy(platform_mutex_t* mutex);
59 
60 //Operations
68 void platform_mutex_lock(platform_mutex_t* mutex);
69 
77 void platform_mutex_unlock(platform_mutex_t* mutex);
78 
79 /* RWLOCK */
80 //Init&destroy
81 
90 platform_rwlock_t* platform_rwlock_init(void* params);
91 
101 void platform_rwlock_destroy(platform_rwlock_t* rwlock);
102 
103 //Read
111 void platform_rwlock_rdlock(platform_rwlock_t* rwlock);
112 
120 void platform_rwlock_rdunlock(platform_rwlock_t* rwlock);
121 
122 //Write
130 void platform_rwlock_wrlock(platform_rwlock_t* rwlock);
131 
139 void platform_rwlock_wrunlock(platform_rwlock_t* rwlock);
140 
141 //C++ extern C
142 ROFL_END_DECLS
143 
144 #endif //if
145 #endif //PLATFORM_LOCK
void platform_rwlock_rdlock(platform_rwlock_t *rwlock)
Performs a read-lock over the platform_rwlock_t mutex platform_mutex_init().
void platform_mutex_lock(platform_mutex_t *mutex)
Locks the platform_mutex_t mutex.
void platform_rwlock_rdunlock(platform_rwlock_t *rwlock)
Performs a read-unlock over the platform_rwlock_t mutex platform_mutex_init().
void platform_mutex_unlock(platform_mutex_t *mutex)
Unlocks the platform_mutex_t mutex.
void platform_rwlock_wrlock(platform_rwlock_t *rwlock)
Performs a write-lock over the platform_rwlock_t mutex platform_mutex_init().
ROFL_BEGIN_DECLS platform_mutex_t * platform_mutex_init(void *params)
Allocates and initializes a mutex.
void platform_rwlock_wrunlock(platform_rwlock_t *rwlock)
Performs a write-unlock over the platform_rwlock_t mutex platform_mutex_init().
platform_rwlock_t * platform_rwlock_init(void *params)
Allocates and initializes a rwlock.
void platform_rwlock_destroy(platform_rwlock_t *rwlock)
Destroys and deallocates a rwlock previously inited by platform_rwlock_init().
void platform_mutex_destroy(platform_mutex_t *mutex)
Destroys and deallocates a mutex previously inited by platform_mutex_init().