From 7a935a076990a3361290ff35688efba76d579936 Mon Sep 17 00:00:00 2001 From: jthorn Date: Mon, 24 Jun 2002 16:13:35 +0000 Subject: move config.hh from ../ delete a bunch of old stuff from stdc.h which we don't use any more git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@588 f88db872-0e4f-0410-b76b-b9085cfa78c5 --- src/include/README | 11 +++++++ src/include/config.hh | 19 +++++++++++ src/include/stdc.h | 89 ++++++++++++++++++--------------------------------- 3 files changed, 62 insertions(+), 57 deletions(-) create mode 100644 src/include/README create mode 100644 src/include/config.hh diff --git a/src/include/README b/src/include/README new file mode 100644 index 0000000..a616529 --- /dev/null +++ b/src/include/README @@ -0,0 +1,11 @@ +This directory holds header files common to all of this thorn. + +stdc.h + is a low-level file defining Jonathan Thornburg's "dialect" of C, + including the "then" pseudo-keyword you'll see all through the + source code + +config.hh + defines compile-time configuration for this thorn, eg the "fp" + typedef (= CCTK_REAL), the choice of 2nd vs 4th order finite + differencing, etc etc diff --git a/src/include/config.hh b/src/include/config.hh new file mode 100644 index 0000000..d1bc9f2 --- /dev/null +++ b/src/include/config.hh @@ -0,0 +1,19 @@ +// config.hh -- compile-time configuration for AHFinderDirect +// $Id$ + +#ifndef CCTK_VARIABLE_REAL + // we must be doing a test compilation outside of Cactus + typedef double CCTK_REAL; + typedef int CCTK_INT; +#endif +typedef CCTK_REAL fp; + +// +// The angular finite differencing in our multipatch system can be +// either 2nd order or 4th order, configurable here. +// +#ifdef FINITE_DIFF_ORDER + // someone (probably a Makefile) has already defined this ==> leave it alone +#else + #define FINITE_DIFF_ORDER 4 +#endif diff --git a/src/include/stdc.h b/src/include/stdc.h index 5505716..a3a929e 100644 --- a/src/include/stdc.h +++ b/src/include/stdc.h @@ -12,64 +12,50 @@ /******************************************************************************/ /* - * C/C++ compatability: + * I use this empty macro in all if statements -- I like the symmetry + * between the two branches of an if statement. + * + * if (foo) + * then bar; + * + * if (foo) + * then bar; + * else baz; */ - -/* use this in prototypes like this: extern C_FUNCTION void foo(...) */ -#ifdef __cplusplus - #define C_FUNCTION "C" -#else - #define C_FUNCTION /* empty */ -#endif +#define then /* empty */ /******************************************************************************/ /* - * New C/C++ "keywords" and types: + * misc stuff */ -#define then /* empty */ /* usage: if (foo) then bar; else baz; */ - /* this makes "then" and "else" symmetrical */ +#ifdef M_PI /* usually defined in */ + #define PI M_PI +#endif + +#define STRING_EQUAL(s_,t_) (strcmp(s_,t_) == 0) + +/* C library uses abs() for integer absolute value; I prefer iabs() */ +#define iabs(x_) abs(x_) /******************************************************************************/ /* - * *** KLUDGE *** - * - * These macros suffer form the same "redefinition in system headers" - * as my MIN/MAX macros (below). The fix here is the same as for MIN/MAX, - * but this time conditional on linux: + * misc sentinal values */ -#ifndef FILENAME_MAX - #if defined(LINUX) - #define FILENAME_MAX 4095 - #elif defined(ALPHA) - /* gcc already defines this */ - #else /* other systems */ - #define FILENAME_MAX BUFSIZ - #endif /* LINUX */ -#endif -/* printf(3) and scanf(3) formats and cast-types to print/read a pointer */ -/* unfortunately, the ANSI/ISO C "%p" format isn't universal yet :-( */ -/* even more unfortunately, ANSI/ISO printf() need not support length, */ -/* precision, or indeed _any_ modifiers for the %p conversion */ -#ifdef HAS_ISO_C_LIBRARY -#define PRINTF_POINTER_FORMAT "%p" -#define PRINTF_POINTER_TYPE void * -#define SCANF_POINTER_FORMAT "%p" -#define PRINTF_POINTER_TYPE void * -#else -#define PRINTF_POINTER_FORMAT "0x%08x" /* for 32-bit pointers */ -#define PRINTF_POINTER_TYPE unsigned long -#define SCANF_POINTER_FORMAT "0x%08x" /* for 32-bit pointers */ -#define PRINTF_POINTER_TYPE unsigned long -#endif +/* n.b. this value is usually 10...0 binary for 2's-complement arithmetic */ +#define INT_SENTINAL_VALUE (~ INT_MAX) /* from */ + +#define FLOAT_SENTINAL_VALUE (- FLT_MAX) /* from */ +#define DOUBLE_SENTINAL_VALUE (- DBL_MAX) /* from */ /******************************************************************************/ #ifdef __cplusplus -namespace jtutil { +namespace jtutil + { #endif /* @@ -80,7 +66,10 @@ namespace jtutil { * like * foo = bar_ok ? baz(bar) : error_exit(...); */ -extern C_FUNCTION int error_exit(int exit_code, const char *format, ...) +#ifdef __cplusplus + extern "C" +#endif +int error_exit(int exit_code, const char *format, ...) #ifdef __GNUC__ __attribute__ ((noreturn)) __attribute__ ((format(printf,2,3))) @@ -105,23 +94,9 @@ extern C_FUNCTION int error_exit(int exit_code, const char *format, ...) #endif #ifdef __cplusplus -} /* close namespace jtutil */ -using jtutil::error_exit; /* bring error_exit() into global namespace */ + } /* 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