diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2013-02-01 17:50:04 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2013-02-01 17:50:04 -0300 |
commit | e1d25de35a2b1f809e8f8d7b182ce0af004f3ec9 (patch) | |
tree | 9edcd271d7553ad4fbda2f15ec06dda4f21815cc /src/include/postgres.h | |
parent | dd1569da67937b819d1589a9f664af9aa9657945 (diff) | |
download | postgresql-e1d25de35a2b1f809e8f8d7b182ce0af004f3ec9.tar.gz postgresql-e1d25de35a2b1f809e8f8d7b182ce0af004f3ec9.zip |
Move Assert() definitions to c.h
This way, they can be used by frontend and backend code. We already
supported that, but doing it this way allows us to mix true frontend
files with backend files compiled in frontend environment.
Author: Andres Freund
Diffstat (limited to 'src/include/postgres.h')
-rw-r--r-- | src/include/postgres.h | 54 |
1 files changed, 2 insertions, 52 deletions
diff --git a/src/include/postgres.h b/src/include/postgres.h index 8ff107a7b3f..207f7b8ffb2 100644 --- a/src/include/postgres.h +++ b/src/include/postgres.h @@ -25,7 +25,7 @@ * ------- ------------------------------------------------ * 1) variable-length datatypes (TOAST support) * 2) datum type + support macros - * 3) exception handling definitions + * 3) exception handling backend support * * NOTES * @@ -634,62 +634,12 @@ extern Datum Float8GetDatum(float8 X); /* ---------------------------------------------------------------- - * Section 3: exception handling definitions - * Assert, Trap, etc macros + * Section 3: exception handling backend support * ---------------------------------------------------------------- */ extern PGDLLIMPORT bool assert_enabled; -/* - * USE_ASSERT_CHECKING, if defined, turns on all the assertions. - * - plai 9/5/90 - * - * It should _NOT_ be defined in releases or in benchmark copies - */ - -/* - * Trap - * Generates an exception if the given condition is true. - */ -#define Trap(condition, errorType) \ - do { \ - if ((assert_enabled) && (condition)) \ - ExceptionalCondition(CppAsString(condition), (errorType), \ - __FILE__, __LINE__); \ - } while (0) - -/* - * TrapMacro is the same as Trap but it's intended for use in macros: - * - * #define foo(x) (AssertMacro(x != 0), bar(x)) - * - * Isn't CPP fun? - */ -#define TrapMacro(condition, errorType) \ - ((bool) ((! assert_enabled) || ! (condition) || \ - (ExceptionalCondition(CppAsString(condition), (errorType), \ - __FILE__, __LINE__), 0))) - -#ifndef USE_ASSERT_CHECKING -#define Assert(condition) -#define AssertMacro(condition) ((void)true) -#define AssertArg(condition) -#define AssertState(condition) -#else -#define Assert(condition) \ - Trap(!(condition), "FailedAssertion") - -#define AssertMacro(condition) \ - ((void) TrapMacro(!(condition), "FailedAssertion")) - -#define AssertArg(condition) \ - Trap(!(condition), "BadArgument") - -#define AssertState(condition) \ - Trap(!(condition), "BadState") -#endif /* USE_ASSERT_CHECKING */ - extern void ExceptionalCondition(const char *conditionName, const char *errorType, const char *fileName, int lineNumber) __attribute__((noreturn)); |