diff options
Diffstat (limited to 'toxcore/util.h')
-rw-r--r-- | toxcore/util.h | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/toxcore/util.h b/toxcore/util.h index 955ce8c4..7cd6bb8b 100644 --- a/toxcore/util.h +++ b/toxcore/util.h | |||
@@ -27,8 +27,9 @@ | |||
27 | 27 | ||
28 | #include <stdbool.h> | 28 | #include <stdbool.h> |
29 | #include <stdint.h> | 29 | #include <stdint.h> |
30 | #include <pthread.h> | ||
30 | 31 | ||
31 | #define inline__ inline __attribute__((always_inline)) | 32 | #define MIN(a,b) (((a)<(b))?(a):(b)) |
32 | 33 | ||
33 | void unix_time_update(); | 34 | void unix_time_update(); |
34 | uint64_t unix_time(); | 35 | uint64_t unix_time(); |
@@ -42,22 +43,16 @@ uint32_t id_copy(uint8_t *dest, const uint8_t *src); /* return value is CLIENT_I | |||
42 | void host_to_net(uint8_t *num, uint16_t numbytes); | 43 | void host_to_net(uint8_t *num, uint16_t numbytes); |
43 | #define net_to_host(x, y) host_to_net(x, y) | 44 | #define net_to_host(x, y) host_to_net(x, y) |
44 | 45 | ||
46 | uint16_t lendian_to_host16(uint16_t lendian); | ||
47 | #define host_tolendian16(x) lendian_to_host16(x) | ||
48 | |||
49 | void host_to_lendian32(uint8_t *dest, uint32_t num); | ||
50 | |||
45 | /* state load/save */ | 51 | /* state load/save */ |
46 | typedef int (*load_state_callback_func)(void *outer, const uint8_t *data, uint32_t len, uint16_t type); | 52 | typedef int (*load_state_callback_func)(void *outer, const uint8_t *data, uint32_t len, uint16_t type); |
47 | int load_state(load_state_callback_func load_state_callback, void *outer, | 53 | int load_state(load_state_callback_func load_state_callback, void *outer, |
48 | const uint8_t *data, uint32_t length, uint16_t cookie_inner); | 54 | const uint8_t *data, uint32_t length, uint16_t cookie_inner); |
49 | 55 | ||
50 | /* Converts 4 bytes to uint32_t */ | 56 | int create_recursive_mutex(pthread_mutex_t *mutex); |
51 | void bytes_to_U32(uint32_t *dest, const uint8_t *bytes); | ||
52 | |||
53 | /* Converts 2 bytes to uint16_t */ | ||
54 | void bytes_to_U16(uint16_t *dest, const uint8_t *bytes); | ||
55 | |||
56 | /* Convert uint32_t to byte string of size 4 */ | ||
57 | void U32_to_bytes(uint8_t *dest, uint32_t value); | ||
58 | |||
59 | /* Convert uint16_t to byte string of size 2 */ | ||
60 | void U16_to_bytes(uint8_t *dest, uint16_t value); | ||
61 | |||
62 | 57 | ||
63 | #endif /* __UTIL_H__ */ | 58 | #endif /* __UTIL_H__ */ |