summaryrefslogtreecommitdiff
path: root/gs/base/gserrors.h
diff options
context:
space:
mode:
Diffstat (limited to 'gs/base/gserrors.h')
-rw-r--r--gs/base/gserrors.h107
1 files changed, 106 insertions, 1 deletions
diff --git a/gs/base/gserrors.h b/gs/base/gserrors.h
index c3d826776..24b5eb42d 100644
--- a/gs/base/gserrors.h
+++ b/gs/base/gserrors.h
@@ -48,11 +48,16 @@
#define gs_error_Remap_Color (-103)
int gs_log_error(int, const char *, int);
-#ifndef DEBUG
+#if !defined(DEBUG) || defined(GS_THREADSAFE)
# define gs_log_error(err, file, line) (err)
#endif
+#ifdef GS_THREADSAFE
+#define gs_note_error(err) (err)
+#define return_error(err) return (err)
+#else
#define gs_note_error(err) gs_log_error(err, __FILE__, __LINE__)
#define return_error(err) return gs_note_error(err)
+#endif
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
# if defined(__GNUC__) && __GNUC__ >= 2
@@ -82,6 +87,105 @@ int gs_log_error(int, const char *, int);
const char *gs_errstr(int code);
+#ifdef GS_THREADSAFE
+/* In threadsafe builds, we just swallow errors unreported */
+#define gs_throw_code(code) \
+ (code)
+
+#define gs_throw(code, fmt) \
+ (code)
+#define gs_throw1(code, fmt, arg1) \
+ (code)
+#define gs_throw2(code, fmt, arg1, arg2) \
+ (code)
+#define gs_throw3(code, fmt, arg1, arg2, arg3) \
+ (code)
+#define gs_throw4(code, fmt, arg1, arg2, arg3, arg4) \
+ (code)
+#define gs_throw5(code, fmt, arg1, arg2, arg3, arg4, arg5) \
+ (code)
+#define gs_throw6(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
+ (code)
+#define gs_throw7(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+ (code)
+#define gs_throw8(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
+ (code)
+#define gs_throw9(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
+ (code)
+
+/* Bubble the code up the stack
+*/
+#define gs_rethrow_code(code) \
+ (code)
+
+#define gs_rethrow(code, fmt) \
+ (code)
+#define gs_rethrow1(code, fmt, arg1) \
+ (code)
+#define gs_rethrow2(code, fmt, arg1, arg2) \
+ (code)
+#define gs_rethrow3(code, fmt, arg1, arg2, arg3) \
+ (code)
+#define gs_rethrow4(code, fmt, arg1, arg2, arg3, arg4) \
+ (code)
+#define gs_rethrow5(code, fmt, arg1, arg2, arg3, arg4, arg5) \
+ (code)
+#define gs_rethrow6(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
+ (code)
+#define gs_rethrow7(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+ (code)
+#define gs_rethrow8(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
+ (code)
+#define gs_rethrow9(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
+ (code)
+
+/* This will cause trouble, as it implies you are fixing an error
+ * the system will spew messages
+ */
+#define gs_catch(code, fmt) \
+ (code)
+#define gs_catch1(code, fmt, arg1) \
+ (code)
+#define gs_catch2(code, fmt, arg1, arg2) \
+ (code)
+#define gs_catch3(code, fmt, arg1, arg2, arg3) \
+ (code)
+#define gs_catch4(code, fmt, arg1, arg2, arg3, arg4) \
+ (code)
+#define gs_catch5(code, fmt, arg1, arg2, arg3, arg4, arg5) \
+ (code)
+#define gs_catch6(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
+ (code)
+#define gs_catch7(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+ (code)
+#define gs_catch8(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
+ (code)
+#define gs_catch9(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
+ (code)
+
+/* gs_warn is a printf
+ */
+#define gs_warn(fmt) \
+ DO_NOTHING
+#define gs_warn1(fmt, arg1) \
+ DO_NOTHING
+#define gs_warn2(fmt, arg1, arg2) \
+ DO_NOTHING
+#define gs_warn3(fmt, arg1, arg2, arg3) \
+ DO_NOTHING
+#define gs_warn4(fmt, arg1, arg2, arg3, arg4) \
+ DO_NOTHING
+#define gs_warn5(fmt, arg1, arg2, arg3, arg4, arg5) \
+ DO_NOTHING
+#define gs_warn6(fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
+ DO_NOTHING
+#define gs_warn7(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+ DO_NOTHING
+#define gs_warn8(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
+ DO_NOTHING
+#define gs_warn9(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
+ DO_NOTHING
+#else
int gs_throw_imp(const char *func, const char *file, int line,
int op, int code, const char *fmt, ...) __printflike(6, 7);
@@ -183,6 +287,7 @@ int gs_throw_imp(const char *func, const char *file, int line,
(void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
#define gs_warn9(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
(void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
+#endif
/* just in case you don't know 0 means no error
* other return codes are errors.