diff options
author | Philip Wittamore <philip@wittamore.com> | 2025-06-08 22:00:43 +0200 |
---|---|---|
committer | Philip Wittamore <philip@wittamore.com> | 2025-06-08 22:00:43 +0200 |
commit | 81757c235ff8e112b4baabdd1ff23409426e9c98 (patch) | |
tree | ef213566ac3c17bf3d7795b0597f254791bd219e /include/util.h | |
download | dwmblocks-async-81757c235ff8e112b4baabdd1ff23409426e9c98.tar.gz dwmblocks-async-81757c235ff8e112b4baabdd1ff23409426e9c98.tar.bz2 dwmblocks-async-81757c235ff8e112b4baabdd1ff23409426e9c98.zip |
update
Diffstat (limited to 'include/util.h')
-rw-r--r-- | include/util.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/util.h b/include/util.h new file mode 100644 index 0000000..a3bdcce --- /dev/null +++ b/include/util.h @@ -0,0 +1,28 @@ +#ifndef UTIL_H +#define UTIL_H + +#include <stddef.h> + +#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) +#define MEMBER_SIZE(type, member) sizeof(((type*)NULL)->member) +#define MEMBER_LENGTH(type, member) \ + (MEMBER_SIZE(type, member) / MEMBER_SIZE(type, member[0])) +// NOLINTEND(bugprone-macro-parentheses) + +#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); + +#endif // UTIL_H |