Cleanup: remove private babeltrace.h
[babeltrace.git] / src / common / safe.h
1
2 #include <stdbool.h>
3 #include <stdint.h>
4
5 static inline
6 bool bt_safe_to_mul_int64(int64_t a, int64_t b)
7 {
8 if (a == 0 || b == 0) {
9 return true;
10 }
11
12 return a < INT64_MAX / b;
13 }
14
15 static inline
16 bool bt_safe_to_mul_uint64(uint64_t a, uint64_t b)
17 {
18 if (a == 0 || b == 0) {
19 return true;
20 }
21
22 return a < UINT64_MAX / b;
23 }
24
25 static inline
26 bool bt_safe_to_add_int64(int64_t a, int64_t b)
27 {
28 return a <= INT64_MAX - b;
29 }
30
31 static inline
32 bool bt_safe_to_add_uint64(uint64_t a, uint64_t b)
33 {
34 return a <= UINT64_MAX - b;
35 }
This page took 0.028983 seconds and 4 git commands to generate.