write a DEBUG macro and change the render_threads stuff to use it. Shuffle the mutexes in render_threads around again to fix yet another bug... seems to work, but meh
committer: Tero Marttila <terom@fixme.fi>
/*
* error handling
*/
void _generic_err ( /*int level, */ const char *func, int perr, const char *fmt, ...)
__attribute__ ((format (printf, 3, 4)));
// needs to be defined as its own function for the noreturn attribute
void _generic_err_exit ( /* int level, */ const char *func, int perr, const char *fmt, ...)
__attribute__ ((format (printf, 3, 4)))
__attribute__ ((noreturn));
/*
enum _debug_level {
DEBUG_FATAL,
DEBUG_ERROR,
DEBUG_WARNING,
DEBUG_INFO,
DEBUG_DEBUG,
};
extern enum _debug_level _cur_debug_level;
*/
// various kinds of ways to handle an error, 2**3 of them, *g*
#define error(...) _generic_err( NULL, 0, __VA_ARGS__)
#define err_exit(...) _generic_err_exit( NULL, 0, __VA_ARGS__)
#define perr(...) _generic_err( NULL, 1, __VA_ARGS__)
#define perr_exit(...) _generic_err_exit( NULL, 1, __VA_ARGS__)
#define err_func(func, ...) _generic_err( func, 0, __VA_ARGS__)
#define err_func_exit(func, ...) _generic_err_exit( func, 0, __VA_ARGS__)
#define perr_func(func, ...) _generic_err( func, 1, __VA_ARGS__)
#define perr_func_exit(func, ...) _generic_err_exit( func, 1, __VA_ARGS__)
// error(func + colon + msg, ...) + goto error
#define ERROR(...) do { err_func(__func__, __VA_ARGS__); goto error; } while (0)
#define PERROR(...) do { perr_func(__func__, __VA_ARGS__); goto error; } while (0)
#define FATAL(...) err_func_exit(__func__, __VA_ARGS__)
#define PFATAL(...) perr_func_exit(__func__, __VA_ARGS__)
#define WARNING(...) err_func(__func__, __VA_ARGS__)
#define PWARNING(...) perr_func(__func__, __VA_ARGS__)
#ifdef DEBUG_ENABLED
#define DEBUG(...) err_func(__func__, __VA_ARGS__)
#else
#define DEBUG(...) if (0) { }
#endif
/*
* Parse a host:port string.
*
* Valid formats:
* host
* host:port
* [host]
* [host]:port
*
* The contents of the given hostport string *will* be modified.
*
* The value of *port will be set to NULL if no port was given.
*
* Returns 0 and sets *host if succesfull, nonzero otherwise.
*
*/
int parse_hostport (char *hostport, char **host, char **port);