IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11686 for trunk/psLib/src/sys


Ignore:
Timestamp:
Feb 7, 2007, 1:52:54 PM (20 years ago)
Author:
jhoblitt
Message:

update psAbort() API:

add noreturn attribute
remove unneeded 'name' params
turn into a macro so file/line/func are automatiically passed

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

Legend:

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

    r10999 r11686  
    99 *
    1010 *  @author Eric Van Alst, MHPCC
     11 *  @author Joshua Hoblitt, University of Hawaii
    1112 *   
    12  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2007-01-09 22:38:53 $
     13 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2007-02-07 23:52:54 $
    1415 *
    1516 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    2223#include <stdarg.h>
    2324#include <stdlib.h>
     25
    2426#include "psAbort.h"
    2527#include "psError.h"
    2628#include "psLogMsg.h"
    2729
    28 void psAbort(const char *name, const char *format, ...)
     30void p_psAbort(const char *file,
     31               unsigned int lineno,
     32               const char *func,
     33               const char *format,
     34               ...)
    2935{
    3036    psErrorStackPrint(stderr, "Aborting. Error stack:");
    … …  
    3541
    3642    // Call logging function with PS_LOG_ABORT level
    37     psLogMsgV(name, PS_LOG_ABORT, format, argPtr);
     43    psLogMsgV("psLib.sys", PS_LOG_ABORT, format, argPtr);
    3844
    3945    // Clean up stack after variable arguement has been used
  • trunk/psLib/src/sys/psAbort.h

    r11248 r11686  
    88 *
    99 *  @author Eric Van Alst, MHPCC
     10 *  @author Joshua Hoblitt, University of Hawaii
    1011 *
    11  *  $Revision: 1.13 $ $Name: not supported by cvs2svn $
    12  *  $Date: 2007-01-23 22:47:23 $
     12 *  $Revision: 1.14 $ $Name: not supported by cvs2svn $
     13 *  $Date: 2007-02-07 23:52:54 $
    1314 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1415 */
    … …  
    1920/// @addtogroup SysUtils System Utilities
    2021/// @{
     22
     23#include <stdarg.h>
    2124
    2225/** Reports an abort message to logging facility
    … …  
    3033 *
    3134 */
    32 #ifdef __GNUC__
     35#ifdef DOXYGEN
    3336void psAbort(
    34     const char *name,                  ///< Source of abort such as file or function detected
    35     const char *format,                   ///< A printf style formatting statement defining msg
    36     ...
    37 ) __attribute__((format(printf, 2, 3)));
    38 #else // __GNUC__
    39 void psAbort(
    40     const char *name,                  ///< Source of abort such as file or function detected
    41     const char *format,                   ///< A printf style formatting statement defining msg
     37    const char *format,                 ///< A printf style formatting statement
    4238    ...
    4339);
    44 #endif // __GNUC__
     40#else // ifdef DOXYGEN
     41void p_psAbort(
     42    const char *file,                   ///< File of caller
     43    unsigned int lineno,                ///< Line number of caller
     44    const char *func,                   ///< Function name of caller
     45    const char *format,                 ///< A printf style formatting statement
     46    ...
     47#ifdef __GNUC__
     48) __attribute__((format(printf, 4, 5), noreturn));
     49#else // ifdef __GNUC__
     50);
     51#endif // ifdef __GNUC__
     52#ifndef SWIG
     53#define psAbort(...) \
     54      p_psAbort(__FILE__, __LINE__, __func__, __VA_ARGS__)
     55#endif // iddef SWIG
     56#endif // ifdef DOXYGEN
    4557
    4658/// @}
  • trunk/psLib/src/sys/psError.c

    r11674 r11686  
    1111 *  @author Eric Van Alst, MHPCC
    1212 *
    13  *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2007-02-07 01:15:49 $
     13 *  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2007-02-07 23:52:54 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    6565        psArrayAdd(errorStack, 0, err);
    6666    } else {
    67         psAbort(__func__, "attempt to exceed maximum error stack depth of %ld",
     67        psAbort("attempt to exceed maximum error stack depth of %ld",
    6868                (long)MAX_ERROR_STACK_SIZE);
    6969    }
    … …  
    7878        // thread exits
    7979        if (pthread_key_create(&errorStack_key, psFreeWrapper)) {
    80             psAbort(__func__, "pthread_key_create() failed");
     80            psAbort("pthread_key_create failed()");
    8181        }
    8282        errorStackKeyInitialized = true;
    … …  
    9595        // param
    9696        if (pthread_setspecific(errorStack_key, errorStack)) {
    97             psAbort(__func__, "pthread_setspecific() failed");
     97            psAbort("pthread_setspecific() failed");
    9898        }
    9999    }
  • trunk/psLib/src/sys/psString.c

    r11618 r11686  
    1313 *  @author David Robbins, MHPCC
    1414 *
    15  *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2007-02-03 06:01:42 $
     15 *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2007-02-07 23:52:54 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    339339    }
    340340
    341     psAbort(__func__, "Should never get here.\n");
     341    psAbort("Should never get here.\n");
    342342    return 0;
    343343}
Note: See TracChangeset for help on using the changeset viewer.