aboutsummaryrefslogtreecommitdiff
path: root/src/jtutil/stdc.h
diff options
context:
space:
mode:
authorjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2001-06-17 10:41:18 +0000
committerjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2001-06-17 10:41:18 +0000
commitb5881295b53a8ad2132d4e8d7e28e5aeb5459469 (patch)
tree4af1f218157a95d018ad851f8d1ab343921cbc1e /src/jtutil/stdc.h
parentaa9e52f0080ee037bf95c75d1eaf12d29cac5fb0 (diff)
move stdc.h from ../jt/ to here
move PI defn from util++.hh to stdc.h git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@51 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/jtutil/stdc.h')
-rw-r--r--src/jtutil/stdc.h114
1 files changed, 114 insertions, 0 deletions
diff --git a/src/jtutil/stdc.h b/src/jtutil/stdc.h
new file mode 100644
index 0000000..b53f3c8
--- /dev/null
+++ b/src/jtutil/stdc.h
@@ -0,0 +1,114 @@
+/* stdc.h -- JT standard C/C++ header file, cut-down for modern code only */
+/* $Id$ */
+
+/*
+ * ***** THIS VERSION IS FOR ANSI/ISO C AND C++ *****
+ */
+
+/* this header file is idempotent */
+#ifndef STDC_H_SEEN
+#define STDC_H_SEEN
+
+/******************************************************************************/
+
+/*
+ * C/C++ compatability:
+ */
+
+/* use this in prototypes like this: extern C_FUNCTION void foo(...) */
+#ifdef __cplusplus
+ #define C_FUNCTION "C"
+#else
+ #define C_FUNCTION /* empty */
+#endif
+
+/******************************************************************************/
+
+/*
+ * Fake "then" keyword for if statement, to make "then" and "else"
+ * symmetrical:
+ *
+ * usage:
+ * if (foo)
+ * then bar;
+ * else baz;
+ */
+#define then /* empty */
+
+/******************************************************************************/
+
+#ifdef M_PI /* usually defined in <math.h> */
+ #define PI M_PI
+#endif
+
+/******************************************************************************/
+
+#ifndef FILENAME_MAX
+ #if defined(LINUX)
+ #define FILENAME_MAX 4095
+ #elif defined(ALPHA)
+ /* gcc already defines this */
+ #else /* other systems */
+ #define FILENAME_MAX (BUFSIZ-1)
+ #endif /* LINUX */
+#endif
+
+/******************************************************************************/
+
+#ifdef __cplusplus
+namespace jtutil
+ {
+#endif
+
+/*
+ * All my error handling is done with my error_exit() routine. It
+ * prints an error message to stderr, then does an exit() or abort().
+ * It does *not* return to its caller. It's declared to return an
+ * int , however, so it may be easily used in conditional expressions
+ * like
+ * foo = bar_ok ? baz(bar) : error_exit(...);
+ */
+extern C_FUNCTION int error_exit(int exit_code, const char *format, ...)
+ #ifdef __GNUC__
+ __attribute__ ((noreturn))
+ __attribute__ ((format(printf,2,3)))
+ #endif
+;
+
+/*
+ * error_exit() uses the following exit() codes:
+ * OK_EXIT ==> everything's under control
+ * ERROR_EXIT ==> something bad has happened
+ * PANIC_EXIT ==> diasaster ==> force (eg) core dump, stack trace
+ */
+
+#ifdef VMS
+ #define OK_EXIT 1
+ #define ERROR_EXIT 3
+ #define PANIC_EXIT (-1)
+#else
+ #define OK_EXIT 0
+ #define ERROR_EXIT 1
+ #define PANIC_EXIT (-1)
+#endif
+
+#ifdef __cplusplus
+ } /* close namespace jtutil */
+#endif
+
+/******************************************************************************/
+
+#define iabs abs /* C library uses abs() for integer absolute value */
+
+#define INT_SENTINAL_VALUE (~ INT_MAX) /* from <limits.h> */
+ /* usually 10...0 binary for */
+ /* a 2's complement system */
+#define FLOAT_SENTINAL_VALUE (- FLT_MAX) /* from <float.h> */
+#define DOUBLE_SENTINAL_VALUE (- DBL_MAX) /* from <float.h> */
+
+/* misc integer sentinal value */
+#define SENTINAL_VALUE INT_SENTINAL_VALUE
+
+/******************************************************************************/
+
+#endif /* STDC_H_SEEN */