IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2211


Ignore:
Timestamp:
Oct 27, 2004, 9:58:54 AM (22 years ago)
Author:
gusciora
Message:

I've been unifying the naming conventions for various macros that check
functions parameters for type, size, non-NULL ...

Location:
trunk/psLib/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astronomy/psAstrometry.c

    r2206 r2211  
    88 *  @author George Gusciora, MHPCC
    99 *
    10  *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-10-27 01:15:47 $
     10 *  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-10-27 19:58:54 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    229229    psS32 j;
    230230
    231     PS_CHECK_NULL_IMAGE_RETURN_NULL(x);
    232     PS_CHECK_NULL_IMAGE_RETURN_NULL(y);
    233     PS_CHECK_IMAGE_TYPE_RETURN_NULL(x, PS_TYPE_F64);
    234     PS_CHECK_IMAGE_TYPE_RETURN_NULL(y, PS_TYPE_F64);
     231    PS_CHECK_NULL_IMAGE(x, NULL);
     232    PS_CHECK_NULL_IMAGE(y, NULL);
     233    PS_CHECK_IMAGE_TYPE(x, PS_TYPE_F64, NULL);
     234    PS_CHECK_IMAGE_TYPE(y, PS_TYPE_F64, NULL);
    235235
    236236    tmp = (psFixedPattern *) psAlloc(sizeof(psFixedPattern));
  • trunk/psLib/src/dataManip/psConstants.h

    r2209 r2211  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-27 01:23:24 $
     8 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-10-27 19:58:54 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1212 */
    1313
     14/*****************************************************************************
     15These constants are used by various functions in the psLib.
     16 *****************************************************************************/
    1417#define DETERMINE_BRACKET_STEP_SIZE 0.10
    1518#define MAX_LMM_ITERATIONS 100
     
    1720#define LEFT_SPLINE_DERIV 0.0
    1821#define RIGHT_SPLINE_DERIV 0.0
    19 
     22/*****************************************************************************
     23These are common mathimatical constants used by various functions in the psLib.
     24 *****************************************************************************/
     25
     26
     27
     28/*****************************************************************************
     29 
     30 *****************************************************************************/
    2031#define CONVERT_VECTOR_F64_TO_F32(OLD, NEW_PTR32, NEW_STATIC32) \
    2132if (OLD->type.type == PS_TYPE_F32) { \
     
    4455} \
    4556
    46 #define VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(VEC) \
    47 if ((VEC->type.type != PS_TYPE_F32) && (VEC->type.type != PS_TYPE_F64)) { \
    48     psAbort(__func__, "Bad type for VEC (%d)", VEC->type.type); \
    49     return(NULL); \
    50 } \
    51 
    5257#define GEN_PERSIST_YERR_VEC_F32(VEC, N) \
    5358VEC = psVectorRecycle(VEC, N, PS_TYPE_F32); \
     
    8994
    9095
    91 
    92 
    93 
     96/*****************************************************************************
     97 
     98*****************************************************************************/
     99#define PS_CHECK_NULL_PTR(NAME, RVAL) \
     100if (NAME == NULL) { \
     101    psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
     102    return(RVAL); \
     103}
     104
     105/*****************************************************************************
     106 
     107 *****************************************************************************/
     108#define VECTOR_CHECK_TYPE_F32_OR_F64(VEC, RVAL) \
     109if ((VEC->type.type != PS_TYPE_F32) && (VEC->type.type != PS_TYPE_F64)) { \
     110    psAbort(__func__, "Bad type for VEC (%d)", VEC->type.type); \
     111    return(RVAL); \
     112} \
    94113
    95114/** Preprocessor macro to generate error on an incorrect type */
     
    107126} \
    108127
    109 /** Preprocessor macro to generate error on a NULL poniter */
    110 #define PS_CHECK_NULL_PTR(NAME, RVAL) \
    111 if (NAME == NULL) { \
    112     psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
    113     return(RVAL); \
    114 }
    115 
    116128/** Preprocessor macro to generate error for zero length vector */
    117129#define PS_CHECK_EMPTY_VECTOR(NAME, RVAL) \
     
    128140}
    129141
    130 
    131 
    132 
    133 
    134 /** Preprocessor macro to generate error on a NULL image */
    135 #define PS_CHECK_NULL_IMAGE_RETURN_NULL(NAME) \
    136 if (NAME == NULL || NAME->data.V == NULL) {                                                         \
    137     psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME);                          \
    138     return(NULL); \
    139 }
    140 
    141 /** Preprocessor macro to generate error for zero length rows or columns */
    142 #define PS_CHECK_EMPTY_IMAGE_RETURN_NULL(NAME) \
    143 if (NAME->numCols < 1 || NAME->numRows < 1) {                                                       \
    144     psError(__func__,"Unallowable operation: %s has zero rows or columns (%dx%d).", #NAME,              \
    145             NAME->numCols, NAME->numRows);                                                          \
    146     return(NULL); \
    147 }
    148 
    149 #define PS_CHECK_IMAGE_TYPE_RETURN_NULL(NAME, TYPE) \
    150 if (NAME->type.type != TYPE) { \
    151     psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \
    152     return(NULL); \
    153 }
    154 
    155 /** Preprocessor macro to generate error on a NULL image */
    156 #define PS_CHECK_NULL_IMAGE_READOUT_NULL(NAME) \
    157 if (NAME == NULL || NAME->image == NULL) {                                                         \
    158     psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME);                          \
    159     return(NULL); \
    160 }
    161 
    162 #define PS_CHECK_NULL_1DPOLY_RETURN_NULL(NAME)                                                          \
    163 if (NAME == NULL || NAME->coeff == NULL) {                                                         \
    164     psError(__func__,"Unallowable operation: %s or its coeffs is NULL.", #NAME);                          \
    165     return(NULL); \
    166 } \
    167 
    168 
    169 
    170 
    171 
    172142#define PS_PRINT_VECTOR(NAME) \
    173143for (int my_i=0;my_i<NAME->n;my_i++) { \
     
    189159
    190160
     161
     162/*****************************************************************************
     163 
     164*****************************************************************************/
     165#define PS_CHECK_NULL_POLY(NAME, NULL) \
     166if (NAME == NULL || NAME->coeff == NULL) { \
     167    psError(__func__,"Unallowable operation: polynomial %s or its coeffs is NULL.", #NAME); \
     168    return(NULL); \
     169} \
     170
     171
     172
     173
     174
     175/*****************************************************************************
     176 
     177*****************************************************************************/
     178/** Preprocessor macro to generate error on a NULL image */
     179#define PS_CHECK_NULL_IMAGE(NAME, RVAL) \
     180if (NAME == NULL || NAME->data.V == NULL) { \
     181    psError(__func__,"Unallowable operation: psImage %s or its data is NULL.", #NAME); \
     182    return(RVAL); \
     183}
     184
     185/** Preprocessor macro to generate error for zero length rows or columns */
     186#define PS_CHECK_EMPTY_IMAGE(NAME, RVAL) \
     187if (NAME->numCols < 1 || NAME->numRows < 1) { \
     188    psError(__func__,"Unallowable operation: psImage %s has zero rows or columns (%dx%d).", #NAME, \
     189            NAME->numCols, NAME->numRows); \
     190    return(RVAL); \
     191}
     192
     193#define PS_CHECK_IMAGE_TYPE(NAME, TYPE, RVAL) \
     194if (NAME->type.type != TYPE) { \
     195    psError(__func__,"Unallowable operation: psImage %s has incorrect type.", #NAME); \
     196    return(RVAL); \
     197}
     198
     199/*****************************************************************************
     200 
     201 *****************************************************************************/
     202/** Preprocessor macro to generate error on a NULL image */
     203#define PS_CHECK_NULL_IMAGE_READOUT(NAME, RVAL) \
     204if (NAME == NULL || NAME->image == NULL) {                                                         \
     205    psError(__func__,"Unallowable operation: psReadout %s or its data is NULL.", #NAME); \
     206    return(RVAL); \
     207}
     208
     209
     210
     211
     212
     213/*****************************************************************************
     214 
     215 *****************************************************************************/
    191216#define PS_MAX(A, B) \
    192217(((A) > (B)) ? (A) : (B)) \
  • trunk/psLib/src/dataManip/psMinimize.c

    r2208 r2211  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-27 01:21:01 $
     11 *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-10-27 19:58:54 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    254254    PS_CHECK_NULL_PTR(mySpline, NULL);
    255255    PS_CHECK_NULL_PTR(y, NULL);
    256     VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(y);
     256    VECTOR_CHECK_TYPE_F32_OR_F64(y, NULL);
    257257    CONVERT_VECTOR_F64_TO_F32(y, y32, y32Static);
    258258
     
    262262        yErr32 = yErr32Static;
    263263    } else {
    264         VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(yErr);
     264        VECTOR_CHECK_TYPE_F32_OR_F64(yErr, NULL);
    265265        CONVERT_VECTOR_F64_TO_F32(yErr, yErr32, yErr32Static);
    266266    }
     
    271271        x32 = x32Static;
    272272    } else {
    273         VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(x);
     273        VECTOR_CHECK_TYPE_F32_OR_F64(x, NULL);
    274274        CONVERT_VECTOR_F64_TO_F32(x, x32, x32Static);
    275275    }
     
    855855    psS32 i;
    856856    psPolynomial1D *tmpPoly;
    857     PS_CHECK_NULL_1DPOLY_RETURN_NULL(myPoly);
     857    PS_CHECK_NULL_POLY(myPoly, NULL);
    858858    PS_CHECK_NULL_VECTOR(y, NULL);
    859859    PS_CHECK_EMPTY_VECTOR(y, NULL);
     
    865865    static psVector *yErr64Static = NULL;
    866866
    867     VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(y);
     867    VECTOR_CHECK_TYPE_F32_OR_F64(y, NULL);
    868868    CONVERT_VECTOR_F32_TO_F64(y, y64, y64Static);
    869869
     
    873873        yErr64 = yErr64Static;
    874874    } else {
    875         VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(yErr);
     875        VECTOR_CHECK_TYPE_F32_OR_F64(yErr, NULL);
    876876        CONVERT_VECTOR_F32_TO_F64(yErr, yErr64, yErr64Static);
    877877    }
     
    885885        x64 = x64Static;
    886886    } else {
    887         VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(x);
     887        VECTOR_CHECK_TYPE_F32_OR_F64(x, NULL);
    888888        CONVERT_VECTOR_F32_TO_F64(x, x64, x64Static);
    889889    }
  • trunk/psLib/src/math/psConstants.h

    r2209 r2211  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-27 01:23:24 $
     8 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-10-27 19:58:54 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1212 */
    1313
     14/*****************************************************************************
     15These constants are used by various functions in the psLib.
     16 *****************************************************************************/
    1417#define DETERMINE_BRACKET_STEP_SIZE 0.10
    1518#define MAX_LMM_ITERATIONS 100
     
    1720#define LEFT_SPLINE_DERIV 0.0
    1821#define RIGHT_SPLINE_DERIV 0.0
    19 
     22/*****************************************************************************
     23These are common mathimatical constants used by various functions in the psLib.
     24 *****************************************************************************/
     25
     26
     27
     28/*****************************************************************************
     29 
     30 *****************************************************************************/
    2031#define CONVERT_VECTOR_F64_TO_F32(OLD, NEW_PTR32, NEW_STATIC32) \
    2132if (OLD->type.type == PS_TYPE_F32) { \
     
    4455} \
    4556
    46 #define VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(VEC) \
    47 if ((VEC->type.type != PS_TYPE_F32) && (VEC->type.type != PS_TYPE_F64)) { \
    48     psAbort(__func__, "Bad type for VEC (%d)", VEC->type.type); \
    49     return(NULL); \
    50 } \
    51 
    5257#define GEN_PERSIST_YERR_VEC_F32(VEC, N) \
    5358VEC = psVectorRecycle(VEC, N, PS_TYPE_F32); \
     
    8994
    9095
    91 
    92 
    93 
     96/*****************************************************************************
     97 
     98*****************************************************************************/
     99#define PS_CHECK_NULL_PTR(NAME, RVAL) \
     100if (NAME == NULL) { \
     101    psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
     102    return(RVAL); \
     103}
     104
     105/*****************************************************************************
     106 
     107 *****************************************************************************/
     108#define VECTOR_CHECK_TYPE_F32_OR_F64(VEC, RVAL) \
     109if ((VEC->type.type != PS_TYPE_F32) && (VEC->type.type != PS_TYPE_F64)) { \
     110    psAbort(__func__, "Bad type for VEC (%d)", VEC->type.type); \
     111    return(RVAL); \
     112} \
    94113
    95114/** Preprocessor macro to generate error on an incorrect type */
     
    107126} \
    108127
    109 /** Preprocessor macro to generate error on a NULL poniter */
    110 #define PS_CHECK_NULL_PTR(NAME, RVAL) \
    111 if (NAME == NULL) { \
    112     psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
    113     return(RVAL); \
    114 }
    115 
    116128/** Preprocessor macro to generate error for zero length vector */
    117129#define PS_CHECK_EMPTY_VECTOR(NAME, RVAL) \
     
    128140}
    129141
    130 
    131 
    132 
    133 
    134 /** Preprocessor macro to generate error on a NULL image */
    135 #define PS_CHECK_NULL_IMAGE_RETURN_NULL(NAME) \
    136 if (NAME == NULL || NAME->data.V == NULL) {                                                         \
    137     psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME);                          \
    138     return(NULL); \
    139 }
    140 
    141 /** Preprocessor macro to generate error for zero length rows or columns */
    142 #define PS_CHECK_EMPTY_IMAGE_RETURN_NULL(NAME) \
    143 if (NAME->numCols < 1 || NAME->numRows < 1) {                                                       \
    144     psError(__func__,"Unallowable operation: %s has zero rows or columns (%dx%d).", #NAME,              \
    145             NAME->numCols, NAME->numRows);                                                          \
    146     return(NULL); \
    147 }
    148 
    149 #define PS_CHECK_IMAGE_TYPE_RETURN_NULL(NAME, TYPE) \
    150 if (NAME->type.type != TYPE) { \
    151     psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \
    152     return(NULL); \
    153 }
    154 
    155 /** Preprocessor macro to generate error on a NULL image */
    156 #define PS_CHECK_NULL_IMAGE_READOUT_NULL(NAME) \
    157 if (NAME == NULL || NAME->image == NULL) {                                                         \
    158     psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME);                          \
    159     return(NULL); \
    160 }
    161 
    162 #define PS_CHECK_NULL_1DPOLY_RETURN_NULL(NAME)                                                          \
    163 if (NAME == NULL || NAME->coeff == NULL) {                                                         \
    164     psError(__func__,"Unallowable operation: %s or its coeffs is NULL.", #NAME);                          \
    165     return(NULL); \
    166 } \
    167 
    168 
    169 
    170 
    171 
    172142#define PS_PRINT_VECTOR(NAME) \
    173143for (int my_i=0;my_i<NAME->n;my_i++) { \
     
    189159
    190160
     161
     162/*****************************************************************************
     163 
     164*****************************************************************************/
     165#define PS_CHECK_NULL_POLY(NAME, NULL) \
     166if (NAME == NULL || NAME->coeff == NULL) { \
     167    psError(__func__,"Unallowable operation: polynomial %s or its coeffs is NULL.", #NAME); \
     168    return(NULL); \
     169} \
     170
     171
     172
     173
     174
     175/*****************************************************************************
     176 
     177*****************************************************************************/
     178/** Preprocessor macro to generate error on a NULL image */
     179#define PS_CHECK_NULL_IMAGE(NAME, RVAL) \
     180if (NAME == NULL || NAME->data.V == NULL) { \
     181    psError(__func__,"Unallowable operation: psImage %s or its data is NULL.", #NAME); \
     182    return(RVAL); \
     183}
     184
     185/** Preprocessor macro to generate error for zero length rows or columns */
     186#define PS_CHECK_EMPTY_IMAGE(NAME, RVAL) \
     187if (NAME->numCols < 1 || NAME->numRows < 1) { \
     188    psError(__func__,"Unallowable operation: psImage %s has zero rows or columns (%dx%d).", #NAME, \
     189            NAME->numCols, NAME->numRows); \
     190    return(RVAL); \
     191}
     192
     193#define PS_CHECK_IMAGE_TYPE(NAME, TYPE, RVAL) \
     194if (NAME->type.type != TYPE) { \
     195    psError(__func__,"Unallowable operation: psImage %s has incorrect type.", #NAME); \
     196    return(RVAL); \
     197}
     198
     199/*****************************************************************************
     200 
     201 *****************************************************************************/
     202/** Preprocessor macro to generate error on a NULL image */
     203#define PS_CHECK_NULL_IMAGE_READOUT(NAME, RVAL) \
     204if (NAME == NULL || NAME->image == NULL) {                                                         \
     205    psError(__func__,"Unallowable operation: psReadout %s or its data is NULL.", #NAME); \
     206    return(RVAL); \
     207}
     208
     209
     210
     211
     212
     213/*****************************************************************************
     214 
     215 *****************************************************************************/
    191216#define PS_MAX(A, B) \
    192217(((A) > (B)) ? (A) : (B)) \
  • trunk/psLib/src/math/psMinimize.c

    r2208 r2211  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-27 01:21:01 $
     11 *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-10-27 19:58:54 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    254254    PS_CHECK_NULL_PTR(mySpline, NULL);
    255255    PS_CHECK_NULL_PTR(y, NULL);
    256     VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(y);
     256    VECTOR_CHECK_TYPE_F32_OR_F64(y, NULL);
    257257    CONVERT_VECTOR_F64_TO_F32(y, y32, y32Static);
    258258
     
    262262        yErr32 = yErr32Static;
    263263    } else {
    264         VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(yErr);
     264        VECTOR_CHECK_TYPE_F32_OR_F64(yErr, NULL);
    265265        CONVERT_VECTOR_F64_TO_F32(yErr, yErr32, yErr32Static);
    266266    }
     
    271271        x32 = x32Static;
    272272    } else {
    273         VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(x);
     273        VECTOR_CHECK_TYPE_F32_OR_F64(x, NULL);
    274274        CONVERT_VECTOR_F64_TO_F32(x, x32, x32Static);
    275275    }
     
    855855    psS32 i;
    856856    psPolynomial1D *tmpPoly;
    857     PS_CHECK_NULL_1DPOLY_RETURN_NULL(myPoly);
     857    PS_CHECK_NULL_POLY(myPoly, NULL);
    858858    PS_CHECK_NULL_VECTOR(y, NULL);
    859859    PS_CHECK_EMPTY_VECTOR(y, NULL);
     
    865865    static psVector *yErr64Static = NULL;
    866866
    867     VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(y);
     867    VECTOR_CHECK_TYPE_F32_OR_F64(y, NULL);
    868868    CONVERT_VECTOR_F32_TO_F64(y, y64, y64Static);
    869869
     
    873873        yErr64 = yErr64Static;
    874874    } else {
    875         VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(yErr);
     875        VECTOR_CHECK_TYPE_F32_OR_F64(yErr, NULL);
    876876        CONVERT_VECTOR_F32_TO_F64(yErr, yErr64, yErr64Static);
    877877    }
     
    885885        x64 = x64Static;
    886886    } else {
    887         VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(x);
     887        VECTOR_CHECK_TYPE_F32_OR_F64(x, NULL);
    888888        CONVERT_VECTOR_F32_TO_F64(x, x64, x64Static);
    889889    }
Note: See TracChangeset for help on using the changeset viewer.