XROAD
xroad_lock.h
Go to the documentation of this file.
1 #pragma once
7 #include <stdint.h>
8 #include <stdbool.h>
9 
10 typedef union
11 {
12  int64_t full;
13  int16_t state;
14  struct {
15  int8_t version;
16  int8_t users;
17  int8_t r_depth;
18  int8_t pad;
19  int32_t pid;
20  };
21 } xroad_lock_t;
22 
23 /*
24  * @brief agressively acuires lock
25  * @param[in] l - lock
26  */
27 void xroad_lock_lock(xroad_lock_t* l);
28 
29 /*
30  * @brief releases lock
31  * @param[in] l - lock
32  * @return true - unlocked, else still locked
33  */
34 bool xroad_lock_unlock(xroad_lock_t* l);
35 
36 /*
37  * @brief resets lock
38  * @param[in] l - lock
39  */
40 void xroad_lock_reset(xroad_lock_t* l);
41 
42 /*
43  * @brief releases lock
44  * @param[in] l_ptr - pointer to lock
45  */
46 #define __xroad_lock_unlock_dtor__ __attribute__((__cleanup__(xroad_lock_unlock_dtor)))
47 void xroad_lock_unlock_dtor(xroad_lock_t** l_ptr);
48 
49 int32_t xroad_lock_get_version(xroad_lock_t* l);
50 
51 int32_t xroad_lock_get_pid(xroad_lock_t* l);
52 
53 int32_t xroad_lock_number_lock(xroad_lock_t* l);
Definition: xroad_lock.h:11