Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3076

Show
Ignore:
Timestamp:
01/08/08 14:21:02 (1 year ago)
Author:
sean
Message:

I have changed quite a few occurrences of uint to size_t where the value represented a size or length. This should address the GDC/amd64 build issues, but I haven't tested in this config to verify that all errors have been fixed. Still, I am marking the ticket as closed. Please reopen if further errors exist. This closes #845.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/gc/basic/gcbits.d

    r2356 r3076  
    5151    const int BITS_MASK = 31; 
    5252 
    53     uint *data = null; 
    54     uint nwords = 0;    // allocated words in data[] excluding sentinals 
    55     uint nbits = 0;     // number of bits in data[] excluding sentinals 
     53    uintdata = null; 
     54    size_t nwords = 0;    // allocated words in data[] excluding sentinals 
     55    size_t nbits = 0;     // number of bits in data[] excluding sentinals 
    5656 
    5757    void Dtor() 
     
    7272    } 
    7373 
    74     void alloc(uint nbits) 
     74    void alloc(size_t nbits) 
    7575    { 
    7676        this.nbits = nbits; 
    7777        nwords = (nbits + (BITS_PER_WORD - 1)) >> BITS_SHIFT; 
    78         data = cast(uint *)calloc(nwords + 2, uint.sizeof); 
     78        data = cast(uint*)calloc(nwords + 2, uint.sizeof); 
    7979        if (!data) 
    8080            onOutOfMemoryError(); 
    8181    } 
    8282 
    83     uint test(uint i) 
     83    uint test(size_t i) 
    8484    in 
    8585    { 
     
    9292    } 
    9393 
    94     void set(uint i) 
     94    void set(size_t i) 
    9595    in 
    9696    { 
     
    103103    } 
    104104 
    105     void clear(uint i) 
     105    void clear(size_t i) 
    106106    in 
    107107    { 
     
    114114    } 
    115115 
    116     uint testClear(uint i) 
     116    uint testClear(size_t i) 
    117117    { 
    118118        version (bitops) 
     
    138138            //(cast(bit *)(data + 1))[i] = 0; 
    139139 
    140             uint *p = &data[1 + (i >> BITS_SHIFT)]; 
    141             uint mask = (1 << (i & BITS_MASK)); 
     140            uint* p = &data[1 + (i >> BITS_SHIFT)]; 
     141            uint mask = (1 << (i & BITS_MASK)); 
    142142            result = *p & mask; 
    143143            *p &= ~mask; 
     
    161161    } 
    162162 
    163     uint *base() 
     163    uint* base() 
    164164    in 
    165165    { 
  • trunk/lib/gc/basic/gcx.d

    r3073 r3076  
    117117        void*  p; 
    118118        size_t size; 
    119         uint  line; 
     119        size_t line; 
    120120        char*  file; 
    121121        void*  parent; 
     
    155155                if (!data) 
    156156                { 
    157                     data = cast(Log *)cstdlib.malloc(allocdim * Log.sizeof); 
     157                    data = cast(Log*)cstdlib.malloc(allocdim * Log.sizeof); 
    158158                    if (!data && allocdim) 
    159159                        onOutOfMemoryError(); 
     
    162162                {   Log *newdata; 
    163163 
    164                     newdata = cast(Log *)cstdlib.malloc(allocdim * Log.sizeof); 
     164                    newdata = cast(Log*)cstdlib.malloc(allocdim * Log.sizeof); 
    165165                    if (!newdata && allocdim) 
    166166                        onOutOfMemoryError(); 
     
    232232    { 
    233233        gcLock = GCLock.classinfo; 
    234         gcx = cast(Gcx *)cstdlib.calloc(1, Gcx.sizeof); 
     234        gcx = cast(Gcx*)cstdlib.calloc(1, Gcx.sizeof); 
    235235        if (!gcx) 
    236236            onOutOfMemoryError(); 
     
    317317            if (pool) 
    318318            { 
    319                 uint biti = (p - pool.baseAddr) / 16; 
     319                auto biti = cast(size_t)(p - pool.baseAddr) / 16; 
    320320 
    321321                oldb = gcx.getBits(pool, biti); 
     
    352352            if (pool) 
    353353            { 
    354                 uint biti = (p - pool.baseAddr) / 16; 
     354                auto biti = cast(size_t)(p - pool.baseAddr) / 16; 
    355355 
    356356                oldb = gcx.getBits(pool, biti); 
     
    388388            if (pool) 
    389389            { 
    390                 uint biti = (p - pool.baseAddr) / 16; 
     390                auto biti = cast(size_t)(p - pool.baseAddr) / 16; 
    391391 
    392392                oldb = gcx.getBits(pool, biti); 
     
    492492 
    493493            // Return next item from free list 
    494             gcx.bucket[bin] = (cast(List *)p).next; 
     494            gcx.bucket[bin] = (cast(List*)p).next; 
    495495            if( !(bits & BlkAttr.NO_SCAN) ) 
    496496                cstring.memset(p + size, 0, binsize[bin] - size); 
     
    514514            assert(pool); 
    515515 
    516             gcx.setBits(pool, (p - pool.baseAddr) / 16, bits); 
     516            gcx.setBits(pool, cast(size_t)(p - pool.baseAddr) / 16, bits); 
    517517        } 
    518518        return p; 
     
    603603                        if (pool) 
    604604                        { 
    605                             uint biti = cast(uint)(p - pool.baseAddr) / 16; 
     605                            auto biti = cast(size_t)(p - pool.baseAddr) / 16; 
    606606 
    607607                            if (bits) 
     
    683683                        if (pool) 
    684684                        { 
    685                             uint biti = cast(uint)(p - pool.baseAddr) / 16; 
     685                            auto biti = cast(size_t)(p - pool.baseAddr) / 16; 
    686686 
    687687                            if (bits) 
     
    850850        assert (p); 
    851851 
    852         Pool *pool; 
    853         uint pagenum; 
    854         Bins bin; 
    855         uint biti; 
     852        Poolpool; 
     853        size_t pagenum; 
     854        Bins   bin; 
     855        size_t biti; 
    856856 
    857857        // Find which page it is in 
     
    861861        sentinel_Invariant(p); 
    862862        p = sentinel_sub(p); 
    863         pagenum = (p - pool.baseAddr) / PAGESIZE; 
    864         biti = cast(uint)(p - pool.baseAddr) / 16; 
     863        pagenum = cast(size_t)(p - pool.baseAddr) / PAGESIZE; 
     864        biti = cast(size_t)(p - pool.baseAddr) / 16; 
    865865        gcx.clrBits(pool, biti, BlkAttr.ALL_BITS); 
    866866 
    867867        bin = cast(Bins)pool.pagetable[pagenum]; 
    868868        if (bin == B_PAGE)              // if large alloc 
    869         {   int npages; 
    870             uint n; 
     869        {   size_t npages; 
     870            size_t n; 
    871871 
    872872            // Free pages 
     
    880880        else 
    881881        {   // Add to free list 
    882             List *list = cast(List *)p; 
     882            List *list = cast(List*)p; 
    883883 
    884884            debug (MEMSTOMP) cstring.memset(p, 0xF2, binsize[bin]); 
     
    10621062        { 
    10631063            Pool*  pool; 
    1064             uint  pagenum; 
     1064            size_t pagenum; 
    10651065            Bins   bin; 
    10661066            size_t size; 
     
    10691069            pool = gcx.findPool(p); 
    10701070            assert(pool); 
    1071             pagenum = (p - pool.baseAddr) / PAGESIZE; 
     1071            pagenum = cast(size_t)(p - pool.baseAddr) / PAGESIZE; 
    10721072            bin = cast(Bins)pool.pagetable[pagenum]; 
    10731073            assert(bin <= B_PAGE); 
     
    10841084                    for (list = gcx.bucket[bin]; list; list = list.next) 
    10851085                    { 
    1086                         assert(cast(void *)list != p); 
     1086                        assert(cast(void*)list != p); 
    10871087                    } 
    10881088                } 
     
    11121112            { 
    11131113                //debug(PRINTF) printf("setStackBottom(%x)\n", p); 
    1114                 gcx.stackBottom = cast(char *)p; 
     1114                gcx.stackBottom = cast(char*)p; 
    11151115            } 
    11161116        } 
     
    12891289 
    12901290            psize += pool.ncommitted * PAGESIZE; 
    1291             for (uint j = 0; j < pool.ncommitted; j++) 
     1291            for (size_t j = 0; j < pool.ncommitted; j++) 
    12921292            { 
    12931293                Bins bin = cast(Bins)pool.pagetable[j]; 
     
    14171417    {   int dummy; 
    14181418 
    1419         (cast(byte *)this)[0 .. Gcx.sizeof] = 0; 
    1420         stackBottom = cast(char *)&dummy; 
     1419        (cast(byte*)this)[0 .. Gcx.sizeof] = 0; 
     1420        stackBottom = cast(char*)&dummy; 
    14211421        log_init(); 
    14221422        debug (THREADINVARIANT) 
     
    14311431        inited = 0; 
    14321432 
    1433         for (uint i = 0; i < npools; i++) 
     1433        for (size_t i = 0; i < npools; i++) 
    14341434        {   Pool *pool = pooltable[i]; 
    14351435 
     
    14561456        { 
    14571457        //printf("Gcx.invariant(): this = %p\n", this); 
    1458             uint i; 
     1458            size_t i; 
    14591459 
    14601460            // Assure we're called on the right thread 
     
    15181518            void** newroots; 
    15191519 
    1520             newroots = cast(void **)cstdlib.malloc(newdim * newroots[0].sizeof); 
     1520            newroots = cast(void**)cstdlib.malloc(newdim * newroots[0].sizeof); 
    15211521            if (!newroots) 
    15221522                onOutOfMemoryError(); 
     
    15631563            Range *newranges; 
    15641564 
    1565             newranges = cast(Range *)cstdlib.malloc(newdim * newranges[0].sizeof); 
     1565            newranges = cast(Range*)cstdlib.malloc(newdim * newranges[0].sizeof); 
    15661566            if (!newranges) 
    15671567                onOutOfMemoryError(); 
     
    16181618            } 
    16191619 
    1620             for (uint i = 0; i < npools; i++) 
     1620            for (size_t i = 0; i < npools; i++) 
    16211621            {   Pool *pool; 
    16221622 
     
    16451645        { 
    16461646            size_t offset = cast(size_t)(p - pool.baseAddr); 
    1647             uint pn = offset / PAGESIZE; 
    1648             Bins bin = cast(Bins)pool.pagetable[pn]; 
     1647            size_t pn = offset / PAGESIZE; 
     1648            Bins   bin = cast(Bins)pool.pagetable[pn]; 
    16491649 
    16501650            // Adjust bit to be at start of allocated memory block 
     
    16771677    size_t findSize(void *p) 
    16781678    { 
    1679         Pool *pool; 
     1679        Poolpool; 
    16801680        size_t size = 0; 
    16811681 
     
    16831683        if (pool) 
    16841684        { 
    1685             uint pagenum; 
    1686             Bins bin; 
    1687  
    1688             pagenum = (cast(uint)(p - pool.baseAddr)) / PAGESIZE; 
     1685            size_t pagenum; 
     1686            Bins   bin; 
     1687 
     1688            pagenum = cast(size_t)(p - pool.baseAddr) / PAGESIZE; 
    16891689            bin = cast(Bins)pool.pagetable[pagenum]; 
    16901690            size = binsize[bin]; 
    16911691            if (bin == B_PAGE) 
    1692             {   uint npages = pool.ncommitted; 
     1692            {   size_t npages = pool.ncommitted; 
    16931693                ubyte* pt; 
    1694                 uint i; 
     1694                size_t i; 
    16951695 
    16961696                pt = &pool.pagetable[0]; 
     
    17121712    BlkInfo getInfo(void* p) 
    17131713    { 
    1714         Pool *pool; 
     1714        Pool*   pool; 
    17151715        BlkInfo info; 
    17161716 
     
    17191719        { 
    17201720            size_t offset = cast(size_t)(p - pool.baseAddr); 
    1721             uint pn = offset / PAGESIZE; 
    1722             Bins bin = cast(Bins)pool.pagetable[pn]; 
     1721            size_t pn = offset / PAGESIZE; 
     1722            Bins   bin = cast(Bins)pool.pagetable[pn]; 
    17231723 
    17241724            //////////////////////////////////////////////////////////////////// 
     
    17481748            info.size = binsize[bin]; 
    17491749            if (bin == B_PAGE) 
    1750             {   uint npages = pool.ncommitted; 
     1750            {   size_t npages = pool.ncommitted; 
    17511751                ubyte* pt; 
    1752                 uint i; 
     1752                size_t i; 
    17531753 
    17541754                pt = &pool.pagetable[0]; 
     
    17651765            //////////////////////////////////////////////////////////////////// 
    17661766 
    1767             info.attr = getBits(pool, offset / 16); 
     1767            info.attr = getBits(pool, cast(size_t)(offset / 16)); 
    17681768        } 
    17691769        return info; 
     
    18251825    size_t reserve(size_t size) 
    18261826    { 
    1827         uint npages = (size + PAGESIZE - 1) / PAGESIZE; 
    1828         Pool *pool = newPool(npages); 
     1827        size_t npages = (size + PAGESIZE - 1) / PAGESIZE; 
     1828        Poolpool = newPool(npages); 
    18291829 
    18301830        if (!pool || pool.extendPages(npages) == ~0u) 
     
    18401840    void *bigAlloc(size_t size) 
    18411841    { 
    1842         Pool *pool; 
    1843         uint npages; 
    1844         uint n; 
    1845         uint pn; 
    1846         uint freedpages; 
    1847         void *p; 
    1848         int state; 
     1842        Poolpool; 
     1843        size_t npages; 
     1844        size_t n; 
     1845        size_t pn; 
     1846        size_t freedpages; 
     1847        voidp; 
     1848        int    state; 
    18491849 
    18501850        npages = (size + PAGESIZE - 1) / PAGESIZE; 
     
    19211921     * Return null if failed. 
    19221922     */ 
    1923     Pool *newPool(uint npages) 
    1924     { 
    1925         Pool *pool; 
    1926         Pool **newpooltable; 
    1927         uint newnpools; 
    1928         uint i; 
     1923    Pool *newPool(size_t npages) 
     1924    { 
     1925        Poolpool; 
     1926        Pool** newpooltable; 
     1927        size_t newnpools; 
     1928        size_t i; 
    19291929 
    19301930        //debug(PRINTF) printf("************Gcx::newPool(npages = %d)****************\n", npages); 
     
    19451945        // Allocate successively larger pools up to 8 megs 
    19461946        if (npools) 
    1947         {   uint n; 
     1947        {   size_t n; 
    19481948 
    19491949            n = npools; 
     
    19981998    int allocPage(Bins bin) 
    19991999    { 
    2000         Pool *pool; 
    2001         uint n; 
    2002         uint pn; 
    2003         byte *p; 
    2004         byte *ptop; 
     2000        Poolpool; 
     2001        size_t n; 
     2002        size_t pn; 
     2003        bytep; 
     2004        byteptop; 
    20052005 
    20062006        //debug(PRINTF) printf("Gcx::allocPage(bin = %d)\n", bin); 
     
    20542054                { 
    20552055                    size_t offset = cast(size_t)(p - pool.baseAddr); 
    2056                     uint biti; 
    2057                     uint pn = offset / PAGESIZE; 
    2058                     Bins bin = cast(Bins)pool.pagetable[pn]; 
     2056                    size_t biti; 
     2057                    size_t pn = offset / PAGESIZE; 
     2058                    Bins   bin = cast(Bins)pool.pagetable[pn]; 
    20592059 
    20602060                    //debug(PRINTF) printf("\t\tfound pool %x, base=%x, pn = %d, bin = %d, biti = x%x\n", pool, pool.baseAddr, pn, bin, biti); 
     
    21412141    size_t fullcollect(void *stackTop) 
    21422142    { 
    2143         uint n; 
    2144         Pool *pool; 
     2143        size_t n; 
     2144        Poolpool; 
    21452145 
    21462146        debug(COLLECT_PRINTF) printf("Gcx.fullcollect()\n"); 
     
    21672167                pool = findPool(list); 
    21682168                assert(pool); 
    2169                 pool.freebits.set(cast(uint)(cast(byte *)list - pool.baseAddr) / 16); 
     2169                pool.freebits.set(cast(size_t)(cast(byte*)list - pool.baseAddr) / 16); 
    21702170            } 
    21712171        } 
     
    22292229                btop = bbase + pool.scan.nwords; 
    22302230                for (b = bbase; b < btop;) 
    2231                 {   Bins bin; 
    2232                     uint pn; 
    2233                     uint u; 
    2234                     uint bitm; 
    2235                     byte *o; 
     2231                {   Bins   bin; 
     2232                    size_t pn; 
     2233                    size_t u; 
     2234                    size_t bitm; 
     2235                    byteo; 
    22362236 
    22372237                    bitm = *b; 
     
    22832283        size_t freed = 0; 
    22842284        for (n = 0; n < npools; n++) 
    2285         {   uint pn; 
    2286             uint ncommitted; 
    2287             uint *bbase; 
     2285        {   size_t pn; 
     2286            size_t ncommitted; 
     2287            uintbbase; 
    22882288 
    22892289            pool = pooltable[n]; 
     
    22952295 
    22962296                if (bin < B_PAGE) 
    2297                 {   byte *p; 
    2298                     byte *ptop; 
    2299                     uint biti; 
    2300                     uint bitstride; 
    2301                     uint size = binsize[bin]; 
     2297                {   byte* p; 
     2298                    byte* ptop; 
     2299                    size_t biti; 
     2300                    size_t bitstride; 
     2301                    auto  size = binsize[bin]; 
    23022302 
    23032303                    p = pool.baseAddr + pn * PAGESIZE; 
     
    23522352                } 
    23532353                else if (bin == B_PAGE) 
    2354                 {   uint biti = pn * (PAGESIZE / 16); 
     2354                {   size_t biti = pn * (PAGESIZE / 16); 
    23552355 
    23562356                    if (!pool.mark.test(biti)) 
     
    23902390        size_t recoveredpages = 0; 
    23912391        for (n = 0; n < npools; n++) 
    2392         {   uint pn; 
    2393             uint ncommitted; 
     2392        {   size_t pn; 
     2393            size_t ncommitted; 
    23942394 
    23952395            pool = pooltable[n]; 
     
    23972397            for (pn = 0; pn < ncommitted; pn++) 
    23982398            { 
    2399                 Bins bin = cast(Bins)pool.pagetable[pn]; 
    2400                 uint biti; 
    2401                 uint u; 
     2399                Bins   bin = cast(Bins)pool.pagetable[pn]; 
     2400                size_t biti; 
     2401                size_t u; 
    24022402 
    24032403                if (bin < B_PAGE) 
    24042404                { 
    2405                     uint size = binsize[bin]; 
    2406                     uint bitstride = size / 16; 
    2407                     uint bitbase = pn * (PAGESIZE / 16); 
    2408                     uint bittop = bitbase + (PAGESIZE / 16); 
    2409                     byte *p; 
     2405                    size_t size = binsize[bin]; 
     2406                    size_t bitstride = size / 16; 
     2407                    size_t bitbase = pn * (PAGESIZE / 16); 
     2408                    size_t bittop = bitbase + (PAGESIZE / 16); 
     2409                    bytep; 
    24102410 
    24112411                    biti = bitbase; 
     
    24452445     * 
    24462446     */ 
    2447     uint getBits(Pool* pool, uint biti) 
     2447    uint getBits(Pool* pool, size_t biti) 
    24482448    in 
    24492449    { 
     
    24692469     * 
    24702470     */ 
    2471     void setBits(Pool* pool, uint biti, uint mask) 
     2471    void setBits(Pool* pool, size_t biti, uint mask) 
    24722472    in 
    24732473    { 
     
    24982498     * 
    24992499     */ 
    2500     void clrBits(Pool* pool, uint biti, uint mask) 
     2500    void clrBits(Pool* pool, size_t biti, uint mask) 
    25012501    in 
    25022502    { 
     
    26232623                assert(pool); 
    26242624                size_t offset = cast(size_t)(p - pool.baseAddr); 
    2625                 uint biti; 
    2626                 uint pn = offset / PAGESIZE; 
     2625                size_t biti; 
     2626                size_t pn = offset / PAGESIZE; 
    26272627                Bins bin = cast(Bins)pool.pagetable[pn]; 
    26282628                biti = (offset & notbinsize[bin]); 
     
    26612661    GCBits noscan;      // entries that should not be scanned 
    26622662 
    2663     uint npages; 
    2664     uint ncommitted;    // ncommitted <= npages 
     2663    size_t npages; 
     2664    size_t ncommitted;    // ncommitted <= npages 
    26652665    ubyte* pagetable; 
    26662666 
    26672667 
    2668     void initialize(uint npages) 
     2668    void initialize(size_t npages) 
    26692669    { 
    26702670        size_t poolsize; 
     
    26762676 
    26772677        // Some of the code depends on page alignment of memory pools 
    2678         assert((cast(uint)baseAddr & (PAGESIZE - 1)) == 0); 
     2678        assert((cast(size_t)baseAddr & (PAGESIZE - 1)) == 0); 
    26792679 
    26802680        if (!baseAddr) 
     
    26892689        topAddr = baseAddr + poolsize; 
    26902690 
    2691         mark.alloc(poolsize / 16); 
    2692         scan.alloc(poolsize / 16); 
    2693         freebits.alloc(poolsize / 16); 
    2694         noscan.alloc(poolsize / 16); 
     2691        mark.alloc(cast(size_t)poolsize / 16); 
     2692        scan.alloc(cast(size_t)poolsize / 16); 
     2693        freebits.alloc(cast(size_t)poolsize / 16); 
     2694        noscan.alloc(cast(size_t)poolsize / 16); 
    26952695 
    26962696        pagetable = cast(ubyte*)cstdlib.malloc(npages); 
     
    27572757        } 
    27582758 
    2759         for (uint i = 0; i < npages; i++) 
     2759        for (size_t i = 0; i < npages; i++) 
    27602760        {   Bins bin = cast(Bins)pagetable[i]; 
    27612761 
     
    27692769     * Returns ~0u on failure. 
    27702770     */ 
    2771     uint allocPages(uint n) 
    2772     { 
    2773         uint i; 
    2774         uint n2; 
     2771    uint allocPages(size_t n) 
     2772    { 
     2773        size_t i; 
     2774        size_t n2; 
    27752775 
    27762776        //debug(PRINTF) printf("Pool::allocPages(n = %d)\n", n); 
     
    27952795     * Returns ~0u on failure. 
    27962796     */ 
    2797     uint extendPages(uint n) 
     2797    uint extendPages(size_t n) 
    27982798    { 
    27992799        //debug(PRINTF) printf("Pool::extendPages(n = %d)\n", n); 
    28002800        if (ncommitted + n <= npages) 
    28012801        { 
    2802             uint tocommit; 
     2802            size_t tocommit; 
    28032803 
    28042804            tocommit = (n + (COMMITSIZE/PAGESIZE) - 1) & ~(COMMITSIZE/PAGESIZE - 1); 
     
    28282828     * Free npages pages starting with pagenum. 
    28292829     */ 
    2830     void freePages(uint pagenum, uint npages) 
     2830    void freePages(size_t pagenum, size_t npages) 
    28312831    { 
    28322832        cstring.memset(&pagetable[pagenum], B_FREE, npages);