This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 852d0d3925acf658dd96979bfbaef0dabb45e81b (commit) via 266c6d21983c196e2071c65d6b5d14d201d9392c (commit) from 983969d8fad548991c47cf81e7e013308fcf6a70 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/852d0d3925acf658dd96979bfbaef0dabb45e...
commit 852d0d3925acf658dd96979bfbaef0dabb45e81b Merge: 266c6d2 983969d Author: Tomas Gavenciak gavento@ucw.cz Date: Sun May 22 11:45:06 2011 +0200
Merge branch 'master' of git://repo.or.cz/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/266c6d21983c196e2071c65d6b5d14d201d93...
commit 266c6d21983c196e2071c65d6b5d14d201d9392c Author: Tomas Gavenciak gavento@ucw.cz Date: Sun May 22 11:41:36 2011 +0200
Unified ASSERT/ABORT/CHECK code, printf-like behaviour
diff --git a/core/GP_Common.h b/core/GP_Common.h index c6005f8..19cc9b9 100644 --- a/core/GP_Common.h +++ b/core/GP_Common.h @@ -65,40 +65,53 @@ /* * Aborts and prints the message along with the location in code * to stderr. Used for fatal errors. + * + * Use as either GP_ABORT(), GP_ABORT(msg) or GP_ABORT(format, params...) where + * msg and format must be string constants. */ -#define GP_ABORT(msg) do { - fprintf(stderr, "*** gfxprim: aborted: %s:%d: in %s: %sn", - __FILE__, __LINE__, __FUNCTION__, msg); +#define GP_ABORT(...) do { + fprintf(stderr, "*** gfxprim: %s:%d: in %s: ", + __FILE__, __LINE__, __FUNCTION__); + fprintf(stderr, "" __VA_ARGS__); + if (! (#__VA_ARGS__ [0])) + fprintf(stderr, "abort()"); + fprintf(stderr, "n"); abort(); } while (0)
/* + * Internal macro with common code for GP_ASSERT and GP_CHECK. + */ +#define GP_GENERAL_CHECK(check_cond_, check_message_, ...) do { + if (unlikely(!(check_cond_))) + if (#__VA_ARGS__ [0]) + GP_ABORT(check_message_ #check_cond_ "n" __VA_ARGS__); + else + GP_ABORT(check_message_ #check_cond_); +} while (0) + +/* * Checks the condition and aborts immediately if it is not satisfied, * printing the condition and location in the source. - * (Intended for checking for bugs within the library itself. - * GP_CHECK is used for reporting user errors, like invalid arguments.) + * (Intended for checking for bugs within the library itself.) + * + * Use as either GP_ASSERT(cond), GP_ASSERT(cond, msg) or + * GP_ASSERT(cond, format, params...) where msg and format must be string + * constants. */ -#define GP_ASSERT(cond) do { - if (unlikely(!(cond))) { - fprintf(stderr, "*** gfxprim: %s:%d: in %s: BUG: assertion failed: %sn", - __FILE__, __LINE__, __FUNCTION__, #cond); - abort(); - } -} while (0) +#define GP_ASSERT(check_cond_, ...) + GP_GENERAL_CHECK(check_cond_, "asserion failed: ", ##__VA_ARGS__);
/* * Perform a runtime check, on failure abort and print a message. - * (This macro is intended for checks for user-caused errors, - * like invalid arguments, leaving the library in improper state etc. - * For internal sanity checks, use GP_ASSERT.) + * (Intended for user-caused errors like invalid arguments.) + * + * Use as either GP_CHECK(cond), GP_CHECK(cond, msg) or + * GP_CHECK(cond, format, params...) where msg and format must be string + * constants. */ -#define GP_CHECK(cond, msg) do { - if (unlikely(!(cond))) { - fprintf(stderr, "*** gfxprim: %s:%d: in %s: %sn", - __FILE__, __LINE__, __FUNCTION__, msg); - abort(); - } -} while (0) +#define GP_CHECK(check_cond_, ...) + GP_GENERAL_CHECK(check_cond_, "check failed: ", ##__VA_ARGS__);
/* * Swap a and b using an intermediate variable
-----------------------------------------------------------------------
Summary of changes: core/GP_Common.h | 57 +++++++++++++++++++++++++++++++++-------------------- 1 files changed, 35 insertions(+), 22 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.