Index: src/OFSecureData.m ================================================================== --- src/OFSecureData.m +++ src/OFSecureData.m @@ -258,11 +258,12 @@ #endif @implementation OFSecureData @synthesize allowsSwappableMemory = _allowsSwappableMemory; -#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) +#if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) && \ + !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) + (void)initialize { if (self != [OFSecureData class]) return; @@ -392,24 +393,26 @@ allowsSwappableMemory: (bool)allowsSwappableMemory { self = [super init]; @try { +#if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) size_t pageSize = [OFSystemInfo pageSize]; +#endif if (count > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exception]; if (allowsSwappableMemory) { _items = [self allocMemoryWithSize: itemSize count: count]; 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, count * itemSize) / pageSize); else { -#if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) struct page *lastPage = of_tlskey_get(lastPageKey); # endif for (struct page *page = lastPage; page != NULL; @@ -430,16 +433,17 @@ if (_items == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: count * itemSize]; } + } #else + } else @throw [OFNotImplementedException exceptionWithSelector: _cmd object: nil]; #endif - } _itemSize = itemSize; _count = count; _allowsSwappableMemory = allowsSwappableMemory; } @catch (id e) {