Index: src/OFBitSetCharacterSet.m ================================================================== --- src/OFBitSetCharacterSet.m +++ src/OFBitSetCharacterSet.m @@ -38,18 +38,19 @@ size_t length = string.length; for (size_t i = 0; i < length; i++) { of_unichar_t c = characters[i]; - if (c / 8 >= _size) { + if (c / CHAR_BIT >= _size) { size_t newSize; if (UINT32_MAX - c < 1) @throw [OFOutOfRangeException exception]; - newSize = OF_ROUND_UP_POW2(8, c + 1) / 8; + newSize = OF_ROUND_UP_POW2(CHAR_BIT, c + 1) / + CHAR_BIT; _bitset = of_realloc(_bitset, newSize, 1); memset(_bitset + _size, '\0', newSize - _size); _size = newSize; @@ -74,11 +75,11 @@ [super dealloc]; } - (bool)characterIsMember: (of_unichar_t)character { - if (character / 8 >= _size) + if (character / CHAR_BIT >= _size) return false; return of_bitset_isset(_bitset, character); } @end Index: src/OFSecureData.m ================================================================== --- src/OFSecureData.m +++ src/OFSecureData.m @@ -99,11 +99,12 @@ static struct page * addPage(bool allowPreallocated) { size_t pageSize = [OFSystemInfo pageSize]; - size_t mapSize = OF_ROUND_UP_POW2(8, pageSize / CHUNK_SIZE) / 8; + size_t mapSize = OF_ROUND_UP_POW2(CHAR_BIT, pageSize / CHUNK_SIZE) / + CHAR_BIT; struct page *page; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) struct page *lastPage; # endif @@ -184,11 +185,12 @@ static void removePageIfEmpty(struct page *page) { unsigned char *map = page->map; size_t pageSize = [OFSystemInfo pageSize]; - size_t mapSize = OF_ROUND_UP_POW2(8, pageSize / CHUNK_SIZE) / 8; + size_t mapSize = OF_ROUND_UP_POW2(CHAR_BIT, pageSize / CHUNK_SIZE) / + CHAR_BIT; for (size_t i = 0; i < mapSize; i++) if (map[i] != 0) return; Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -25,10 +25,11 @@ #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif +#include #include #include #include #include #include @@ -822,23 +823,23 @@ } static OF_INLINE bool of_bitset_isset(unsigned char *_Nonnull storage, size_t idx) { - return storage[idx / 8] & (1u << (idx % 8)); + return storage[idx / CHAR_BIT] & (1u << (idx % CHAR_BIT)); } static OF_INLINE void of_bitset_set(unsigned char *_Nonnull storage, size_t idx) { - storage[idx / 8] |= (1u << (idx % 8)); + storage[idx / CHAR_BIT] |= (1u << (idx % CHAR_BIT)); } static OF_INLINE void of_bitset_clear(unsigned char *_Nonnull storage, size_t idx) { - storage[idx / 8] &= ~(1u << (idx % 8)); + storage[idx / CHAR_BIT] &= ~(1u << (idx % CHAR_BIT)); } static OF_INLINE char *_Nullable of_strdup(const char *_Nonnull string) {