You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.8 KiB

8 years ago
#pragma once
#include <assert.h>
#include <stdio.h>
7 years ago
#include <stdlib.h>
8 years ago
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
7 years ago
#define UNIMPLEMENTED() \
do { \
8 years ago
eprintf("UNIMPLEMENTED: %s @ %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
7 years ago
abort(); \
} while (0)
8 years ago
#define UNIMPLEMENTED_UNLESS(x) \
do { \
if (!(x)) \
UNIMPLEMENTED(); \
} while (0)
7 years ago
#define ABORT() \
do { \
eprintf("ABORT: %s @ %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
7 years ago
abort(); \
} while (0)
7 years ago
#define DUMMY() eprintf("DUMMY: %s @ %s:%d\n", __FUNCTION__, __FILE__, __LINE__)
8 years ago
7 years ago
#define DUMMY_ONCE() \
do { \
8 years ago
static bool dummy_shown = false; \
7 years ago
if (!dummy_shown) { \
DUMMY(); \
dummy_shown = true; \
} \
} while (0)
8 years ago
7 years ago
#define DUMMY_PRINT(fmt, ...) eprintf("DUMMY: %s : " fmt "\n", __FUNCTION__, ##__VA_ARGS__)
8 years ago
static inline const char *nullstr(const char *a)
{
return a ? a : "(null)";
}
#define ASSERT(x) \
if (!(x)) { \
fprintf(stderr, "Assertion failed in %s:%d: %s\n", __FILE__, __LINE__, #x); \
abort(); \
}