IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9538 for trunk/psLib/src/sys


Ignore:
Timestamp:
Oct 13, 2006, 11:13:48 AM (20 years ago)
Author:
Paul Price
Message:

Synchronising with SDRS, and cleaning up:

  • Replaced is_psType() with PS_ASSERT_PTR() throughout psLib.
  • Changed "char *" to "psString" where appropriate in psDB and a few other places (to indicate pointers on the PS memory system).
  • Removed psLogArguments and psTraceArguments (functionality in psArgumentVerbosity).
  • Renamed psMetadataLookupMD to psMetadataLookupMetadata (it was about time...). Similarly with the psPolynomial?D{From,To}MD functions.
  • Removed psMetadataRemove() since it is ambiguous about what's removed --- use psMetadataRemove{Key,Index}.
  • psArrayRemoveByPos --> psArrayRemoveIndex
  • psArrayRemove --> psArrayRemoveData
Location:
trunk/psLib/src/sys
Files:
9 edited

Legend:

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

    r8921 r9538  
    66#include <math.h>
    77
     8#include "psMemory.h"
    89#include "psError.h"
    910#include "psLogMsg.h"
     11
     12// Ensure this is a psLib pointer, by checking for the memblock bounds.
     13#define PS_ASSERT_PTR(NAME, RVAL) \
     14{ \
     15    psMemBlock *mb = (psMemBlock*)(NAME) - 1; \
     16    if (mb->startblock != P_PS_MEMMAGIC || mb->endblock != P_PS_MEMMAGIC || \
     17            *(psPtr *)((int8_t *) (mb + 1) + mb->userMemorySize) != P_PS_MEMMAGIC) { \
     18        psError(PS_ERR_MEMORY_CORRUPTION, false, \
     19                "Error: Pointer %s is corrupted or not on the PS memory system.", \
     20                #NAME); \
     21        return (RVAL); \
     22    } \
     23}
    1024
    1125#define PS_ASSERT_INT_UNEQUAL(NAME1, NAME2, RVAL) \
  • trunk/psLib/src/sys/psConfigure.c

    r8627 r9538  
    1313 *  @author Robert DeSonia, MHPCC
    1414 *
    15  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2006-08-26 04:34:28 $
     15 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2006-10-13 21:13:48 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    3434static FILE *memCheckFile = NULL;       // File to which to write results of mem check
    3535
    36 char* psLibVersion(void)
     36psString psLibVersion(void)
    3737{
    3838    char version[80];
  • trunk/psLib/src/sys/psConfigure.h

    r7646 r9538  
    1313 *  @author Robert DeSonia, MHPCC
    1414 *
    15  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2006-06-23 01:59:15 $
     15 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2006-10-13 21:13:48 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    3232 *  @return char*: String with version name.
    3333 */
    34 char* psLibVersion(
     34psString psLibVersion(
    3535    void
    3636);
  • trunk/psLib/src/sys/psLine.c

    r7950 r9538  
    33
    44#include "psMemory.h"
     5#include "psAssert.h"
    56#include "psConstants.h"
    67#include "psLine.h"
    … …  
    6465bool psMemCheckLine(psPtr ptr)
    6566{
    66     if (!is_psType(ptr)) {
    67         return false;
    68     }
     67    PS_ASSERT_PTR(ptr, false);
    6968    return ( psMemGetDeallocator(ptr) == (psFreeFunc)lineFree );
    7069}
  • trunk/psLib/src/sys/psMemory.c

    r8812 r9538  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2006-09-14 22:27:29 $
     10*  @version $Revision: 1.86 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2006-10-13 21:13:48 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    2424#include "psMemory.h"
    2525#include "psError.h"
     26#include "psAssert.h"
    2627#include "psAbort.h"
    2728#include "psLogMsg.h"
    … …  
    3536#include "psLine.h"
    3637#include "psRegion.h"
    37 
    38 #define P_PS_MEMMAGIC (psPtr )0xdeadbeef   // Magic number in psMemBlock header
    3938
    4039#define P_PS_LARGE_BLOCK_SIZE 65536        // size where under, we try to recycle
    … …  
    274273psMemId psMemGetId(void)
    275274{
    276     psMemId id;
    277 
    278     if (safeThreads) {
    279         pthread_mutex_lock(&memIdMutex);
    280     }
    281 
    282     id = memid + 1;
    283 
    284     if (safeThreads) {
    285         pthread_mutex_unlock(&memIdMutex);
    286     }
    287 
    288     return id;
     275    return psMemGetLastId() + 1;
    289276}
    290277
    … …  
    889876}
    890877
    891 bool is_psType(psPtr ptr)
    892 {
    893     if (ptr == NULL) {
    894         return false;
    895     }
    896     psMemBlock* m = ((psMemBlock* ) ptr) - 1;
    897     if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {
    898         return false; //Probably not a psAllocated-Type
    899     } else {
    900         return true;
    901     }
    902 }
    903 
    904878bool psMemCheckType(psDataType type,
    905879                    psPtr ptr)
    906880{
    907     if (!is_psType(ptr)) {
    908         return false;
    909     }
     881    PS_ASSERT_PTR(ptr, false);
    910882
    911883    switch(type) {
  • trunk/psLib/src/sys/psMemory.h

    r8705 r9538  
    1212 *  @ingroup MemoryManagement
    1313 *
    14  *  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-08-30 04:40:56 $
     14 *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-10-13 21:13:48 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    2929 *  @{
    3030 */
     31
     32#define P_PS_MEMMAGIC (psPtr)0xdeadbeef   // Magic number in psMemBlock header
    3133
    3234/**
    … …  
    172174);
    173175
    174 /** Tells whether or not a pointer has been allocated as a psDataType.
    175  *
    176  * @return bool:        True if ptr is a psDataType, otherwise false.
    177  */
    178 bool is_psType(
    179     psPtr ptr                          ///< The pointer whose type to check
    180 );
    181 
    182176/** Checks the deallocator to see if the pointer matches the desired datatype.
    183177 *
  • trunk/psLib/src/sys/psSlurp.c

    r9002 r9538  
    55 *  @author Joshua Hoblitt, University of Hawaii
    66 *
    7  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-09-27 03:50:19 $
     7 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-10-13 21:13:48 $
    99 *
    1010 *  Copyright 2006 University of Hawaii
    … …  
    1515#endif
    1616
     17#include <stdio.h>
    1718#include <unistd.h>
    1819
  • trunk/psLib/src/sys/psSlurp.h

    r8996 r9538  
     1#ifndef PS_SLURP_H
     2#define PS_SLURP_H
     3
    14#include <stdio.h>
    2 #include <pslib.h>
     5#include "psString.h"
    36
    4 psString psSlurpFD(int fd);
    5 psString psSlurpFile(FILE *stream);
     7
     8// Read ("slurp") a file (specified by file descriptor)
     9// and return a string containing the entire file.
     10psString psSlurpFD(int fd               // File descriptor to read
     11                  );
     12
     13// Read ("slurp") a file (specified by file stream)
     14// and return a string containing the entire file.
     15psString psSlurpFile(FILE *stream       // File stream to read
     16                    );
     17
     18
     19#endif
  • trunk/psLib/src/sys/psString.c

    r9509 r9538  
    1313 *  @author David Robbins, MHPCC
    1414 *
    15  *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2006-10-12 21:31:47 $
     15 *  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2006-10-13 21:13:48 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    4747bool psMemCheckString(psPtr ptr)
    4848{
    49     if (!is_psType(ptr)) {
    50         return false;
    51     }
     49    PS_ASSERT_PTR(ptr, false);
    5250    return ( psMemGetDeallocator(ptr) == (psFreeFunc)stringFree );
    5351}
Note: See TracChangeset for help on using the changeset viewer.