XROAD
xroad_aux.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include "xroad_common_fwd.h"
9 #include <stdint.h>
10 #include <stdbool.h>
11 #include <sched.h>
12 
13 #ifdef __cplusplus
14 extern "C"
15 {
16 #endif
17 
18 #define xroad_likely(x) __builtin_expect(!!(x), 1)
19 #define xroad_unlikely(x) __builtin_expect(!!(x), 0)
20 
21 #define xroad_cpu_pause() __asm__ volatile("pause\n": : :"memory")
22 #define xroad_fence() __asm__ volatile("mfence": : :"memory")
23 
24 #define __dtor__(fun) __attribute__((__cleanup__(fun)))
25 
26 #define __free_dtor__ __dtor__(free_destructor)
27 void free_destructor(void*);
28 
32 #define xroad_min(a, b) \
33 ({ __typeof__ (a) _a = (a); \
34  __typeof__ (b) _b = (b); \
35  _a < _b ? _a : _b; \
36 })
37 
41 #define xroad_max(a, b) \
42 ({ __typeof__ (a) _a = (a); \
43  __typeof__ (b) _b = (b); \
44  _a > _b ? _a : _b; \
45 })
46 
51 #define xroad_dbl_cmp(lhs, rhs) \
52 ({ \
53  __typeof__(lhs) lhs1977_ = (lhs); \
54  __typeof__(rhs) rhs1977_ = (rhs); \
55  (fabs(lhs1977_ - rhs1977_) < XROAD_EPSILON) ? 0 : \
56  (lhs1977_ < rhs1977_ ? -1 : 1); \
57 })
58 
65 
72 bool xroad_set_cpu_set(xroad_str_t cpus, cpu_set_t* cpu_set);
73 
74 #ifdef __cplusplus
75 }
76 #endif
Definition: xroad_string.h:29
bool xroad_set_cpu_set(xroad_str_t cpus, cpu_set_t *cpu_set)
xroad_str_t xroad_strerror(int32_t err)