Mercurial > audlegacy
diff audacious/debug.h @ 0:cb178e5ad177 trunk
[svn] Import audacious source.
author | nenolod |
---|---|
date | Mon, 24 Oct 2005 03:06:47 -0700 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/audacious/debug.h Mon Oct 24 03:06:47 2005 -0700 @@ -0,0 +1,44 @@ +#ifndef DEBUG_H +#define DEBUG_H + +#include <glib.h> + +#ifdef NDEBUG + +/* void REQUIRE_LOCK(GMutex *m); */ +# define REQUIRE_LOCK(m) + +/* void REQUIRE_STR_UTF8(const gchar *str); */ +# define REQUIRE_STR_UTF8(str) + +/* void REQUIRE_STATIC_LOCK(GStaticMutex *m); */ +# define REQUIRE_STATIC_LOCK(m) + +#else /* !NDEBUG */ + +/* void REQUIRE_LOCK(GMutex *m); */ +# define REQUIRE_LOCK(m) G_STMT_START { \ + if (g_mutex_trylock(m)) { \ + g_critical(G_STRLOC ": Mutex not locked!"); \ + g_mutex_unlock(m); \ + } \ + } G_STMT_END + +/* void REQUIRE_STATIC_LOCK(GStaticMutex *m); */ +# define REQUIRE_STATIC_LOCK(m) G_STMT_START { \ + if (G_TRYLOCK(m)) { \ + g_critical(G_STRLOC ": Mutex not locked!"); \ + G_UNLOCK(m); \ + } \ + } G_STMT_END + +/* void REQUIRE_STR_UTF8(const gchar *str); */ +# define REQUIRE_STR_UTF8(str) G_STMT_START { \ + if (!g_utf_validate(str, -1, NULL)) \ + g_warning(G_STRLOC ": String is not UTF-8!"); \ + } G_STMT_END + +#endif /* NDEBUG */ + + +#endif