00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _PXSTUFF_H_
00012 #define _PXSTUFF_H_
00013
00014 #include "NamespaceHeader.H"
00015
00016 enum PXE_Boolean { PXE_False, PXE_True, PXE_BooleanLast};
00017
00018
00019 #ifndef unlikely
00020 #define unlikely(expr) __builtin_expect((expr), 0)
00021 #endif
00022
00023 #ifndef likely
00024 #define likely(expr) __builtin_expect((expr), 1)
00025 #endif
00026
00027
00028
00029
00030
00031
00032
00033
00034 extern void PXErrorReport( const char *file, int line, const char *call, int ierr);
00035
00036
00037 #define PXError(v,X) { int _ier; _ier = (X); if (unlikely(_ier != PX_NO_ERROR)){ PXErrorRepo\
00038 rt(__FILE__, __LINE__, #X, _ier); } (v) = _ier;}
00039 #define PXErrorBreak(X) do{ int _ier; _ier = (X); if (unlikely(_ier != PX_NO_ERROR)){ PXErrorRepo\
00040 rt(__FILE__, __LINE__, #X, _ier); exit(-1);} } while (0)
00041 #define PXErrorReturn(X) do{ int _ier; _ier = (X); if (unlikely(_ier != PX_NO_ERROR)){ PXErrorRepo\
00042 rt(__FILE__, __LINE__, #X, _ier); return _ier;} } while (0)
00043 #define PXErrorReturnCode(X,Y) do{ int _ier; _ier = (X); if (unlikely(_ier != PX_NO_ERROR)){ PXErrorRepo\
00044 rt(__FILE__, __LINE__, #X, _ier); return ( Y);} } while (0)
00045 #define PXErrorReturnSilent(X) do{ int _ier; _ier = (X); if (unlikely(_ier != PX_NO_ERROR)){ return _ier\
00046 ;} } while (0)
00047
00048
00049 #define PX_NO_ERROR 0
00050 #define PX_MEMORY_ERROR -1
00051 #define PX_BAD_INPUT -2
00052 #define PX_NON_PHYSICAL -3
00053 #define PX_READWRITE_ERROR -4
00054 #define PX_GRID_ERROR -5
00055 #define PX_SEARCH_NOT_FOUND -6
00056 #define PX_NO_UPDATE -7
00057 #define PX_PARALLEL_ERROR -8
00058 #define PX_CODE_FLOW_ERROR -9
00059 #define PX_SYSTEM_ERROR -10
00060 #define PX_DYNAMIC_LIBRARY_ERROR -11
00061 #define PX_NOT_CONVERGED -12
00062 #define PX_VIZ_ERROR -13
00063 #define PX_LAPACK_ERROR -14
00064 #define PX_HARD_EXIT -15
00065 #define PX_CGNS_ERROR -16
00066
00067 extern const char *PXE_ErrorCodeName[];
00068
00069 #define AssertDblWithin( truth, actual, delta) \
00070 if (Abs((truth) - (actual)) > (delta)) PXErrorReturn(PX_CODE_FLOW_ERROR);
00071
00072 #define PXAssertDblEquals( truth, actual ) \
00073 CuAssertDblEquals( private_test_struct, truth, actual, 1.0e-15)
00074
00075 #define PXAssertDblRelErrWithin( truth, actual, delta) \
00076 CuAssertDblRelErrWithin( private_test_struct, truth, actual, delta )
00077
00078 #define PXAssertIntWithin( truth, actual, delta ) \
00079 if ( abs(truth - actual) > delta){\
00080 sprintf(private_test_message,"expected <%d> but was <%d>", truth, actual ); \
00081 CuFail( private_test_struct, private_test_message); }
00082
00083 #define AssertIntEquals( truth, actual ) \
00084 if ((truth) != (actual)) PXErrorReturn(PX_CODE_FLOW_ERROR);
00085
00086 #define PXAssertPtrNotNull( ptr ) \
00087 CuAssertPtrNotNull( private_test_struct, ptr )
00088
00089 #define PXAssertPtrEquals( truth, actual ) \
00090 CuAssertPtrEquals( private_test_struct, truth, actual )
00091
00092 #define PXAssertStrEquals( truth, actual ) \
00093 CuAssertStrEquals( private_test_struct, truth, actual )
00094
00095 #define AssertDblGreater( min, actual ) \
00096 if ( !((actual) > (min)) ) PXErrorReturn(PX_CODE_FLOW_ERROR);
00097
00098 #define PXAssertIsNotNaN( value ) \
00099 if ( !(value==value) ){ \
00100 sprintf(private_test_message, \
00101 "NaN encountered.\n"); \
00102 CuFail( private_test_struct, private_test_message ); }
00103
00104 #define ErrorAssert(X) do{ int _ier; _ier = (X); if (_ier != PX_NO_ERROR){ printf("Error %d (%s) has o\
00105 ccured.\n File : %s Line : %d\n Call : %s\n", _ier,PXE_ErrorCodeName[-_ier], __FILE__, __LINE__, #X); f\
00106 flush(stdout); AssertIntEquals(PX_NO_ERROR, _ier);} } while (0)
00107
00108
00109
00110 #include "NamespaceFooter.H"
00111
00112 #endif