2023-02-12 09:34:44 +01:00
|
|
|
#ifndef _UTIL_H
|
|
|
|
|
#define _UTIL_H
|
|
|
|
|
|
2023-03-12 13:43:30 +01:00
|
|
|
#include <stdio.h>
|
2023-02-15 02:15:44 +01:00
|
|
|
|
|
|
|
|
|
2023-02-12 09:34:44 +01:00
|
|
|
void * emalloc(unsigned long int size);
|
|
|
|
|
void * ecalloc(unsigned long int nmemb, unsigned long int size);
|
2023-03-04 18:54:00 +01:00
|
|
|
void * erealloc(void *ptr, unsigned long int size);
|
2023-02-12 09:34:44 +01:00
|
|
|
void efree(void *ptr);
|
|
|
|
|
|
|
|
|
|
void map_file(const unsigned char **str, int *size, const char *path);
|
2023-02-19 23:40:58 +01:00
|
|
|
void dump_file(const char *path, char **buf, int *buf_len);
|
2023-02-12 09:34:44 +01:00
|
|
|
|
|
|
|
|
void print_byte(unsigned char byte);
|
|
|
|
|
|
2023-03-12 00:28:38 +01:00
|
|
|
void stopwatch_start(void);
|
|
|
|
|
double stopwatch_get(void);
|
|
|
|
|
|
2023-03-12 13:43:30 +01:00
|
|
|
#define TIME_SEC(f) \
|
|
|
|
|
{ \
|
|
|
|
|
stopwatch_start(); \
|
|
|
|
|
f; \
|
|
|
|
|
printf("\"%s\" took %f seconds", #f, stopwatch_get()); \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define TIME_MS(f) \
|
|
|
|
|
{ \
|
|
|
|
|
stopwatch_start(); \
|
|
|
|
|
f; \
|
|
|
|
|
printf("\"%s\" took %f ms", #f, stopwatch_get()*1000.0f); \
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-12 09:34:44 +01:00
|
|
|
#endif
|