@@ -97,11 +97,11 @@ static struct page * addPage(bool allowPreallocated) { size_t pageSize = [OFSystemInfo pageSize]; - size_t mapSize = OF_ROUND_UP_POW2(CHAR_BIT, pageSize / CHUNK_SIZE) / + size_t mapSize = OFRoundUpToPowerOf2(CHAR_BIT, pageSize / CHUNK_SIZE) / CHAR_BIT; struct page *page; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) struct page *lastPage; # endif @@ -118,21 +118,21 @@ OFTLSKeyGet(preallocatedPagesKey); # endif numPreallocatedPages--; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - OF_ENSURE(OFTLSKeySet(numPreallocatedPagesKey, + OFEnsure(OFTLSKeySet(numPreallocatedPagesKey, (void *)numPreallocatedPages) == 0); # endif page = preallocatedPages[numPreallocatedPages]; if (numPreallocatedPages == 0) { OFFreeMemory(preallocatedPages); preallocatedPages = NULL; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - OF_ENSURE(OFTLSKeySet(preallocatedPagesKey, + OFEnsure(OFTLSKeySet(preallocatedPagesKey, preallocatedPages) == 0); # endif } return page; @@ -151,11 +151,11 @@ } @catch (id e) { OFFreeMemory(page->map); OFFreeMemory(page); @throw e; } - of_explicit_memset(page->page, 0, pageSize); + OFZeroMemory(page->page, pageSize); # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) lastPage = OFTLSKeyGet(lastPageKey); # endif @@ -169,14 +169,14 @@ lastPage = page; if (firstPage == NULL) firstPage = page; # else - OF_ENSURE(OFTLSKeySet(lastPageKey, page) == 0); + OFEnsure(OFTLSKeySet(lastPageKey, page) == 0); if (OFTLSKeyGet(firstPageKey) == NULL) - OF_ENSURE(OFTLSKeySet(firstPageKey, page) == 0); + OFEnsure(OFTLSKeySet(firstPageKey, page) == 0); # endif return page; } @@ -183,11 +183,11 @@ static void removePageIfEmpty(struct page *page) { unsigned char *map = page->map; size_t pageSize = [OFSystemInfo pageSize]; - size_t mapSize = OF_ROUND_UP_POW2(CHAR_BIT, pageSize / CHUNK_SIZE) / + size_t mapSize = OFRoundUpToPowerOf2(CHAR_BIT, pageSize / CHUNK_SIZE) / CHAR_BIT; for (size_t i = 0; i < mapSize; i++) if (map[i] != 0) return; @@ -205,13 +205,13 @@ firstPage = page->next; if (lastPage == page) lastPage = page->previous; # else if (OFTLSKeyGet(firstPageKey) == page) - OF_ENSURE(OFTLSKeySet(firstPageKey, page->next) == 0); + OFEnsure(OFTLSKeySet(firstPageKey, page->next) == 0); if (OFTLSKeyGet(lastPageKey) == page) - OF_ENSURE(OFTLSKeySet(lastPageKey, page->previous) == 0); + OFEnsure(OFTLSKeySet(lastPageKey, page->previous) == 0); # endif OFFreeMemory(page); } @@ -218,17 +218,17 @@ static void * allocateMemory(struct page *page, size_t bytes) { size_t chunks, chunksLeft, pageSize, i, firstChunk; - bytes = OF_ROUND_UP_POW2(CHUNK_SIZE, bytes); + bytes = OFRoundUpToPowerOf2(CHUNK_SIZE, bytes); chunks = chunksLeft = bytes / CHUNK_SIZE; firstChunk = 0; pageSize = [OFSystemInfo pageSize]; for (i = 0; i < pageSize / CHUNK_SIZE; i++) { - if (of_bitset_isset(page->map, i)) { + if (OFBitsetIsSet(page->map, i)) { chunksLeft = chunks; firstChunk = i + 1; continue; } @@ -236,11 +236,11 @@ break; } if (chunksLeft == 0) { for (size_t j = firstChunk; j < firstChunk + chunks; j++) - of_bitset_set(page->map, j); + OFBitsetSet(page->map, j); return page->page + (CHUNK_SIZE * firstChunk); } return NULL; @@ -249,18 +249,18 @@ static void freeMemory(struct page *page, void *pointer, size_t bytes) { size_t chunks, chunkIndex; - bytes = OF_ROUND_UP_POW2(CHUNK_SIZE, bytes); + bytes = OFRoundUpToPowerOf2(CHUNK_SIZE, bytes); chunks = bytes / CHUNK_SIZE; chunkIndex = ((uintptr_t)pointer - (uintptr_t)page->page) / CHUNK_SIZE; - of_explicit_memset(pointer, 0, bytes); + OFZeroMemory(pointer, bytes); for (size_t i = 0; i < chunks; i++) - of_bitset_clear(page->map, chunkIndex + i); + OFBitsetClear(page->map, chunkIndex + i); } #endif @implementation OFSecureData @synthesize allowsSwappableMemory = _allowsSwappableMemory; @@ -282,11 +282,11 @@ + (void)preallocateUnswappableMemoryWithSize: (size_t)size { #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) size_t pageSize = [OFSystemInfo pageSize]; - size_t numPages = OF_ROUND_UP_POW2(pageSize, size) / pageSize; + size_t numPages = OFRoundUpToPowerOf2(pageSize, size) / pageSize; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) struct page **preallocatedPages = OFTLSKeyGet(preallocatedPagesKey); size_t numPreallocatedPages; # endif size_t i; @@ -294,11 +294,11 @@ if (preallocatedPages != NULL) @throw [OFInvalidArgumentException exception]; preallocatedPages = OFAllocZeroedMemory(numPages, sizeof(struct page)); # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - OF_ENSURE(OFTLSKeySet(preallocatedPagesKey, preallocatedPages) == 0); + OFEnsure(OFTLSKeySet(preallocatedPagesKey, preallocatedPages) == 0); # endif @try { for (i = 0; i < numPages; i++) preallocatedPages[i] = addPage(false); @@ -312,11 +312,11 @@ @throw e; } numPreallocatedPages = numPages; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - OF_ENSURE(OFTLSKeySet(numPreallocatedPagesKey, + OFEnsure(OFTLSKeySet(numPreallocatedPagesKey, (void *)(uintptr_t)numPreallocatedPages) == 0); # endif #else @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; @@ -418,11 +418,11 @@ _items = OFAllocMemory(count, itemSize); _freeWhenDone = true; memset(_items, 0, count * itemSize); #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) } else if (count * itemSize >= pageSize) - _items = mapPages(OF_ROUND_UP_POW2(pageSize, + _items = mapPages(OFRoundUpToPowerOf2(pageSize, count * itemSize) / pageSize); else { # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) struct page *lastPage = OFTLSKeyGet(lastPageKey); # endif @@ -528,11 +528,11 @@ if (!_allowsSwappableMemory) { size_t pageSize = [OFSystemInfo pageSize]; if (_count * _itemSize > pageSize) unmapPages(_items, - OF_ROUND_UP_POW2(pageSize, _count * _itemSize) / + OFRoundUpToPowerOf2(pageSize, _count * _itemSize) / pageSize); else if (_page != NULL) { if (_items != NULL) freeMemory(_page, _items, _count * _itemSize); @@ -557,11 +557,11 @@ return _items + idx * _itemSize; } - (void)zero { - of_explicit_memset(_items, 0, _count * _itemSize); + OFZeroMemory(_items, _count * _itemSize); } - (id)copy { OFSecureData *copy = [[OFSecureData alloc]