 |
Changeset 3076
- 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
| r2356 |
r3076 |
|
| 51 | 51 | const int BITS_MASK = 31; |
|---|
| 52 | 52 | |
|---|
| 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 | uint* data = null; |
|---|
| | 54 | size_t nwords = 0; // allocated words in data[] excluding sentinals |
|---|
| | 55 | size_t nbits = 0; // number of bits in data[] excluding sentinals |
|---|
| 56 | 56 | |
|---|
| 57 | 57 | void Dtor() |
|---|
| … | … | |
| 72 | 72 | } |
|---|
| 73 | 73 | |
|---|
| 74 | | void alloc(uint nbits) |
|---|
| | 74 | void alloc(size_t nbits) |
|---|
| 75 | 75 | { |
|---|
| 76 | 76 | this.nbits = nbits; |
|---|
| 77 | 77 | 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); |
|---|
| 79 | 79 | if (!data) |
|---|
| 80 | 80 | onOutOfMemoryError(); |
|---|
| 81 | 81 | } |
|---|
| 82 | 82 | |
|---|
| 83 | | uint test(uint i) |
|---|
| | 83 | uint test(size_t i) |
|---|
| 84 | 84 | in |
|---|
| 85 | 85 | { |
|---|
| … | … | |
| 92 | 92 | } |
|---|
| 93 | 93 | |
|---|
| 94 | | void set(uint i) |
|---|
| | 94 | void set(size_t i) |
|---|
| 95 | 95 | in |
|---|
| 96 | 96 | { |
|---|
| … | … | |
| 103 | 103 | } |
|---|
| 104 | 104 | |
|---|
| 105 | | void clear(uint i) |
|---|
| | 105 | void clear(size_t i) |
|---|
| 106 | 106 | in |
|---|
| 107 | 107 | { |
|---|
| … | … | |
| 114 | 114 | } |
|---|
| 115 | 115 | |
|---|
| 116 | | uint testClear(uint i) |
|---|
| | 116 | uint testClear(size_t i) |
|---|
| 117 | 117 | { |
|---|
| 118 | 118 | version (bitops) |
|---|
| … | … | |
| 138 | 138 | //(cast(bit *)(data + 1))[i] = 0; |
|---|
| 139 | 139 | |
|---|
| 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)); |
|---|
| 142 | 142 | result = *p & mask; |
|---|
| 143 | 143 | *p &= ~mask; |
|---|
| … | … | |
| 161 | 161 | } |
|---|
| 162 | 162 | |
|---|
| 163 | | uint *base() |
|---|
| | 163 | uint* base() |
|---|
| 164 | 164 | in |
|---|
| 165 | 165 | { |
|---|
| r3073 |
r3076 |
|
| 117 | 117 | void* p; |
|---|
| 118 | 118 | size_t size; |
|---|
| 119 | | uint line; |
|---|
| | 119 | size_t line; |
|---|
| 120 | 120 | char* file; |
|---|
| 121 | 121 | void* parent; |
|---|
| … | … | |
| 155 | 155 | if (!data) |
|---|
| 156 | 156 | { |
|---|
| 157 | | data = cast(Log *)cstdlib.malloc(allocdim * Log.sizeof); |
|---|
| | 157 | data = cast(Log*)cstdlib.malloc(allocdim * Log.sizeof); |
|---|
| 158 | 158 | if (!data && allocdim) |
|---|
| 159 | 159 | onOutOfMemoryError(); |
|---|
| … | … | |
| 162 | 162 | { Log *newdata; |
|---|
| 163 | 163 | |
|---|
| 164 | | newdata = cast(Log *)cstdlib.malloc(allocdim * Log.sizeof); |
|---|
| | 164 | newdata = cast(Log*)cstdlib.malloc(allocdim * Log.sizeof); |
|---|
| 165 | 165 | if (!newdata && allocdim) |
|---|
| 166 | 166 | onOutOfMemoryError(); |
|---|
| … | … | |
| 232 | 232 | { |
|---|
| 233 | 233 | gcLock = GCLock.classinfo; |
|---|
| 234 | | gcx = cast(Gcx *)cstdlib.calloc(1, Gcx.sizeof); |
|---|
| | 234 | gcx = cast(Gcx*)cstdlib.calloc(1, Gcx.sizeof); |
|---|
| 235 | 235 | if (!gcx) |
|---|
| 236 | 236 | onOutOfMemoryError(); |
|---|
| … | … | |
| 317 | 317 | if (pool) |
|---|
| 318 | 318 | { |
|---|
| 319 | | uint biti = (p - pool.baseAddr) / 16; |
|---|
| | 319 | auto biti = cast(size_t)(p - pool.baseAddr) / 16; |
|---|
| 320 | 320 | |
|---|
| 321 | 321 | oldb = gcx.getBits(pool, biti); |
|---|
| … | … | |
| 352 | 352 | if (pool) |
|---|
| 353 | 353 | { |
|---|
| 354 | | uint biti = (p - pool.baseAddr) / 16; |
|---|
| | 354 | auto biti = cast(size_t)(p - pool.baseAddr) / 16; |
|---|
| 355 | 355 | |
|---|
| 356 | 356 | oldb = gcx.getBits(pool, biti); |
|---|
| … | … | |
| 388 | 388 | if (pool) |
|---|
| 389 | 389 | { |
|---|
| 390 | | uint biti = (p - pool.baseAddr) / 16; |
|---|
| | 390 | auto biti = cast(size_t)(p - pool.baseAddr) / 16; |
|---|
| 391 | 391 | |
|---|
| 392 | 392 | oldb = gcx.getBits(pool, biti); |
|---|
| … | … | |
| 492 | 492 | |
|---|
| 493 | 493 | // Return next item from free list |
|---|
| 494 | | gcx.bucket[bin] = (cast(List *)p).next; |
|---|
| | 494 | gcx.bucket[bin] = (cast(List*)p).next; |
|---|
| 495 | 495 | if( !(bits & BlkAttr.NO_SCAN) ) |
|---|
| 496 | 496 | cstring.memset(p + size, 0, binsize[bin] - size); |
|---|
| … | … | |
| 514 | 514 | assert(pool); |
|---|
| 515 | 515 | |
|---|
| 516 | | gcx.setBits(pool, (p - pool.baseAddr) / 16, bits); |
|---|
| | 516 | gcx.setBits(pool, cast(size_t)(p - pool.baseAddr) / 16, bits); |
|---|
| 517 | 517 | } |
|---|
| 518 | 518 | return p; |
|---|
| … | … | |
| 603 | 603 | if (pool) |
|---|
| 604 | 604 | { |
|---|
| 605 | | uint biti = cast(uint)(p - pool.baseAddr) / 16; |
|---|
| | 605 | auto biti = cast(size_t)(p - pool.baseAddr) / 16; |
|---|
| 606 | 606 | |
|---|
| 607 | 607 | if (bits) |
|---|
| … | … | |
| 683 | 683 | if (pool) |
|---|
| 684 | 684 | { |
|---|
| 685 | | uint biti = cast(uint)(p - pool.baseAddr) / 16; |
|---|
| | 685 | auto biti = cast(size_t)(p - pool.baseAddr) / 16; |
|---|
| 686 | 686 | |
|---|
| 687 | 687 | if (bits) |
|---|
| … | … | |
| 850 | 850 | assert (p); |
|---|
| 851 | 851 | |
|---|
| 852 | | Pool *pool; |
|---|
| 853 | | uint pagenum; |
|---|
| 854 | | Bins bin; |
|---|
| 855 | | uint biti; |
|---|
| | 852 | Pool* pool; |
|---|
| | 853 | size_t pagenum; |
|---|
| | 854 | Bins bin; |
|---|
| | 855 | size_t biti; |
|---|
| 856 | 856 | |
|---|
| 857 | 857 | // Find which page it is in |
|---|
| … | … | |
| 861 | 861 | sentinel_Invariant(p); |
|---|
| 862 | 862 | 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; |
|---|
| 865 | 865 | gcx.clrBits(pool, biti, BlkAttr.ALL_BITS); |
|---|
| 866 | 866 | |
|---|
| 867 | 867 | bin = cast(Bins)pool.pagetable[pagenum]; |
|---|
| 868 | 868 | if (bin == B_PAGE) // if large alloc |
|---|
| 869 | | { int npages; |
|---|
| 870 | | uint n; |
|---|
| | 869 | { size_t npages; |
|---|
| | 870 | size_t n; |
|---|
| 871 | 871 | |
|---|
| 872 | 872 | // Free pages |
|---|
| … | … | |
| 880 | 880 | else |
|---|
| 881 | 881 | { // Add to free list |
|---|
| 882 | | List *list = cast(List *)p; |
|---|
| | 882 | List *list = cast(List*)p; |
|---|
| 883 | 883 | |
|---|
| 884 | 884 | debug (MEMSTOMP) cstring.memset(p, 0xF2, binsize[bin]); |
|---|
| … | … | |
| 1062 | 1062 | { |
|---|
| 1063 | 1063 | Pool* pool; |
|---|
| 1064 | | uint pagenum; |
|---|
| | 1064 | size_t pagenum; |
|---|
| 1065 | 1065 | Bins bin; |
|---|
| 1066 | 1066 | size_t size; |
|---|
| … | … | |
| 1069 | 1069 | pool = gcx.findPool(p); |
|---|
| 1070 | 1070 | assert(pool); |
|---|
| 1071 | | pagenum = (p - pool.baseAddr) / PAGESIZE; |
|---|
| | 1071 | pagenum = cast(size_t)(p - pool.baseAddr) / PAGESIZE; |
|---|
| 1072 | 1072 | bin = cast(Bins)pool.pagetable[pagenum]; |
|---|
| 1073 | 1073 | assert(bin <= B_PAGE); |
|---|
| … | … | |
| 1084 | 1084 | for (list = gcx.bucket[bin]; list; list = list.next) |
|---|
| 1085 | 1085 | { |
|---|
| 1086 | | assert(cast(void *)list != p); |
|---|
| | 1086 | assert(cast(void*)list != p); |
|---|
| 1087 | 1087 | } |
|---|
| 1088 | 1088 | } |
|---|
| … | … | |
| 1112 | 1112 | { |
|---|
| 1113 | 1113 | //debug(PRINTF) printf("setStackBottom(%x)\n", p); |
|---|
| 1114 | | gcx.stackBottom = cast(char *)p; |
|---|
| | 1114 | gcx.stackBottom = cast(char*)p; |
|---|
| 1115 | 1115 | } |
|---|
| 1116 | 1116 | } |
|---|
| … | … | |
| 1289 | 1289 | |
|---|
| 1290 | 1290 | psize += pool.ncommitted * PAGESIZE; |
|---|
| 1291 | | for (uint j = 0; j < pool.ncommitted; j++) |
|---|
| | 1291 | for (size_t j = 0; j < pool.ncommitted; j++) |
|---|
| 1292 | 1292 | { |
|---|
| 1293 | 1293 | Bins bin = cast(Bins)pool.pagetable[j]; |
|---|
| … | … | |
| 1417 | 1417 | { int dummy; |
|---|
| 1418 | 1418 | |
|---|
| 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; |
|---|
| 1421 | 1421 | log_init(); |
|---|
| 1422 | 1422 | debug (THREADINVARIANT) |
|---|
| … | … | |
| 1431 | 1431 | inited = 0; |
|---|
| 1432 | 1432 | |
|---|
| 1433 | | for (uint i = 0; i < npools; i++) |
|---|
| | 1433 | for (size_t i = 0; i < npools; i++) |
|---|
| 1434 | 1434 | { Pool *pool = pooltable[i]; |
|---|
| 1435 | 1435 | |
|---|
| … | … | |
| 1456 | 1456 | { |
|---|
| 1457 | 1457 | //printf("Gcx.invariant(): this = %p\n", this); |
|---|
| 1458 | | uint i; |
|---|
| | 1458 | size_t i; |
|---|
| 1459 | 1459 | |
|---|
| 1460 | 1460 | // Assure we're called on the right thread |
|---|
| … | … | |
| 1518 | 1518 | void** newroots; |
|---|
| 1519 | 1519 | |
|---|
| 1520 | | newroots = cast(void **)cstdlib.malloc(newdim * newroots[0].sizeof); |
|---|
| | 1520 | newroots = cast(void**)cstdlib.malloc(newdim * newroots[0].sizeof); |
|---|
| 1521 | 1521 | if (!newroots) |
|---|
| 1522 | 1522 | onOutOfMemoryError(); |
|---|
| … | … | |
| 1563 | 1563 | Range *newranges; |
|---|
| 1564 | 1564 | |
|---|
| 1565 | | newranges = cast(Range *)cstdlib.malloc(newdim * newranges[0].sizeof); |
|---|
| | 1565 | newranges = cast(Range*)cstdlib.malloc(newdim * newranges[0].sizeof); |
|---|
| 1566 | 1566 | if (!newranges) |
|---|
| 1567 | 1567 | onOutOfMemoryError(); |
|---|
| … | … | |
| 1618 | 1618 | } |
|---|
| 1619 | 1619 | |
|---|
| 1620 | | for (uint i = 0; i < npools; i++) |
|---|
| | 1620 | for (size_t i = 0; i < npools; i++) |
|---|
| 1621 | 1621 | { Pool *pool; |
|---|
| 1622 | 1622 | |
|---|
| … | … | |
| 1645 | 1645 | { |
|---|
| 1646 | 1646 | 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]; |
|---|
| 1649 | 1649 | |
|---|
| 1650 | 1650 | // Adjust bit to be at start of allocated memory block |
|---|
| … | … | |
| 1677 | 1677 | size_t findSize(void *p) |
|---|
| 1678 | 1678 | { |
|---|
| 1679 | | Pool *pool; |
|---|
| | 1679 | Pool* pool; |
|---|
| 1680 | 1680 | size_t size = 0; |
|---|
| 1681 | 1681 | |
|---|
| … | … | |
| 1683 | 1683 | if (pool) |
|---|
| 1684 | 1684 | { |
|---|
| 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; |
|---|
| 1689 | 1689 | bin = cast(Bins)pool.pagetable[pagenum]; |
|---|
| 1690 | 1690 | size = binsize[bin]; |
|---|
| 1691 | 1691 | if (bin == B_PAGE) |
|---|
| 1692 | | { uint npages = pool.ncommitted; |
|---|
| | 1692 | { size_t npages = pool.ncommitted; |
|---|
| 1693 | 1693 | ubyte* pt; |
|---|
| 1694 | | uint i; |
|---|
| | 1694 | size_t i; |
|---|
| 1695 | 1695 | |
|---|
| 1696 | 1696 | pt = &pool.pagetable[0]; |
|---|
| … | … | |
| 1712 | 1712 | BlkInfo getInfo(void* p) |
|---|
| 1713 | 1713 | { |
|---|
| 1714 | | Pool *pool; |
|---|
| | 1714 | Pool* pool; |
|---|
| 1715 | 1715 | BlkInfo info; |
|---|
| 1716 | 1716 | |
|---|
| … | … | |
| 1719 | 1719 | { |
|---|
| 1720 | 1720 | 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]; |
|---|
| 1723 | 1723 | |
|---|
| 1724 | 1724 | //////////////////////////////////////////////////////////////////// |
|---|
| … | … | |
| 1748 | 1748 | info.size = binsize[bin]; |
|---|
| 1749 | 1749 | if (bin == B_PAGE) |
|---|
| 1750 | | { uint npages = pool.ncommitted; |
|---|
| | 1750 | { size_t npages = pool.ncommitted; |
|---|
| 1751 | 1751 | ubyte* pt; |
|---|
| 1752 | | uint i; |
|---|
| | 1752 | size_t i; |
|---|
| 1753 | 1753 | |
|---|
| 1754 | 1754 | pt = &pool.pagetable[0]; |
|---|
| … | … | |
| 1765 | 1765 | //////////////////////////////////////////////////////////////////// |
|---|
| 1766 | 1766 | |
|---|
| 1767 | | info.attr = getBits(pool, offset / 16); |
|---|
| | 1767 | info.attr = getBits(pool, cast(size_t)(offset / 16)); |
|---|
| 1768 | 1768 | } |
|---|
| 1769 | 1769 | return info; |
|---|
| … | … | |
| 1825 | 1825 | size_t reserve(size_t size) |
|---|
| 1826 | 1826 | { |
|---|
| 1827 | | uint npages = (size + PAGESIZE - 1) / PAGESIZE; |
|---|
| 1828 | | Pool *pool = newPool(npages); |
|---|
| | 1827 | size_t npages = (size + PAGESIZE - 1) / PAGESIZE; |
|---|
| | 1828 | Pool* pool = newPool(npages); |
|---|
| 1829 | 1829 | |
|---|
| 1830 | 1830 | if (!pool || pool.extendPages(npages) == ~0u) |
|---|
| … | … | |
| 1840 | 1840 | void *bigAlloc(size_t size) |
|---|
| 1841 | 1841 | { |
|---|
| 1842 | | Pool *pool; |
|---|
| 1843 | | uint npages; |
|---|
| 1844 | | uint n; |
|---|
| 1845 | | uint pn; |
|---|
| 1846 | | uint freedpages; |
|---|
| 1847 | | void *p; |
|---|
| 1848 | | int state; |
|---|
| | 1842 | Pool* pool; |
|---|
| | 1843 | size_t npages; |
|---|
| | 1844 | size_t n; |
|---|
| | 1845 | size_t pn; |
|---|
| | 1846 | size_t freedpages; |
|---|
| | 1847 | void* p; |
|---|
| | 1848 | int state; |
|---|
| 1849 | 1849 | |
|---|
| 1850 | 1850 | npages = (size + PAGESIZE - 1) / PAGESIZE; |
|---|
| … | … | |
| 1921 | 1921 | * Return null if failed. |
|---|
| 1922 | 1922 | */ |
|---|
| 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 | Pool* pool; |
|---|
| | 1926 | Pool** newpooltable; |
|---|
| | 1927 | size_t newnpools; |
|---|
| | 1928 | size_t i; |
|---|
| 1929 | 1929 | |
|---|
| 1930 | 1930 | //debug(PRINTF) printf("************Gcx::newPool(npages = %d)****************\n", npages); |
|---|
| … | … | |
| 1945 | 1945 | // Allocate successively larger pools up to 8 megs |
|---|
| 1946 | 1946 | if (npools) |
|---|
| 1947 | | { uint n; |
|---|
| | 1947 | { size_t n; |
|---|
| 1948 | 1948 | |
|---|
| 1949 | 1949 | n = npools; |
|---|
| … | … | |
| 1998 | 1998 | int allocPage(Bins bin) |
|---|
| 1999 | 1999 | { |
|---|
| 2000 | | Pool *pool; |
|---|
| 2001 | | uint n; |
|---|
| 2002 | | uint pn; |
|---|
| 2003 | | byte *p; |
|---|
| 2004 | | byte *ptop; |
|---|
| | 2000 | Pool* pool; |
|---|
| | 2001 | size_t n; |
|---|
| | 2002 | size_t pn; |
|---|
| | 2003 | byte* p; |
|---|
| | 2004 | byte* ptop; |
|---|
| 2005 | 2005 | |
|---|
| 2006 | 2006 | //debug(PRINTF) printf("Gcx::allocPage(bin = %d)\n", bin); |
|---|
| … | … | |
| 2054 | 2054 | { |
|---|
| 2055 | 2055 | 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]; |
|---|
| 2059 | 2059 | |
|---|
| 2060 | 2060 | //debug(PRINTF) printf("\t\tfound pool %x, base=%x, pn = %d, bin = %d, biti = x%x\n", pool, pool.baseAddr, pn, bin, biti); |
|---|
| … | … | |
| 2141 | 2141 | size_t fullcollect(void *stackTop) |
|---|
| 2142 | 2142 | { |
|---|
| 2143 | | uint n; |
|---|
| 2144 | | Pool *pool; |
|---|
| | 2143 | size_t n; |
|---|
| | 2144 | Pool* pool; |
|---|
| 2145 | 2145 | |
|---|
| 2146 | 2146 | debug(COLLECT_PRINTF) printf("Gcx.fullcollect()\n"); |
|---|
| … | … | |
| 2167 | 2167 | pool = findPool(list); |
|---|
| 2168 | 2168 | 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); |
|---|
| 2170 | 2170 | } |
|---|
| 2171 | 2171 | } |
|---|
| … | … | |
| 2229 | 2229 | btop = bbase + pool.scan.nwords; |
|---|
| 2230 | 2230 | 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 | byte* o; |
|---|
| 2236 | 2236 | |
|---|
| 2237 | 2237 | bitm = *b; |
|---|
| … | … | |
| 2283 | 2283 | size_t freed = 0; |
|---|
| 2284 | 2284 | for (n = 0; n < npools; n++) |
|---|
| 2285 | | { uint pn; |
|---|
| 2286 | | uint ncommitted; |
|---|
| 2287 | | uint *bbase; |
|---|
| | 2285 | { size_t pn; |
|---|
| | 2286 | size_t ncommitted; |
|---|
| | 2287 | uint* bbase; |
|---|
| 2288 | 2288 | |
|---|
| 2289 | 2289 | pool = pooltable[n]; |
|---|
| … | … | |
| 2295 | 2295 | |
|---|
| 2296 | 2296 | 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]; |
|---|
| 2302 | 2302 | |
|---|
| 2303 | 2303 | p = pool.baseAddr + pn * PAGESIZE; |
|---|
| … | … | |
| 2352 | 2352 | } |
|---|
| 2353 | 2353 | else if (bin == B_PAGE) |
|---|
| 2354 | | { uint biti = pn * (PAGESIZE / 16); |
|---|
| | 2354 | { size_t biti = pn * (PAGESIZE / 16); |
|---|
| 2355 | 2355 | |
|---|
| 2356 | 2356 | if (!pool.mark.test(biti)) |
|---|
| … | … | |
| 2390 | 2390 | size_t recoveredpages = 0; |
|---|
| 2391 | 2391 | for (n = 0; n < npools; n++) |
|---|
| 2392 | | { uint pn; |
|---|
| 2393 | | uint ncommitted; |
|---|
| | 2392 | { size_t pn; |
|---|
| | 2393 | size_t ncommitted; |
|---|
| 2394 | 2394 | |
|---|
| 2395 | 2395 | pool = pooltable[n]; |
|---|
| … | … | |
| 2397 | 2397 | for (pn = 0; pn < ncommitted; pn++) |
|---|
| 2398 | 2398 | { |
|---|
| 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; |
|---|
| 2402 | 2402 | |
|---|
| 2403 | 2403 | if (bin < B_PAGE) |
|---|
| 2404 | 2404 | { |
|---|
| 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 | byte* p; |
|---|
| 2410 | 2410 | |
|---|
| 2411 | 2411 | biti = bitbase; |
|---|
| … | … | |
| 2445 | 2445 | * |
|---|
| 2446 | 2446 | */ |
|---|
| 2447 | | uint getBits(Pool* pool, uint biti) |
|---|
| | 2447 | uint getBits(Pool* pool, size_t biti) |
|---|
| 2448 | 2448 | in |
|---|
| 2449 | 2449 | { |
|---|
| … | … | |
| 2469 | 2469 | * |
|---|
| 2470 | 2470 | */ |
|---|
| 2471 | | void setBits(Pool* pool, uint biti, uint mask) |
|---|
| | 2471 | void setBits(Pool* pool, size_t biti, uint mask) |
|---|
| 2472 | 2472 | in |
|---|
| 2473 | 2473 | { |
|---|
| … | … | |
| 2498 | 2498 | * |
|---|
| 2499 | 2499 | */ |
|---|
| 2500 | | void clrBits(Pool* pool, uint biti, uint mask) |
|---|
| | 2500 | void clrBits(Pool* pool, size_t biti, uint mask) |
|---|
| 2501 | 2501 | in |
|---|
| 2502 | 2502 | { |
|---|
| … | … | |
| 2623 | 2623 | assert(pool); |
|---|
| 2624 | 2624 | 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; |
|---|
| 2627 | 2627 | Bins bin = cast(Bins)pool.pagetable[pn]; |
|---|
| 2628 | 2628 | biti = (offset & notbinsize[bin]); |
|---|
| … | … | |
| 2661 | 2661 | GCBits noscan; // entries that should not be scanned |
|---|
| 2662 | 2662 | |
|---|
| 2663 | | uint npages; |
|---|
| 2664 | | uint ncommitted; // ncommitted <= npages |
|---|
| | 2663 | size_t npages; |
|---|
| | 2664 | size_t ncommitted; // ncommitted <= npages |
|---|
| 2665 | 2665 | ubyte* pagetable; |
|---|
| 2666 | 2666 | |
|---|
| 2667 | 2667 | |
|---|
| 2668 | | void initialize(uint npages) |
|---|
| | 2668 | void initialize(size_t npages) |
|---|
| 2669 | 2669 | { |
|---|
| 2670 | 2670 | size_t poolsize; |
|---|
| … | … | |
| 2676 | 2676 | |
|---|
| 2677 | 2677 | // 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); |
|---|
| 2679 | 2679 | |
|---|
| 2680 | 2680 | if (!baseAddr) |
|---|
| … | … | |
| 2689 | 2689 | topAddr = baseAddr + poolsize; |
|---|
| 2690 | 2690 | |
|---|
| 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); |
|---|
| 2695 | 2695 | |
|---|
| 2696 | 2696 | pagetable = cast(ubyte*)cstdlib.malloc(npages); |
|---|
| … | … | |
| 2757 | 2757 | } |
|---|
| 2758 | 2758 | |
|---|
| 2759 | | for (uint i = 0; i < npages; i++) |
|---|
| | 2759 | for (size_t i = 0; i < npages; i++) |
|---|
| 2760 | 2760 | { Bins bin = cast(Bins)pagetable[i]; |
|---|
| 2761 | 2761 | |
|---|
| … | … | |
| 2769 | 2769 | * Returns ~0u on failure. |
|---|
| 2770 | 2770 | */ |
|---|
| 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; |
|---|
| 2775 | 2775 | |
|---|
| 2776 | 2776 | //debug(PRINTF) printf("Pool::allocPages(n = %d)\n", n); |
|---|
| … | … | |
| 2795 | 2795 | * Returns ~0u on failure. |
|---|
| 2796 | 2796 | */ |
|---|
| 2797 | | uint extendPages(uint n) |
|---|
| | 2797 | uint extendPages(size_t n) |
|---|
| 2798 | 2798 | { |
|---|
| 2799 | 2799 | //debug(PRINTF) printf("Pool::extendPages(n = %d)\n", n); |
|---|
| 2800 | 2800 | if (ncommitted + n <= npages) |
|---|
| 2801 | 2801 | { |
|---|
| 2802 | | uint tocommit; |
|---|
| | 2802 | size_t tocommit; |
|---|
| 2803 | 2803 | |
|---|
| 2804 | 2804 | tocommit = (n + (COMMITSIZE/PAGESIZE) - 1) & ~(COMMITSIZE/PAGESIZE - 1); |
|---|
| … | … | |
| 2828 | 2828 | * Free npages pages starting with pagenum. |
|---|
| 2829 | 2829 | */ |
|---|
| 2830 | | void freePages(uint pagenum, uint npages) |
|---|
| | 2830 | void freePages(size_t pagenum, size_t npages) |
|---|
| 2831 | 2831 | { |
|---|
| 2832 | 2832 | cstring.memset(&pagetable[pagenum], B_FREE, npages); |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic