IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17446


Ignore:
Timestamp:
Apr 12, 2008, 10:18:27 PM (18 years ago)
Author:
eugene
Message:

adding psAssert function

Location:
trunk/psLib/src/sys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psAbort.c

    r11686 r17446  
    1111 *  @author Joshua Hoblitt, University of Hawaii
    1212 *   
    13  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2007-02-07 23:52:54 $
     13 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2008-04-13 08:18:27 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4949    abort();
    5050}
     51
     52void p_psAssert(const char *file,
     53                unsigned int lineno,
     54                const char *func,
     55                const bool value,
     56                const char *format,
     57                ...)
     58{
     59    if (value) return;
     60    psErrorStackPrint(stderr, "Aborting. Error stack:");
     61
     62    va_list argPtr;             // variable list arguement pointer
     63    // Get the variable list parameters to pass to logging function
     64    va_start(argPtr, format);
     65
     66    // Call logging function with PS_LOG_ABORT level
     67    psLogMsgV("psLib.sys", PS_LOG_ABORT, format, argPtr);
     68
     69    // Clean up stack after variable arguement has been used
     70    va_end(argPtr);
     71
     72    // Call system abort function to terminate program execution
     73    abort();
     74}
  • trunk/psLib/src/sys/psAbort.h

    r14452 r17446  
    1010 *  @author Joshua Hoblitt, University of Hawaii
    1111 *
    12  *  $Revision: 1.15 $ $Name: not supported by cvs2svn $
    13  *  $Date: 2007-08-09 01:40:07 $
     12 *  $Revision: 1.16 $ $Name: not supported by cvs2svn $
     13 *  $Date: 2008-04-13 08:18:27 $
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1515 */
     
    5454#endif // ifdef DOXYGEN
    5555
     56/** Reports an abort message to logging facility
     57 *
     58 *  This function will invoke the psLogMsg function with a level of
     59 *  PS_LOG_ABORT and pass the parameters name and fmt to generate a proper
     60 *  log message.  After logging, this function will call system abort
     61 *  function to abnormally terminate the program.
     62 *
     63 *  @return  void No return value
     64 *
     65 */
     66#ifdef DOXYGEN
     67void psAssert(
     68    const bool value,
     69    const char *format,                 ///< A printf style formatting statement
     70    ...
     71);
     72#else // ifdef DOXYGEN
     73void p_psAssert(
     74    const char *file,                   ///< File of caller
     75    unsigned int lineno,                ///< Line number of caller
     76    const char *func,                   ///< Function name of caller
     77    const bool value,
     78    const char *format,                 ///< A printf style formatting statement
     79    ...
     80) PS_ATTR_FORMAT(printf, 5, 6);
     81#ifndef SWIG
     82#define psAssert(VALUE, ...) \
     83      p_psAssert(__FILE__, __LINE__, __func__, (VALUE), __VA_ARGS__)
     84#endif // iddef SWIG
     85#endif // ifdef DOXYGEN
     86
    5687/// @}
    5788#endif // #ifndef PS_ABORT_H
Note: See TracChangeset for help on using the changeset viewer.