#include <stdint.h>
-#include <stdio.h>
-#include <stdarg.h>
#include <unistd.h>
/* TODO: not thread-safe nor fork-safe */
-static volatile int t_status;
+extern volatile int t_status;
#define T_LOC2(l) __FILE__ ":" #l
#define T_LOC1(l) T_LOC2(l)
-#define t_error(...) t_printf("ERROR " T_LOC1(__LINE__) ": " __VA_ARGS__)
-
-static int t_printf(const char *s, ...)
-{
- va_list ap;
- char buf[512];
- int n;
-
- t_status = 1;
- va_start(ap, s);
- n = vsnprintf(buf, sizeof buf, s, ap);
- va_end(ap);
- if (n < 0)
- n = 0;
- else if (n >= sizeof buf) {
- n = sizeof buf;
- buf[n - 1] = '\n';
- buf[n - 2] = '.';
- buf[n - 3] = '.';
- buf[n - 4] = '.';
- }
- return write(1, buf, n);
-}
+#define t_error(...) t_printf(T_LOC1(__LINE__) ": " __VA_ARGS__)
+
+int t_printf(const char *s, ...);
int t_vmfill(void **, size_t *, int);
+int t_memfill(void);
void t_fdfill(void);
char *t_pathrel(char *buf, size_t n, char *argv0, char *p);
+int t_setrlim(int r, long lim);
+