1 #include <stdint.h> 2 #include <unistd.h> 3 4 /* TODO: not thread-safe nor fork-safe */ 5 extern volatile int t_status; 6 7 #define T_LOC2(l) __FILE__ ":" #l 8 #define T_LOC1(l) T_LOC2(l) 9 #define t_error(...) t_printf(T_LOC1(__LINE__) ": " __VA_ARGS__) 10 11 int t_printf(const char *s, ...); 12 13 int t_vmfill(void **, size_t *, int); 14 int t_memfill(void); 15 16 void t_fdfill(void); 17 18 void t_randseed(uint64_t s); 19 uint64_t t_randn(uint64_t n); 20 uint64_t t_randint(uint64_t a, uint64_t b); 21 void t_shuffle(uint64_t *p, size_t n); 22 void t_randrange(uint64_t *p, size_t n); 23 int t_choose(uint64_t n, size_t k, uint64_t *p); 24 25 char *t_pathrel(char *buf, size_t n, char *argv0, char *p); 26 27 int t_setrlim(int r, long lim); 28 29 int t_setutf8(void); 30