2023-11-16 04:38:29 +01:00
|
|
|
#ifndef UTIL_H
|
|
|
|
#define UTIL_H
|
2023-10-24 05:14:31 +02:00
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2023-11-16 04:38:29 +01:00
|
|
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
|
|
#define LEN(arr) (sizeof(arr) / sizeof((arr)[0]))
|
|
|
|
#define BIT(n) (1 << (n))
|
|
|
|
|
|
|
|
// NOLINTBEGIN(bugprone-macro-parentheses)
|
2023-10-24 05:14:31 +02:00
|
|
|
#define MEMBER_SIZE(type, member) sizeof(((type*)NULL)->member)
|
|
|
|
#define MEMBER_LENGTH(type, member) \
|
|
|
|
(MEMBER_SIZE(type, member) / MEMBER_SIZE(type, member[0]))
|
2023-11-16 04:38:29 +01:00
|
|
|
// NOLINTEND(bugprone-macro-parentheses)
|
2023-10-24 05:14:31 +02:00
|
|
|
|
|
|
|
#define UTF8_MAX_BYTE_COUNT 4
|
|
|
|
|
|
|
|
enum pipe_fd_index {
|
|
|
|
READ_END,
|
|
|
|
WRITE_END,
|
|
|
|
PIPE_FD_COUNT,
|
|
|
|
};
|
|
|
|
|
|
|
|
unsigned int gcd(unsigned int a, unsigned int b);
|
|
|
|
size_t truncate_utf8_string(char* const buffer, const size_t size,
|
|
|
|
const size_t char_limit);
|
2023-11-16 04:38:29 +01:00
|
|
|
|
|
|
|
#endif // UTIL_H
|