Formatted all code using indent
This commit is contained in:
@@ -17,72 +17,75 @@ char *log_context = "";
|
||||
|
||||
void error_init(void)
|
||||
{
|
||||
pthread_key_create(&cleanup_handler_key, free);
|
||||
pthread_key_create(&cleanup_handler_key, free);
|
||||
}
|
||||
|
||||
void error_handler(int fatal)
|
||||
{
|
||||
DECLARE_ERROR_CONTEXT(context);
|
||||
DECLARE_ERROR_CONTEXT(context);
|
||||
|
||||
if (context) {
|
||||
longjmp(context->jmp, fatal ? 1 : 2 );
|
||||
}
|
||||
else {
|
||||
if ( fatal ) { abort(); }
|
||||
else { pthread_exit((void*) 1); }
|
||||
if (context) {
|
||||
longjmp(context->jmp, fatal ? 1 : 2);
|
||||
} else {
|
||||
if (fatal) {
|
||||
abort();
|
||||
} else {
|
||||
pthread_exit((void *) 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void exit_err( const char *msg )
|
||||
void exit_err(const char *msg)
|
||||
{
|
||||
fprintf( stderr, "%s\n", msg );
|
||||
exit( 1 );
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
void mylog(int line_level, const char* format, ...)
|
||||
void mylog(int line_level, const char *format, ...)
|
||||
{
|
||||
if (line_level < log_level) { return; }
|
||||
if (line_level < log_level) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_list argptr;
|
||||
va_list argptr;
|
||||
|
||||
va_start(argptr, format);
|
||||
vfprintf(stderr, format, argptr);
|
||||
va_end(argptr);
|
||||
va_start(argptr, format);
|
||||
vfprintf(stderr, format, argptr);
|
||||
va_end(argptr);
|
||||
}
|
||||
|
||||
uint64_t monotonic_time_ms()
|
||||
{
|
||||
struct timespec ts;
|
||||
uint64_t seconds_ms, nanoseconds_ms;
|
||||
struct timespec ts;
|
||||
uint64_t seconds_ms, nanoseconds_ms;
|
||||
|
||||
FATAL_IF_NEGATIVE(
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts),
|
||||
SHOW_ERRNO( "clock_gettime failed" )
|
||||
FATAL_IF_NEGATIVE(clock_gettime(CLOCK_MONOTONIC, &ts),
|
||||
SHOW_ERRNO("clock_gettime failed")
|
||||
);
|
||||
|
||||
seconds_ms = ts.tv_sec;
|
||||
seconds_ms = seconds_ms * 1000;
|
||||
seconds_ms = ts.tv_sec;
|
||||
seconds_ms = seconds_ms * 1000;
|
||||
|
||||
nanoseconds_ms = ts.tv_nsec;
|
||||
nanoseconds_ms = nanoseconds_ms / 1000000;
|
||||
nanoseconds_ms = ts.tv_nsec;
|
||||
nanoseconds_ms = nanoseconds_ms / 1000000;
|
||||
|
||||
return seconds_ms + nanoseconds_ms;
|
||||
return seconds_ms + nanoseconds_ms;
|
||||
}
|
||||
|
||||
|
||||
void* xrealloc(void* ptr, size_t size)
|
||||
void *xrealloc(void *ptr, size_t size)
|
||||
{
|
||||
void* p = realloc(ptr, size);
|
||||
FATAL_IF_NULL(p, "couldn't xrealloc %d bytes", ptr ? "realloc" : "malloc", size);
|
||||
return p;
|
||||
void *p = realloc(ptr, size);
|
||||
FATAL_IF_NULL(p, "couldn't xrealloc %d bytes",
|
||||
ptr ? "realloc" : "malloc", size);
|
||||
return p;
|
||||
}
|
||||
|
||||
void* xmalloc(size_t size)
|
||||
void *xmalloc(size_t size)
|
||||
{
|
||||
void* p = xrealloc(NULL, size);
|
||||
memset(p, 0, size);
|
||||
return p;
|
||||
void *p = xrealloc(NULL, size);
|
||||
memset(p, 0, size);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user