1 #ifndef SSB_SPROMTOOL_UTILS_H_
2 #define SSB_SPROMTOOL_UTILS_H_
8 #define ssb_stringify_1(x) #x
9 #define ssb_stringify(x) ssb_stringify_1(x)
11 #ifdef ATTRIBUTE_FORMAT
12 # undef ATTRIBUTE_FORMAT
15 # define ATTRIBUTE_FORMAT(t, a, b) __attribute__((format(t, a, b)))
17 # define ATTRIBUTE_FORMAT(t, a, b) /* nothing */
20 int prinfo(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
21 int prerror(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
22 int prdata(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
24 void internal_error(const char *message);
25 #define internal_error_on(condition) \
28 internal_error(ssb_stringify(condition)); \
31 void * malloce(size_t size);
32 void * realloce(void *ptr, size_t newsize);
34 /* CRC-8 with polynomial x^8+x^7+x^6+x^4+x^2+1 */
35 uint8_t crc8(uint8_t crc, uint8_t data);
37 #endif /* SSB_SPROMTOOL_UTILS_H_ */