From b5881295b53a8ad2132d4e8d7e28e5aeb5459469 Mon Sep 17 00:00:00 2001 From: jthorn Date: Sun, 17 Jun 2001 10:41:18 +0000 Subject: 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 --- src/jtutil/stdc.h | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/jtutil/stdc.h (limited to 'src/jtutil/stdc.h') 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 */ + #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 */ + /* usually 10...0 binary for */ + /* a 2's complement system */ +#define FLOAT_SENTINAL_VALUE (- FLT_MAX) /* from */ +#define DOUBLE_SENTINAL_VALUE (- DBL_MAX) /* from */ + +/* misc integer sentinal value */ +#define SENTINAL_VALUE INT_SENTINAL_VALUE + +/******************************************************************************/ + +#endif /* STDC_H_SEEN */ -- cgit v1.2.3