IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 6, 2007, 2:36:02 PM (19 years ago)
Author:
jhoblitt
Message:

remove all use of psType.h types -- psMemory.h now has no ps*.h dependencies
remove "const void *" functions parameters because of sporadic compilation warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psMemory.h

    r11416 r11672  
    1515 *  @ingroup MemoryManagement
    1616 *
    17  *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
    18  *  @date $Date: 2007-01-30 03:00:50 $
     17 *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
     18 *  @date $Date: 2007-02-07 00:36:02 $
    1919 *
    2020 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2727/// @{
    2828
    29 #include <stdio.h>                     // needed for FILE
    30 #include <pthread.h>                   // we need a mutex to make this stuff thread safe.
    31 #include "psType.h"
     29#include <stdio.h>                      // needed for FILE
     30#include <pthread.h>                    // we need a mutex to make this stuff thread safe.
     31#include <stdint.h>                     // for uint32_t
     32#include <stdbool.h>
    3233
    3334/** @addtogroup MemoryManagement
     
    3536 */
    3637
    37 #define P_PS_MEMMAGIC (psU32)0xdeadbeef   // Magic number in psMemBlock header
     38#define P_PS_MEMMAGIC (uint32_t)0xdeadbeef   // Magic number in psMemBlock header
    3839
    3940/// typedef for memory identification numbers.  Guaranteed to be some variety of integer.
     
    4445
    4546/// typedef for deallocator.
    46 typedef void (*psFreeFunc) (void* ptr);
     47typedef void (*psFreeFunc) (void *ptr);
    4748
    4849/** Book-keeping data for storage allocator.
     
    5758typedef struct psMemBlock
    5859{
    59     const psU32 startblock;            ///< initialised to p_psMEMMAGIC
     60    const uint32_t startblock;            ///< initialised to p_psMEMMAGIC
    6061    struct psMemBlock* previousBlock;  ///< previous block in allocation list
    6162    struct psMemBlock* nextBlock;      ///< next block allocation list
     
    7576    psReferenceCount refCounter;       ///< how many times pointer is referenced
    7677    bool persistent;                   ///< marks if this non-user persistent data like error stack, etc.
    77     const psU32 endblock;              ///< initialised to p_psMEMMAGIC
     78    const uint32_t endblock;              ///< initialised to p_psMEMMAGIC
    7879}
    7980psMemBlock;
     
    109110/** prototype of a callback function used when memory runs out
    110111 *
    111  *  @return psPtr pointer to requested buffer of the size size_t, or NULL if memory could not
     112 *  @return void * pointer to requested buffer of the size size_t, or NULL if memory could not
    112113 *          be found.
    113114 *
    114115 *  @see psMemExhaustedCallbackSet
    115116 */
    116 typedef psPtr (*psMemExhaustedCallback) (
     117typedef void *(*psMemExhaustedCallback) (
    117118    size_t size                        ///< the size of buffer required
    118119);
     
    120121/** Memory allocation.  This operates much like malloc(), but is guaranteed to return a non-NULL value.
    121122 *
    122  *  @return psPtr pointer to the allocated buffer. This will not be NULL.
     123 *  @return void * pointer to the allocated buffer. This will not be NULL.
    123124 *  @see psFree
    124125 */
    125126#ifdef DOXYGEN
    126127
    127 psPtr psAlloc(
     128void *psAlloc(
    128129    size_t size                        ///< Size required
    129130);
     
    132133
    133134#ifdef __GNUC__
    134 psPtr p_psAlloc(
     135void *p_psAlloc(
    135136    size_t size,                       ///< Size required
    136137    const char *file,                  ///< File of caller
     
    139140) __attribute__((malloc));
    140141# else // __GNUC__
    141 
    142     psPtr p_psAlloc(
     142    void *p_psAlloc(
    143143        size_t size,                       ///< Size required
    144144        const char *file,                  ///< File of caller
     
    167167
    168168void psMemSetDeallocator(
    169     psPtr ptr,                         ///< the memory block to operate on
     169    void *ptr,                         ///< the memory block to operate on
    170170    psFreeFunc freeFunc                ///< the function to be executed at deallocation
    171171);
     
    174174
    175175void p_psMemSetDeallocator(
    176     psPtr ptr,                          ///< the memory block to operate on
     176    void *ptr,                          ///< the memory block to operate on
    177177    psFreeFunc freeFunc,                ///< the function to be executed at deallocation
    178178    const char *file,                   ///< File of caller
     
    201201
    202202psFreeFunc psMemGetDeallocator(
    203     const psPtr ptr                     ///< the memory block
     203    void *ptr                     ///< the memory block
    204204);
    205205
     
    207207
    208208psFreeFunc p_psMemGetDeallocator(
    209     const psPtr ptr,                    ///< the memory block
     209    void *ptr,                    ///< the memory block
    210210    const char *file,                   ///< File of caller
    211211    unsigned int lineno,                ///< Line number of caller
     
    256256
    257257void psMemSetPersistent(
    258     psPtr ptr,                         ///< the memory block to operate on
    259     bool value,                        ///< true if memory is persistent, otherwise false
     258    void *ptr,                          ///< the memory block to operate on
     259    bool value,                         ///< true if memory is persistent, otherwise false
    260260);
    261261
     
    263263
    264264void p_psMemSetPersistent(
    265     psPtr ptr,                         ///< the memory block to operate on
    266     bool value,                        ///< true if memory is persistent, otherwise false
    267     const char *file,                  ///< File of caller
    268     unsigned int lineno,               ///< Line number of caller
    269     const char *func                   ///< Function name of caller
     265    void *ptr,                          ///< the memory block to operate on
     266    bool value,                         ///< true if memory is persistent, otherwise false
     267    const char *file,                   ///< File of caller
     268    unsigned int lineno,                ///< Line number of caller
     269    const char *func                    ///< Function name of caller
    270270);
    271271
     
    299299
    300300bool psMemGetPersistent(
    301     psPtr ptr,                         ///< the memory block to check.
     301    void *ptr,                          ///< the memory block to check.
    302302);
    303303#else // ifdef DOXYGEN
    304304
    305305bool p_psMemGetPersistent(
    306     psPtr ptr,                         ///< the memory block to check.
    307     const char *file,                  ///< File of caller
    308     unsigned int lineno,               ///< Line number of caller
    309     const char *func                   ///< Function name of caller
     306    void *ptr,                          ///< the memory block to check.
     307    const char *file,                   ///< File of caller
     308    unsigned int lineno,                ///< Line number of caller
     309    const char *func                    ///< Function name of caller
    310310);
    311311
     
    320320/** Memory re-allocation.  This operates much like realloc(), but is guaranteed to return a non-NULL value.
    321321 *
    322  *  @return psPtr pointer to resized buffer. This will not be NULL.
     322 *  @return void * pointer to resized buffer. This will not be NULL.
    323323 *  @see psAlloc, psFree
    324324 */
    325325#ifdef DOXYGEN
    326326
    327 psPtr psRealloc(
    328     psPtr ptr,                         ///< Pointer to re-allocate
    329     size_t size                        ///< Size required
     327void *psRealloc(
     328    void *ptr,                          ///< Pointer to re-allocate
     329    size_t size                         ///< Size required
    330330);
    331331#else // #ifdef DOXYGEN
    332 
    333332#ifdef __GNUC__
    334 psPtr p_psRealloc(
    335     psPtr ptr,                         ///< Pointer to re-allocate
    336     size_t size,                       ///< Size required
    337     const char *file,                  ///< File of caller
    338     unsigned int lineno,               ///< Line number of caller
    339     const char *func                   ///< Function name of caller
     333void *p_psRealloc(
     334    void *ptr,                          ///< Pointer to re-allocate
     335    size_t size,                        ///< Size required
     336    const char *file,                   ///< File of caller
     337    unsigned int lineno,                ///< Line number of caller
     338    const char *func                    ///< Function name of caller
    340339) __attribute__((malloc));
    341340# else // __GNUC__
    342 
    343     psPtr p_psRealloc(
    344         psPtr ptr,                         ///< Pointer to re-allocate
    345         size_t size,                       ///< Size required
    346         const char *file,                  ///< File of caller
    347         unsigned int lineno,               ///< Line number of caller
    348         const char *func                   ///< Function name of caller
     341    void *p_psRealloc(
     342        void *ptr,                          ///< Pointer to re-allocate
     343        size_t size,                        ///< Size required
     344        const char *file,                   ///< File of caller
     345        unsigned int lineno,                ///< Line number of caller
     346        const char *func                    ///< Function name of caller
    349347    );
    350348#endif // __GNUC__
     
    365363#ifdef DOXYGEN
    366364void psFree(
    367     psPtr ptr                          ///< Pointer to free, if NULL, function returns immediately.
     365    void *ptr                           ///< Pointer to free, if NULL, function returns immediately.
    368366);
    369367#else // #ifdef DOXYGEN
     
    372370#ifndef SWIG
    373371#define            psFree(ptr) \
    374 p_psMemDecrRefCounter((psPtr *)ptr, __FILE__, __LINE__, __func__);
     372p_psMemDecrRefCounter((void **)ptr, __FILE__, __LINE__, __func__);
    375373#endif // ! SWIG
    376374
     
    449447
    450448psReferenceCount psMemGetRefCounter(
    451     const psPtr ptr                    ///< Pointer to get refCounter for
     449    void *ptr                     ///< Pointer to get refCounter for
    452450);
    453451
     
    455453
    456454psReferenceCount p_psMemGetRefCounter(
    457     const psPtr ptr,                   ///< Pointer to get refCounter for
    458     const char *file,                  ///< File of call
    459     unsigned int lineno,               ///< Line number of call
    460     const char *func                   ///< Function name of caller
     455    void *ptr,                    ///< Pointer to get refCounter for
     456    const char *file,                   ///< File of call
     457    unsigned int lineno,                ///< Line number of call
     458    const char *func                    ///< Function name of caller
    461459);
    462460
     
    471469/** Increment reference counter and return the pointer
    472470 *
    473  *  @return psPtr
    474  *
    475  */
    476 #ifdef DOXYGEN
    477 
    478 psPtr psMemIncrRefCounter(
    479     const psPtr ptr                    ///< Pointer to increment refCounter, and return
     471 *  @return void *
     472 *
     473 */
     474#ifdef DOXYGEN
     475
     476void *psMemIncrRefCounter(
     477    void *ptr                           ///< Pointer to increment refCounter, and return
    480478);
    481479#else // ifdef DOXYGEN
    482480
    483 psPtr p_psMemIncrRefCounter(
    484     const psPtr ptr,                  ///< Pointer to increment refCounter, and return
    485     const char *file,                  ///< File of call
    486     unsigned int lineno,               ///< Line number of call
    487     const char *func                   ///< Function name of caller
     481void *p_psMemIncrRefCounter(
     482    void *ptr,                          ///< Pointer to increment refCounter, and return
     483    const char *file,                   ///< File of call
     484    unsigned int lineno,                ///< Line number of call
     485    const char *func                    ///< Function name of caller
    488486);
    489487
     
    499497 *
    500498 *
    501  *  @return psPtr    the pointer deremented in refCount, or NULL if pointer is
     499 *  @return void *    the pointer deremented in refCount, or NULL if pointer is
    502500 *                   fully dereferenced.
    503501 */
    504502#ifdef DOXYGEN
    505503
    506 psPtr psMemDecrRefCounter(
    507     psPtr ptr                         ///< Pointer to decrement refCounter, and return
     504void *psMemDecrRefCounter(
     505    void *ptr                           ///< Pointer to decrement refCounter, and return
    508506);
    509507
    510508#else // DOXYGEN
    511509
    512 psPtr p_psMemDecrRefCounter(
    513     psPtr ptr,                        ///< Pointer to decrement refCounter, and return
    514     const char *file,                  ///< File of call
    515     unsigned int lineno,               ///< Line number of call
    516     const char *func                   ///< Function name of caller
     510void *p_psMemDecrRefCounter(
     511    void *ptr,                          ///< Pointer to decrement refCounter, and return
     512    const char *file,                   ///< File of call
     513    unsigned int lineno,                ///< Line number of call
     514    const char *func                    ///< Function name of caller
    517515);
    518516
     
    527525/** Set reference counter and return the pointer
    528526 *
    529  *  @return psPtr    the pointer with refCount set, or NULL if pointer is
     527 *  @return void *    the pointer with refCount set, or NULL if pointer is
    530528 *                   fully dereferenced.
    531529 */
    532530#ifdef DOXYGEN
    533 psPtr psMemSetRefCounter(
    534     psPtr ptr,                        ///< Pointer to decrement refCounter, and return
     531void * psMemSetRefCounter(
     532    void * ptr,                        ///< Pointer to decrement refCounter, and return
    535533    psReferenceCount count            ///< New reference count
    536534);
    537535#else // DOXYGEN
    538 psPtr p_psMemSetRefCounter(
    539     psPtr vptr,                        ///< Pointer to decrement refCounter, and return
     536void * p_psMemSetRefCounter(
     537    void * vptr,                        ///< Pointer to decrement refCounter, and return
    540538    psReferenceCount count,            ///< New reference count
    541539    const char *file,                  ///< File of call
Note: See TracChangeset for help on using the changeset viewer.