jsfw/util.h

19 lines
550 B
C
Raw Normal View History

2022-08-30 17:54:56 -05:00
// vi:ft=c
#ifndef UTIL_H_
#define UTIL_H_
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
2022-08-29 17:27:03 -05:00
// Print a formatted message and exit with code 1
void panicf(const char *fmt, ...);
uint16_t parse_port(const char *str);
// Test if the bit with index i is set in the byte array bits
static inline bool bit_set(uint8_t *bits, int i) { return bits[i / 8] & (1 << (i % 8)); }
// Align n to the next 8 boundary
static inline size_t align_8(size_t n) { return (((n - 1) >> 3) + 1) << 3; }
uint8_t parse_hex_digit(char h);
2022-08-29 17:27:03 -05:00
#endif