IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4444 for trunk/psLib/src


Ignore:
Timestamp:
Jun 30, 2005, 5:57:42 PM (21 years ago)
Author:
drobbin
Message:

revised psMemory structs in accordance with psLib SDRS rev. 15. added psDataType

Location:
trunk/psLib/src/sysUtils
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sysUtils/psMemory.c

    r4401 r4444  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.57 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-06-27 20:38:12 $
     10*  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2005-07-01 03:57:39 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    8484/*
    8585 * Default callback for both allocate and free. Note that the
    86  * value of p_psMemAllocateID/p_psMemFreeID is incremented
     86 * value of p_psMemAllocID/p_psMemFreeID is incremented
    8787 * by the return value (so returning 0 means that the callback
    8888 * isn't resignalled)
    8989 */
    90 static psMemId memAllocateCallbackDefault(const psMemBlock* ptr)
    91 {
    92     static psMemId incr = 0; // "p_psMemAllocateID += incr"
     90static psMemId memAllocCallbackDefault(const psMemBlock* ptr)
     91{
     92    static psMemId incr = 0; // "p_psMemAllocID += incr"
    9393
    9494    return incr;
     
    102102}
    103103
    104 static void memProblemCallbackDefault(const psMemBlock* ptr, const char *file, psS32 lineno)
     104static void memProblemCallbackDefault( psMemBlock* ptr, const char *file, unsigned int lineno)
    105105{
    106106    if (ptr->refCounter < 1) {
     
    158158 * The default callbacks
    159159 */
    160 static psMemAllocateCallback memAllocateCallback = memAllocateCallbackDefault;
     160static psMemAllocCallback memAllocCallback = memAllocCallbackDefault;
    161161static psMemFreeCallback memFreeCallback = memFreeCallbackDefault;
    162162static psMemProblemCallback memProblemCallback = memProblemCallbackDefault;
     
    194194 * Call the callbacks when these IDs are allocated/freed
    195195 */
    196 psMemId p_psMemAllocateID = 0;       // notify user this block is allocated
     196psMemId p_psMemAllocID = 0;       // notify user this block is allocated
    197197psMemId p_psMemFreeID = 0;   // notify user this block is freed
    198198
    199 psMemId psMemAllocateCallbackSetID(psMemId id)
    200 {
    201     psMemId old = p_psMemAllocateID;
    202 
    203     p_psMemAllocateID = id;
     199psMemId psMemAllocCallbackSetID(psMemId id)
     200{
     201    psMemId old = p_psMemAllocID;
     202
     203    p_psMemAllocID = id;
    204204
    205205    return old;
     
    215215}
    216216
    217 psMemAllocateCallback psMemAllocateCallbackSet(psMemAllocateCallback func)
    218 {
    219     psMemFreeCallback old = memAllocateCallback;
     217psMemAllocCallback psMemAllocCallbackSet(psMemAllocCallback func)
     218{
     219    psMemFreeCallback old = memAllocCallback;
    220220
    221221    if (func != NULL) {
    222         memAllocateCallback = func;
     222        memAllocCallback = func;
    223223    } else {
    224         memAllocateCallback = memAllocateCallbackDefault;
     224        memAllocCallback = memAllocCallbackDefault;
    225225    }
    226226
     
    286286}
    287287
    288 psPtr p_psAlloc(size_t size, const char *file, psS32 lineno)
     288psPtr p_psAlloc(size_t size, const char *file, unsigned int lineno)
    289289{
    290290
     
    363363
    364364    // Did the user ask to be informed about this allocation?
    365     if (ptr->id == p_psMemAllocateID) {
    366         p_psMemAllocateID += memAllocateCallback(ptr);
     365    if (ptr->id == p_psMemAllocID) {
     366        p_psMemAllocID += memAllocCallback(ptr);
    367367    }
    368368    // And return the user the memory that they allocated
     
    370370}
    371371
    372 psPtr p_psRealloc(psPtr vptr, size_t size, const char *file, psS32 lineno)
     372psPtr p_psRealloc(psPtr vptr, size_t size, const char *file, unsigned int lineno)
    373373{
    374374    size = (size < recycleBinSize[0]) ? recycleBinSize[0] : size; // set the minimum size to allocate
     
    416416
    417417        // Did the user ask to be informed about this allocation?
    418         if (ptr->id == p_psMemAllocateID) {
    419             p_psMemAllocateID += memAllocateCallback(ptr);
     418        if (ptr->id == p_psMemAllocID) {
     419            p_psMemAllocID += memAllocCallback(ptr);
    420420        }
    421421
     
    424424}
    425425
    426 void p_psFree(psPtr vptr, const char *file, psS32 lineno)
     426void p_psFree(psPtr vptr, const char *file, unsigned int lineno)
    427427{
    428428    if (vptr == NULL) {
  • trunk/psLib/src/sysUtils/psMemory.h

    r4401 r4444  
    1212 *  @ingroup MemoryManagement
    1313 *
    14  *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-06-27 20:38:12 $
     14 *  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-07-01 03:57:39 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4949
    5050/// typedef for memory identification numbers.  Guaranteed to be some variety of integer.
    51 typedef psU64 psMemId;
     51typedef unsigned long psMemId;
    5252
    5353/// typedef for a memory block's reference count. Guaranteed to be some variety of integer.
    54 typedef psU64 psReferenceCount;
     54typedef unsigned long psReferenceCount;
    5555
    5656/// typedef for deallocator.
    57 typedef void (*psFreeFunc) (psPtr ptr);
     57typedef void (*psFreeFunc) (void* ptr);
    5858
    5959/** Book-keeping data for storage allocator.
     
    6464typedef struct psMemBlock
    6565{
    66     const psPtr startblock;            ///< initialised to p_psMEMMAGIC
     66    const void* startblock;            ///< initialised to p_psMEMMAGIC
    6767    struct psMemBlock* previousBlock;  ///< previous block in allocation list
    6868    struct psMemBlock* nextBlock;      ///< next block allocation list
     
    7171    const psMemId id;                  ///< a unique ID for this allocation
    7272    const char *file;                  ///< set from __FILE__ in e.g. p_psAlloc
    73     const psS32 lineno;                ///< set from __LINE__ in e.g. p_psAlloc
     73    const unsigned int lineno;         ///< set from __LINE__ in e.g. p_psAlloc
    7474    pthread_mutex_t refCounterMutex;   ///< mutex to ensure exclusive access to reference counter
    7575    psReferenceCount refCounter;       ///< how many times pointer is referenced
    76     psBool persistent;                 ///< marks if this non-user persistent data like error stack, etc.
    77     const psPtr endblock;              ///< initialised to p_psMEMMAGIC
     76    bool persistent;                   ///< marks if this non-user persistent data like error stack, etc.
     77    const void* endblock;              ///< initialised to p_psMEMMAGIC
    7878}
    7979psMemBlock;
     
    8181/** prototype of a basic callback used by memory functions
    8282 *
    83  *  @see psMemAllocateCallbackSet
    84  *  @ingroup memCallback
    85  */
    86 typedef psMemId(*psMemAllocateCallback) (
     83 *  @see psMemAllocCallbackSet
     84 *  @ingroup memCallback
     85 */
     86typedef psMemId(*psMemAllocCallback) (
    8787    const psMemBlock* ptr              ///< the psMemBlock just allocated
    8888);
     
    105105 */
    106106typedef void (*psMemProblemCallback) (
    107     const psMemBlock* ptr,             ///< the pointer to the problematic memory block.
    108     const char *file,                  ///< the file in which the problem originated
    109     psS32 lineno                         ///< the line number in which the problem originated
     107    psMemBlock* ptr,                   ///< the pointer to the problematic memory block.
     108    const char *filename,                    ///< the file in which the problem originated
     109    unsigned int lineno                ///< the line number in which the problem originated
    110110);
    111111
     
    118118 *  @ingroup memCallback
    119119 */
    120 typedef psPtr (*psMemExhaustedCallback) (
     120typedef void* (*psMemExhaustedCallback) (
    121121    size_t size                        ///< the size of buffer required
    122122);
     
    128128 */
    129129#ifdef DOXYGEN
    130 psPtr psAlloc(size_t size       ///< Size required
    131              );
     130
     131psPtr psAlloc(
     132    size_t size                        ///< Size required
     133);
     134
    132135#else // #ifdef DOXYGEN
    133 psPtr p_psAlloc(size_t size,    ///< Size required
    134                 const char *file,       ///< File of call
    135                 psS32 lineno      ///< Line number of call
    136                );
     136psPtr p_psAlloc(
     137    size_t size,                       ///< Size required
     138    const char *filename,              ///< File of call
     139    unsigned int lineno                ///< Line number of call
     140);
    137141
    138142/// Memory allocation. psAlloc sends file and line number to p_psAlloc.
     
    203207 */
    204208#ifdef DOXYGEN
     209
    205210psPtr psRealloc(
    206     psPtr ptr,                          ///< Pointer to re-allocate
    207     size_t size                         ///< Size required
     211    psPtr ptr,                         ///< Pointer to re-allocate
     212    size_t size                        ///< Size required
    208213);
    209214#else // #ifdef DOXYGEN
     215
    210216psPtr p_psRealloc(
    211217    psPtr ptr,                         ///< Pointer to re-allocate
    212218    size_t size,                       ///< Size required
    213     const char *file,                  ///< File of call
    214     psS32 lineno                       ///< Line number of call
     219    const char *filename,              ///< File of call
     220    unsigned int lineno                ///< Line number of call
    215221);
    216222
     
    234240    psPtr ptr,                         ///< Pointer to free
    235241    const char *file,                  ///< File of call
    236     psS32 lineno                       ///< Line number of call
     242    unsigned int lineno                ///< Line number of call
    237243);
    238244
     
    259265 */
    260266psS32 psMemCheckLeaks(
    261     psMemId id0,                    ///< don't list blocks with id < id0
     267    psMemId id0,                       ///< don't list blocks with id < id0
    262268    psMemBlock* ** arr,                ///< pointer to array of pointers to leaked blocks, or NULL
    263269    FILE * fd,                         ///< print list of leaks to fd (or NULL)
     
    288294#ifdef DOXYGEN
    289295psPtr psMemIncrRefCounter(
    290     const psPtr ptr                         ///< Pointer to increment refCounter, and return
     296    const psPtr ptr                    ///< Pointer to increment refCounter, and return
    291297);
    292298#else
     
    294300    psPtr vptr,                        ///< Pointer to increment refCounter, and return
    295301    const char *file,                  ///< File of call
    296     psS32 lineno                         ///< Line number of call
     302    psS32 lineno                       ///< Line number of call
    297303);
    298304
     
    318324    psPtr vptr,                        ///< Pointer to decrement refCounter, and return
    319325    const char *file,                  ///< File of call
    320     psS32 lineno                         ///< Line number of call
     326    psS32 lineno                       ///< Line number of call
    321327);
    322328
     
    362368/** Set call back for when a particular memory block is allocated
    363369 *
    364  *  A private variable, p_psMemAllocateID, can be used to trace the allocation
    365  *  and freeing of specific memory blocks. If p_psMemAllocateID is set and a
    366  *  memory block with that ID is allocated, psMemAllocateCallback is called
     370 *  A private variable, p_psMemAllocID, can be used to trace the allocation
     371 *  and freeing of specific memory blocks. If p_psMemAllocID is set and a
     372 *  memory block with that ID is allocated, psMemAllocCallback is called
    367373 *  just before memory is returned to the calling function.
    368374 *
    369375 *  @ingroup memCallback
    370376 *
    371  *  @return psMemAllocateCallback      old psMemAllocateCallback function
    372  */
    373 psMemAllocateCallback psMemAllocateCallbackSet(
    374     psMemAllocateCallback func       ///< Function to run at memory allocation of specific mem block
     377 *  @return psMemAllocCallback      old psMemAllocCallback function
     378 */
     379psMemAllocCallback psMemAllocCallbackSet(
     380    psMemAllocCallback func            ///< Function to run at memory allocation of specific mem block
    375381);
    376382
     
    398404psMemId psMemGetId(void);
    399405
    400 /** set p_psMemAllocateID to specific id
    401  *
    402  *  A private variable, p_psMemAllocateID, can be used to trace the allocation
    403  *  and freeing of specific memory blocks. If p_psMemAllocateID is set and a
    404  *  memory block with that ID is allocated, psMemAllocateCallback is called
     406/** set p_psMemAllocID to specific id
     407 *
     408 *  A private variable, p_psMemAllocID, can be used to trace the allocation
     409 *  and freeing of specific memory blocks. If p_psMemAllocID is set and a
     410 *  memory block with that ID is allocated, psMemAllocCallback is called
    405411 *  just before memory is returned to the calling function.
    406412 *
     
    409415 *  @return psMemId
    410416 *
    411  *  @see psMemAllocateCallbackSet
    412  */
    413 psMemId psMemAllocateCallbackSetID(
    414     psMemId id                      ///< ID to set
     417 *  @see psMemAllocCallbackSet
     418 */
     419psMemId psMemAllocCallbackSetID(
     420    psMemId id                         ///< ID to set
    415421);
    416422
     
    429435 */
    430436psMemId psMemFreeCallbackSetID(
    431     psMemId id                      ///< ID to set
     437    psMemId id                         ///< ID to set
    432438);
    433439
  • trunk/psLib/src/sysUtils/psType.h

    r4342 r4444  
    1010*  @author Ross Harman, MHPCC
    1111*
    12 *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-06-22 02:05:41 $
     12*  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-07-01 03:57:39 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    9494} psElemType;
    9595
     96/** Enumeration primarily used with metadata which defines a data structure
     97 *  e.g., list, array, FITS file, etc.
     98*/
     99typedef enum {
     100    PS_DATA_S32  = PS_TYPE_S32,        ///< psS32
     101    PS_DATA_F32  = PS_TYPE_F32,        ///< psF32
     102    PS_DATA_F64  = PS_TYPE_F64,        ///< psF64
     103    PS_DATA_BOOL = PS_TYPE_BOOL,       ///< psBool
     104    PS_DATA_STRING = 0x10000,          ///< psString (char *)
     105    PS_DATA_ARRAY,                     ///< psArray
     106    PS_DATA_BITSET,                    ///< psBitSet
     107    PS_DATA_CELL,                      ///< psCell
     108    PS_DATA_CHIP,                      ///< psChip
     109    PS_DATA_CUBE,                      ///< psCube
     110    PS_DATA_FITS,                      ///< psFits
     111    PS_DATA_HASH,                      ///< psHash
     112    PS_DATA_HISTOGRAM,                 ///< psHistogram
     113    PS_DATA_IMAGE,                     ///< psImage
     114    PS_DATA_KERNEL,                    ///< psKernel
     115    PS_DATA_LIST,                      ///< psList
     116    PS_DATA_LOOKUPTABLE,               ///< psLookupTable
     117    PS_DATA_METADATA,                  ///< psMetadata
     118    PS_DATA_METADATAITEM,              ///< psMetadataItem
     119    PS_DATA_MINIMIZATION,              ///< psMinimization
     120    PS_DATA_PIXELS,                    ///< psPixels
     121    PS_DATA_PLANE,                     ///< psPlane
     122    PS_DATA_PLANEDISTORT,              ///< psPlaneDistort
     123    PS_DATA_PLANETRANSFORM,            ///< psPlaneTransform
     124    PS_DATA_POLYNOMIAL1D,              ///< psPolynomial1D
     125    PS_DATA_POLYNOMIAL2D,              ///< psPolynomial2D
     126    PS_DATA_POLYNOMIAL3D,              ///< psPolynomial3D
     127    PS_DATA_POLYNOMIAL4D,              ///< psPolynomial4D
     128    PS_DATA_PROJECTION,                ///< psProjection
     129    PS_DATA_READOUT,                   ///< psReadout
     130    PS_DATA_REGION,                    ///< psRegion
     131    PS_DATA_SCALAR,                    ///< psScalar
     132    PS_DATA_SPHERE,                    ///< psSphere
     133    PS_DATA_SPHERETRANSFORM,           ///< psSphereTransform
     134    PS_DATA_SPLINE1D,                  ///< psSpline1D
     135    PS_DATA_STATS,                     ///< psStats
     136    PS_DATA_TIME,                      ///< psTime
     137    PS_DATA_VECTOR,                    ///< psVector
     138    PS_DATA_UNKNOWN,                   ///< Other data of an unknown type
     139    PS_DATA_METADATA_MULTI             ///< Used internally for metadata; not a 'real' type
     140} psDataType;
     141
    96142#define PS_TYPE_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
    97143#define PS_TYPE_MASK_DATA U8           /**< the data member to use for mask image */
Note: See TracChangeset for help on using the changeset viewer.