Changeset 1011 for trunk/src/core


Ignore:
Timestamp:
Jun 4, 2008, 11:21:15 AM (16 years ago)
Author:
dkearney
Message:

updated rappture's bindings and units dictionaries for compiling on 64bit platforms. previously (on our 32bit systems), we used integers as dictionary keys. This did not cause a problem because our pointers were also 32bits wide. On the 64bit platforms we test on, the integers are 32bits, but the pointers (and longs) are 64bits wide. The short term solution is to change our dictionary key to a long int, as was done in this changeset. the long term solution, if you choose to accept, is to swap out our RpDict? class for something more robust like the blt hash table.

Location:
trunk/src/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/RpBindingsDict.cc

    r569 r1011  
    55 * ======================================================================
    66 *  AUTHOR:  Derrick S. Kearney, Purdue University
    7  *  Copyright (c) 2004-2005  Purdue Research Foundation
     7 *  Copyright (c) 2004-2008  Purdue Research Foundation
    88 *
    99 *  See the file "license.terms" for information on usage and
     
    4444            dictKey = ObjDict_Lib.size() + 1;
    4545        }
    46         ObjDict_Lib.set(dictKey,objectName, NULL,&newEntry);
     46        long int dictKey_long = dictKey;
     47        ObjDict_Lib.set(dictKey_long,objectName,NULL,&newEntry);
    4748        retVal = dictKey;
    4849    }
     
    7071    RpDictEntry DICT_TEMPLATE_L* nullEntry = &(ObjDict_Lib.getNullEntry());
    7172
    72     libEntry = &(ObjDict_Lib.find(objKey));
     73    long int objKey_long = objKey;
     74    libEntry = &(ObjDict_Lib.find(objKey_long));
    7375
    7476
     
    138140        // no error checking to make sure it was successful in entering
    139141        // the new entry.
    140         ObjDictUnits.set(dictNextKey,objectName, NULL, &newEntry);
     142        long int dictNextKey_long = dictNextKey;
     143        ObjDictUnits.set(dictNextKey_long,objectName, NULL, &newEntry);
    141144        retVal = dictNextKey;
    142145    }
     
    160163getObject_UnitsStr(int objKey) {
    161164
    162     /*
    163     std::string basisName = *(ObjDictUnits.find(objKey).getValue());
    164 
    165     if (basisName == *(ObjDictUnits.getNullEntry().getValue())) {
    166         // basisName = "";
    167         return NULL;
    168     }
    169 
    170     return RpUnits::find(basisName);
    171     */
    172 
    173165    RpDictEntry DICT_TEMPLATE_U* unitEntry = &(ObjDictUnits.getNullEntry());
    174166    RpDictEntry DICT_TEMPLATE_U* nullEntry = &(ObjDictUnits.getNullEntry());
    175167
    176     unitEntry = &(ObjDictUnits.find(objKey));
     168    long int objKey_long = objKey;
     169    unitEntry = &(ObjDictUnits.find(objKey_long));
    177170
    178171
     
    199192
    200193    RpDictEntry DICT_TEMPLATE_U *hPtr;
    201     // RpDictIterator DICT_TEMPLATE iter(fortObjDict_Lib);
    202194    // should rp_quit clean up the dict or some function in RpBindingsCommon.h
    203195    RpDictIterator DICT_TEMPLATE_U iter(ObjDictUnits);
     
    206198
    207199    while (hPtr) {
    208         // Py_DECREF(*(hPtr->getValue()));
    209200        hPtr->erase();
    210201        hPtr = iter.next();
    211202    }
    212203
    213     // if (fortObjDict_Lib.size()) {
    214204    if (ObjDictUnits.size()) {
    215205        // probably want to change the warning sometime
    216206        // printf("\nWARNING: internal dictionary is not empty..deleting\n");
    217207    }
    218 
    219 }
     208}
  • trunk/src/core/RpBindingsDict.h

    r511 r1011  
    2828*/
    2929
    30 #define DICT_TEMPLATE_L <int,RpLibrary*>
    31 #define DICT_TEMPLATE_U <int,std::string>
     30#define DICT_TEMPLATE_L <long,RpLibrary*>
     31#define DICT_TEMPLATE_U <long,std::string>
    3232
    3333// global declaration of library and units dictionaries
  • trunk/src/core/RpDict.h

    r962 r1011  
    44 *
    55 *  AUTHOR:  Derrick Kearney, Purdue University
    6  *  Copyright (c) 2004-2005  Purdue Research Foundation
     6 *  Copyright (c) 2004-2008  Purdue Research Foundation
    77 *
    88 *  See the file "license.terms" for information on usage and
     
    1515#include <stdlib.h>
    1616#include <errno.h>
    17 //#include <malloc.h>
    1817
    1918#ifndef _RpDICT_H
     
    5857
    5958    public:
    60 
    61         // public data members
    62 
    63         // public member functions
    6459
    6560        // retrieve the table the iterator is iterating
     
    114109{
    115110    public:
    116 
    117         // public member functions
    118111
    119112        operator int() const;
     
    133126        void erase();
    134127
    135         // template <KeyType,ValType> friend class RpDict;
    136         // template <KeyType,ValType> friend class RpDictIterator;
    137 
    138128        friend class RpDict<KeyType,ValType,_Compare>;
    139129        friend class RpDictIterator<KeyType,ValType,_Compare>;
    140 
    141         // one-arg constructor
    142         // maybe get rid of this one?
    143         // use the clientData's default [no-arg] constructor
    144         /*
    145         RpDictEntry(KeyType newKey)
    146            : nextPtr    (NULL),
    147              tablePtr   (NULL),
    148              hash       (0),
    149              // clientData (NULL),
    150              key        (newKey)
    151         {
    152         }
    153         */
    154130
    155131        // two-arg constructor
     
    164140        }
    165141
    166 /*
    167         RpDictEntry(KeyType* newKey, ValType* newVal)
    168            : nextPtr    (NULL),
    169              tablePtr   (NULL),
    170              hash       (0),
    171              clientData (*newVal),
    172              key        (*newKey)
    173         {
    174         }
    175 
    176         RpDictEntry(KeyType newKey, RpDict* table)
    177            : nextPtr    (NULL),
    178              tablePtr   (table),
    179              hash       (0),
    180              // clientData (NULL),
    181              key        (newKey)
    182         {
    183         }
    184 */
    185142        // copy constructor
    186143        RpDictEntry (const RpDictEntry<KeyType,ValType,_Compare>& entry)
     
    203160    private:
    204161
    205         // private data members
    206162        RpDictEntry<KeyType,ValType,_Compare>*
    207163            nextPtr;                /* Pointer to next entry in this
     
    221177        ValType* valid;            /* is this a valid object */
    222178
    223 
    224         // no_arg constructor
    225         //
    226179        RpDictEntry()
    227180           : nextPtr (NULL),
     
    301254              caseInsensitive(ci)
    302255        {
    303 
    304256            staticBuckets[0] = staticBuckets[1] = 0;
    305257            staticBuckets[2] = staticBuckets[3] = 0;
     
    309261
    310262            assert(nullEntry != NULL);
    311 
    312             // std::cout << "inside RpDict Constructor" << std::endl;
    313 
    314263        }
    315264
     
    338287                                       * element points to first entry in
    339288                                       * bucket's hash chain, or NULL. */
    340         // RpDictEntry *staticBuckets[SMALL_RP_DICT_SIZE];
    341289        RpDictEntry<KeyType,ValType,_Compare>
    342290                    *staticBuckets[4];
     
    382330/*--------------------------------------------------------------------------*/
    383331
    384 
    385 // public RpDict member functions
    386 
    387 
    388332/**************************************************************************
    389333 *
     
    400344 *************************************************************************/
    401345
    402 template <typename KeyType, typename ValType, class _Compare> 
    403 const int 
     346template <typename KeyType, typename ValType, class _Compare>
     347const int
    404348RpDict<KeyType,ValType,_Compare>::size() const
    405349{
     
    411355 *
    412356 * RpDict::set()
    413  *  checks to make sure the table exists. 
     357 *  checks to make sure the table exists.
    414358 *  places a key/value pair into the hash table
    415359 *
    416360 * Results:
    417361 *  Returns a reference to the RpDict object allowing the user to chain
    418  *  together different commands such as 
     362 *  together different commands such as
    419363 *      rpdict_obj.set(key).find(a).erase(a);
    420364 *
     
    1015959/*************************************************************************/
    1016960
    1017 // private member functions
    1018 
    1019961/*
    1020962 *----------------------------------------------------------------------
     
    1046988    RpDictEntry<KeyType,ValType,_Compare> *hPtr = NULL;
    1047989
    1048     // void *key = NULL;
    1049 
    1050990    oldSize = numBuckets;
    1051991    oldBuckets = buckets;
     
    10631003
    10641004    for (count = numBuckets, newChainPtr = buckets;
    1065         count > 0; 
     1005        count > 0;
    10661006        count--, newChainPtr++) {
    10671007
     
    10801020        for (hPtr = *oldChainPtr; hPtr != NULL; hPtr = *oldChainPtr) {
    10811021            *oldChainPtr = hPtr->nextPtr;
    1082 
    1083             // key = (void *) hPtr->getKey();
    10841022
    10851023            index = randomIndex(hPtr->hash);
Note: See TracChangeset for help on using the changeset viewer.