diff options
author | jthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416> | 2002-12-20 15:10:22 +0000 |
---|---|---|
committer | jthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416> | 2002-12-20 15:10:22 +0000 |
commit | bd533e3e3243827a5667ab2efbeefdb85ffda30f (patch) | |
tree | a5f69063e47f3402ee8c17e051d76d6c8c79ae1e /src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h | |
parent | cb9aaede7365d60bc7e0543ce36873de7893607a (diff) |
add testing for the error case where the grid is smaller than the molecule
(before this would access memory off the end of the grid
==> core dump on some platforms, eg alphas)
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/LocalInterp/trunk@122 df1f8a13-aa1d-4dd4-9681-27ded5b42416
Diffstat (limited to 'src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h')
-rw-r--r-- | src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h b/src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h index 24be556..d2990df 100644 --- a/src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h +++ b/src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h @@ -20,16 +20,16 @@ typedef int bool; /******************************************************************************/ /* number of integers in the range [x,y] inclusive */ -#define how_many_in_range(x,y) ((y) - (x) + 1) +#define HOW_MANY_IN_RANGE(x,y) ((y) - (x) + 1) /* is the integer x even/odd? */ -#define is_even(x) (((x) & 0x1) == 0) -#define is_odd (x) (((x) & 0x1) != 0) +#define IS_EVEN(x) (((x) & 0x1) == 0) +#define IS_ODD (x) (((x) & 0x1) != 0) /* round floating-point value to nearest integer */ /* ... result is expressed as floating point! */ /* ... needs <math.h> for floor() */ -#define jt_round(x) floor((x) + 0.5) +#define JT_ROUND(x) floor((x) + 0.5) /******************************************************************************/ @@ -149,6 +149,25 @@ struct Jacobian_info CCTK_INT Jacobian_part_stride; }; +/**************************************/ + +/* + * error codes for LocalInterp_molecule_posn() + * ... these are defined in terms of INT_MIN from <limits.h> + */ + +/* x < minimum allowable x in grid */ +#define MOLECULE_POSN_ERROR_X_LT_MIN (INT_MIN + 0) + +/* x > maximum allowable x in grid */ +#define MOLECULE_POSN_ERROR_X_GT_MAX (INT_MIN + 1) + +/* grid is smaller than molecule */ +#define MOLECULE_POSN_ERROR_GRID_TINY (INT_MIN + 2) + +/* is a given integer an error code? */ +#define IS_MOLECULE_POSN_ERROR_CODE(x) (x <= MOLECULE_POSN_ERROR_GRID_TINY) + /******************************************************************************/ /* |