Changeset 2273 for trunk/psLib/src/dataManip/psConstants.h
- Timestamp:
- Nov 3, 2004, 3:05:00 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/dataManip/psConstants.h (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psConstants.h
r2272 r2273 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-11-0 3 22:58:53$8 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:04:57 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 32 32 #define PS_INT_CHECK_NON_NEGATIVE(NAME, RVAL) \ 33 33 if (NAME < 0) { \ 34 psError(__func__,"Error: %s is less than 0.", #NAME); \ 34 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 35 "Error: %s is less than 0.", #NAME); \ 35 36 return(RVAL); \ 36 37 } … … 38 39 #define PS_INT_CHECK_POSITIVE(NAME, RVAL) \ 39 40 if (NAME < 1) { \ 40 psError(__func__,"Error: %s is 0 or less.", #NAME); \ 41 return(RVAL); \ 42 } 43 44 // Produce an error if ((NAME1 > NAME2) 41 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 42 "Error: %s is 0 or less.", #NAME); \ 43 return(RVAL); \ 44 } 45 46 #define PS_INT_CHECK_RANGE(NAME, LOWER, UPPER, RVAL) \ 47 if ((int)NAME < LOWER || (int)NAME > UPPER) { \ 48 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 49 "Error: %s, %d, is out of range. Must be between %d and %d.", \ 50 #NAME,(int)NAME,LOWER,UPPER); \ 51 return RVAL; \ 52 } 53 54 // Produce an error if (NAME1 > NAME2) 45 55 #define PS_INT_COMPARE(NAME1, NAME2, RVAL) \ 46 56 if (NAME1 > NAME2) { \ 47 psError(__func__,"Error: (%s > %s) (%d %d).", #NAME1, #NAME2, NAME1, NAME2); \ 57 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 58 "Error: (%s > %s) (%d %d).", \ 59 #NAME1, #NAME2, NAME1, NAME2); \ 48 60 return(RVAL); \ 49 61 } … … 53 65 #define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \ 54 66 if (NAME1 > NAME2) { \ 55 psError(__func__,"Error: (%s > %s) (%f %f)", #NAME1, #NAME2, NAME1, NAME2); \ 67 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 68 "Error: (%s > %s) (%f %f)", \ 69 #NAME1, #NAME2, NAME1, NAME2); \ 56 70 return(RVAL); \ 57 71 } … … 59 73 #define PS_FLOAT_CHECK_NON_EQUAL(NAME1, NAME2, RVAL) \ 60 74 if (fabs(NAME2 - NAME1) < FLT_EPSILON) { \ 61 psError(__func__,"Error: %s and %s are equal.", #NAME1, #NAME2); \ 75 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 76 "Error: %s and %s are equal.", \ 77 #NAME1, #NAME2); \ 62 78 return(RVAL); \ 63 79 } … … 67 83 the wrong type. 68 84 *****************************************************************************/ 69 #define PS_PTR_CHECK_NULL(NAME, RVAL) \ 85 #define PS_PTR_CHECK_NULL(NAME, RVAL) PS_PTR_CHECK_NULL_GENERAL(NAME, return RVAL) 86 #define PS_PTR_CHECK_NULL_GENERAL(NAME, CLEANUP) \ 70 87 if (NAME == NULL) { \ 71 psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \ 72 return(RVAL); \ 88 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 89 "Unallowable operation: %s is NULL.", \ 90 #NAME); \ 91 CLEANUP; \ 73 92 } 74 93 75 94 #define PS_PTR_CHECK_TYPE(NAME, TYPE, RVAL) \ 76 95 if (NAME->type.type != TYPE) { \ 77 psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \ 78 return(RVAL); \ 79 } 96 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 97 "Unallowable operation: %s has incorrect type.", \ 98 #NAME); \ 99 return(RVAL); \ 100 } 101 102 #define PS_PTR_CHECK_DIMEN(NAME, DIMEN, RVAL) PS_PTR_CHECK_DIMEN_GENERAL(NAME, DIMEN, return RVAL) 103 #define PS_PTR_CHECK_DIMEN_GENERAL(NAME, DIMEN, CLEANUP) \ 104 if (NAME->type.dimen != DIMEN) { \ 105 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 106 "Unallowable operation: %s has incorrect dimensionality.", \ 107 #NAME); \ 108 CLEANUP; \ 109 } 110 80 111 81 112 #define PS_PTR_CHECK_SIZE_EQUAL(PTR1, PTR2, RVAL) \ 82 113 if (PTR1->n != PTR2->n) { \ 83 psError(__func__,"ptr %s has size %d, ptr %s has size %d.", #PTR1, PTR1->n, #PTR2, PTR2->n); \ 84 return(RVAL); \ 85 } 86 87 #define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) \ 114 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 115 "ptr %s has size %d, ptr %s has size %d.", \ 116 #PTR1, PTR1->n, #PTR2, PTR2->n); \ 117 return(RVAL); \ 118 } 119 120 #define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) PS_PTR_CHECK_TYPE_EQUAL_GENERAL(PTR1, PTR2, return RVAL) 121 122 #define PS_PTR_CHECK_TYPE_EQUAL_GENERAL(PTR1, PTR2, CLEANUP) \ 88 123 if (PTR1->type.type != PTR2->type.type) { \ 89 psError(__func__,"ptr %s has type %d, ptr %s has type %d.", #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \ 90 return(RVAL); \ 124 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 125 "ptr %s has type %d, ptr %s has type %d.", \ 126 #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \ 127 CLEANUP; \ 91 128 } 92 129 … … 95 132 PS_VECTOR macros: 96 133 *****************************************************************************/ 97 #define PS_VECTOR_CHECK_NULL(NAME, RVAL) \ 134 #define PS_VECTOR_CHECK_NULL(NAME, RVAL) PS_VECTOR_CHECK_NULL_GENERAL(NAME, return RVAL) 135 #define PS_VECTOR_CHECK_NULL_GENERAL(NAME, CLEANUP) \ 98 136 if (NAME == NULL || NAME->data.V == NULL) { \ 99 psError(__func__,"Unallowable operation: psVector %s or its data is NULL.", #NAME); \ 100 return(RVAL); \ 137 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 138 "Unallowable operation: psVector %s or its data is NULL.", \ 139 #NAME); \ 140 CLEANUP; \ 101 141 } \ 102 142 103 143 #define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \ 104 144 if (NAME->n < 1) { \ 105 psError(__func__,"Unallowable operation: psVector %s has no elements.", #NAME); \ 145 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 146 "Unallowable operation: psVector %s has no elements.", \ 147 #NAME); \ 106 148 return(RVAL); \ 107 149 } \ … … 109 151 #define PS_VECTOR_CHECK_TYPE_F32_OR_F64(NAME, RVAL) \ 110 152 if ((NAME->type.type != PS_TYPE_F32) && (NAME->type.type != PS_TYPE_F64)) { \ 111 psError(__func__, "psVector %s: bad type(%d)", #NAME, NAME->type.type); \ 153 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 154 "psVector %s: bad type(%d)", \ 155 #NAME, NAME->type.type); \ 112 156 return(RVAL); \ 113 157 } \ … … 115 159 #define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \ 116 160 if (NAME->type.type != TYPE) { \ 117 psError(__func__,"Unallowable operation: psVector %s has incorrect type.", #NAME); \ 161 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 162 "Unallowable operation: psVector %s has incorrect type.", \ 163 #NAME); \ 118 164 return(RVAL); \ 119 165 } … … 121 167 #define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \ 122 168 if (VEC1->n != VEC2->n) { \ 123 psError(__func__,"psVector %s has size %d, psVector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \ 169 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 170 "psVector %s has size %d, psVector %s has size %d.", \ 171 #VEC1, VEC1->n, #VEC2, VEC2->n); \ 124 172 return(RVAL); \ 125 173 } … … 221 269 #define PS_POLY_CHECK_NULL(NAME, RVAL) \ 222 270 if (NAME == NULL || NAME->coeff == NULL) { \ 223 psError(__func__,"Unallowable operation: polynomial %s or its coeffs is NULL.", #NAME); \ 271 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 272 "Unallowable operation: polynomial %s or its coeffs is NULL.", \ 273 #NAME); \ 224 274 return(RVAL); \ 225 275 } \ … … 227 277 #define PS_POLY_CHECK_TYPE(NAME, TYPE, RVAL) \ 228 278 if (NAME->type != TYPE) { \ 229 psError(__func__,"Unallowable operation: polynomial %s has wrong type.", #NAME); \ 279 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 280 "Unallowable operation: polynomial %s has wrong type.", #NAME); \ 230 281 return(RVAL); \ 231 282 } \ … … 234 285 PS_IMAGE macros: 235 286 *****************************************************************************/ 236 #define PS_IMAGE_CHECK_NULL(NAME, RVAL) \ 287 #define PS_IMAGE_CHECK_NULL(NAME, RVAL) PS_IMAGE_CHECK_NULL_GENERAL(NAME, return RVAL) 288 #define PS_IMAGE_CHECK_NULL_GENERAL(NAME, CLEANUP) \ 237 289 if (NAME == NULL || NAME->data.V == NULL) { \ 238 psError(__func__,"Unallowable operation: psImage %s or its data is NULL.", #NAME); \ 239 return(RVAL); \ 240 } 241 242 #define PS_IMAGE_CHECK_EMPTY(NAME, RVAL) \ 290 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 291 "Unallowable operation: psImage %s or its data is NULL.", \ 292 #NAME); \ 293 CLEANUP; \ 294 } 295 296 #define PS_IMAGE_CHECK_EMPTY(NAME, RVAL) PS_IMAGE_CHECK_EMPTY_GENERAL(NAME, return RVAL) 297 #define PS_IMAGE_CHECK_EMPTY_GENERAL(NAME, CLEANUP) \ 243 298 if (NAME->numCols < 1 || NAME->numRows < 1) { \ 244 psError(__func__,"Unallowable operation: psImage %s has zero rows or columns (%dx%d).", #NAME, \ 245 NAME->numCols, NAME->numRows); \ 246 return(RVAL); \ 299 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 300 "Unallowable operation: psImage %s has zero rows or columns (%dx%d).", \ 301 #NAME, NAME->numCols, NAME->numRows); \ 302 CLEANUP; \ 247 303 } 248 304 249 305 #define PS_IMAGE_CHECK_TYPE(NAME, TYPE, RVAL) \ 250 306 if (NAME->type.type != TYPE) { \ 251 psError(__func__,"Unallowable operation: psImage %s has incorrect type.", #NAME); \ 307 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 308 "Unallowable operation: psImage %s has incorrect type.", \ 309 #NAME); \ 252 310 return(RVAL); \ 253 311 } … … 260 318 #define PS_READOUT_CHECK_NULL(NAME, RVAL) \ 261 319 if (NAME == NULL || NAME->image == NULL) { \ 262 psError(__func__,"Unallowable operation: psReadout %s or its data is NULL.", #NAME); \ 320 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 321 "Unallowable operation: psReadout %s or its data is NULL.", \ 322 #NAME); \ 263 323 return(RVAL); \ 264 324 }
Note:
See TracChangeset
for help on using the changeset viewer.
