Overview
Comment: | A few more missed renames |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
19236ddfe72cd231ddf2f6ba0cb6641b |
User & Date: | js on 2021-05-02 09:25:55 |
Other Links: | manifest | tags |
Context
2021-05-02
| ||
09:40 | Remove leftover files check-in: 25de908a52 user: js tags: trunk | |
09:25 | A few more missed renames check-in: 19236ddfe7 user: js tags: trunk | |
09:18 | OFTimer: Add -[description] check-in: aaca545b2f user: js tags: trunk | |
Changes
Modified src/OFASPrintF.m from [88da2745a9] to [55b5185ec7].
︙ | ︙ | |||
49 50 51 52 53 54 55 | * configure determined it is broken. In this case, we must make sure there is * no name clash. */ # define asprintf asprintf_ # define vasprintf vasprintf_ #endif | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | * configure determined it is broken. In this case, we must make sure there is * no name clash. */ # define asprintf asprintf_ # define vasprintf vasprintf_ #endif struct Context { const char *format; size_t formatLen; char subformat[maxSubformatLen + 1]; size_t subformatLen; va_list arguments; char *buffer; size_t bufferLen; |
︙ | ︙ | |||
144 145 146 147 148 149 150 | va_end(arguments); return ret; } #endif static bool | | | | | | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | va_end(arguments); return ret; } #endif static bool appendString(struct Context *ctx, const char *append, size_t appendLen) { char *newBuf; if (appendLen == 0) return true; if ((newBuf = realloc(ctx->buffer, ctx->bufferLen + appendLen + 1)) == NULL) return false; memcpy(newBuf + ctx->bufferLen, append, appendLen); ctx->buffer = newBuf; ctx->bufferLen += appendLen; return true; } static bool appendSubformat(struct Context *ctx, const char *subformat, size_t subformatLen) { if (ctx->subformatLen + subformatLen > maxSubformatLen) return false; memcpy(ctx->subformat + ctx->subformatLen, subformat, subformatLen); ctx->subformatLen += subformatLen; ctx->subformat[ctx->subformatLen] = 0; return true; } static bool stringState(struct Context *ctx) { if (ctx->format[ctx->i] == '%') { if (ctx->i > 0) if (!appendString(ctx, ctx->format + ctx->last, ctx->i - ctx->last)) return false; if (!appendSubformat(ctx, ctx->format + ctx->i, 1)) return false; ctx->last = ctx->i + 1; ctx->state = stateFormatFlags; } return true; } static bool formatFlagsState(struct Context *ctx) { switch (ctx->format[ctx->i]) { case '-': case '+': case ' ': case '#': case '0': |
︙ | ︙ | |||
224 225 226 227 228 229 230 | break; } return true; } static bool | | | | 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | break; } return true; } static bool formatFieldWidthState(struct Context *ctx) { if ((ctx->format[ctx->i] >= '0' && ctx->format[ctx->i] <= '9') || ctx->format[ctx->i] == '*' || ctx->format[ctx->i] == '.') { if (!appendSubformat(ctx, ctx->format + ctx->i, 1)) return false; } else { ctx->state = stateFormatLengthModifier; ctx->i--; } return true; } static bool formatLengthModifierState(struct Context *ctx) { /* Only one allowed */ switch (ctx->format[ctx->i]) { case 'h': /* and also hh */ if (ctx->formatLen > ctx->i + 1 && ctx->format[ctx->i + 1] == 'h') { if (!appendSubformat(ctx, ctx->format + ctx->i, 2)) |
︙ | ︙ | |||
369 370 371 372 373 374 375 | } ctx->state = stateFormatConversionSpecifier; return true; } static bool | | | 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | } ctx->state = stateFormatConversionSpecifier; return true; } static bool formatConversionSpecifierState(struct Context *ctx) { char *tmp = NULL; int tmpLen = 0; #ifndef HAVE_ASPRINTF_L OFString *point; #endif |
︙ | ︙ | |||
727 728 729 730 731 732 733 | ctx->last = ctx->i + 1; ctx->state = stateString; return true; } | | | | 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | ctx->last = ctx->i + 1; ctx->state = stateString; return true; } static bool (*states[])(struct Context *) = { stringState, formatFlagsState, formatFieldWidthState, formatLengthModifierState, formatConversionSpecifierState }; int OFVASPrintF(char **string, const char *format, va_list arguments) { struct Context ctx; ctx.format = format; ctx.formatLen = strlen(format); memset(ctx.subformat, 0, maxSubformatLen + 1); ctx.subformatLen = 0; va_copy(ctx.arguments, arguments); ctx.bufferLen = 0; |
︙ | ︙ |
Modified src/OFObject.m from [ec692d0b5b] to [4833385eee].
︙ | ︙ | |||
68 69 70 71 72 73 74 | #endif #ifdef OF_APPLE_RUNTIME extern id _Nullable _objc_rootAutorelease(id _Nullable object); #endif #if defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR) extern id OFForward(id, SEL, ...); | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | #endif #ifdef OF_APPLE_RUNTIME extern id _Nullable _objc_rootAutorelease(id _Nullable object); #endif #if defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR) extern id OFForward(id, SEL, ...); extern struct Stret OFForward_stret(id, SEL, ...); #else # define OFForward OFMethodNotFound # define OFForward_stret OFMethodNotFound_stret #endif struct PreIvars { int retainCount; |
︙ | ︙ |
Modified src/OFSecureData.h from [3c696dcd02] to [69bd454c65].
︙ | ︙ | |||
28 29 30 31 32 33 34 | * deallocated. Check the @ref allowsSwappableMemory property to see * whether a particular OFSecureData might be allocated in swappable * memory. */ OF_SUBCLASSING_RESTRICTED @interface OFSecureData: OFData { | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | * deallocated. Check the @ref allowsSwappableMemory property to see * whether a particular OFSecureData might be allocated in swappable * memory. */ OF_SUBCLASSING_RESTRICTED @interface OFSecureData: OFData { void *_page; bool _allowsSwappableMemory; } /** * @brief Whether the data may be stored in swappable memory. */ @property (readonly, nonatomic) bool allowsSwappableMemory; |
︙ | ︙ |
Modified src/OFSecureData.m from [850d3da4ab] to [80f9f47dea].
︙ | ︙ | |||
34 35 36 37 38 39 40 | #import "OFNotImplementedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) static const size_t chunkSize = 16; | | | | | | | | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #import "OFNotImplementedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) static const size_t chunkSize = 16; struct Page { struct Page *next, *previous; void *map; unsigned char *page; }; # if defined(OF_HAVE_COMPILER_TLS) static thread_local struct Page *firstPage = NULL; static thread_local struct Page *lastPage = NULL; static thread_local struct Page **preallocatedPages = NULL; static thread_local size_t numPreallocatedPages = 0; # elif defined(OF_HAVE_THREADS) static OFTLSKey firstPageKey, lastPageKey; static OFTLSKey preallocatedPagesKey, numPreallocatedPagesKey; # else static struct Page *firstPage = NULL; static struct Page *lastPage = NULL; static struct Page **preallocatedPages = NULL; static size_t numPreallocatedPages = 0; # endif static void * mapPages(size_t numPages) { size_t pageSize = [OFSystemInfo pageSize]; |
︙ | ︙ | |||
90 91 92 93 94 95 96 | if (numPages > SIZE_MAX / pageSize) @throw [OFOutOfRangeException exception]; munlock(pointer, numPages * pageSize); munmap(pointer, numPages * pageSize); } | | | | | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | if (numPages > SIZE_MAX / pageSize) @throw [OFOutOfRangeException exception]; munlock(pointer, numPages * pageSize); munmap(pointer, numPages * pageSize); } static struct Page * addPage(bool allowPreallocated) { size_t pageSize = [OFSystemInfo pageSize]; size_t mapSize = OFRoundUpToPowerOf2(CHAR_BIT, pageSize / chunkSize) / CHAR_BIT; struct Page *page; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) struct Page *lastPage; # endif if (allowPreallocated) { # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) uintptr_t numPreallocatedPages = (uintptr_t)OFTLSKeyGet(numPreallocatedPagesKey); # endif if (numPreallocatedPages > 0) { # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) struct Page **preallocatedPages = OFTLSKeyGet(preallocatedPagesKey); # endif numPreallocatedPages--; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) OFEnsure(OFTLSKeySet(numPreallocatedPagesKey, (void *)numPreallocatedPages) == 0); |
︙ | ︙ | |||
176 177 178 179 180 181 182 | OFEnsure(OFTLSKeySet(firstPageKey, page) == 0); # endif return page; } static void | | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | OFEnsure(OFTLSKeySet(firstPageKey, page) == 0); # endif return page; } static void removePageIfEmpty(struct Page *page) { unsigned char *map = page->map; size_t pageSize = [OFSystemInfo pageSize]; size_t mapSize = OFRoundUpToPowerOf2(CHAR_BIT, pageSize / chunkSize) / CHAR_BIT; for (size_t i = 0; i < mapSize; i++) |
︙ | ︙ | |||
211 212 213 214 215 216 217 | OFEnsure(OFTLSKeySet(lastPageKey, page->previous) == 0); # endif OFFreeMemory(page); } static void * | | | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | OFEnsure(OFTLSKeySet(lastPageKey, page->previous) == 0); # endif OFFreeMemory(page); } static void * allocateMemory(struct Page *page, size_t bytes) { size_t chunks, chunksLeft, pageSize, i, firstChunk; bytes = OFRoundUpToPowerOf2(chunkSize, bytes); chunks = chunksLeft = bytes / chunkSize; firstChunk = 0; pageSize = [OFSystemInfo pageSize]; |
︙ | ︙ | |||
242 243 244 245 246 247 248 | return page->page + (chunkSize * firstChunk); } return NULL; } static void | | | 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | return page->page + (chunkSize * firstChunk); } return NULL; } static void freeMemory(struct Page *page, void *pointer, size_t bytes) { size_t chunks, chunkIndex; bytes = OFRoundUpToPowerOf2(chunkSize, bytes); chunks = bytes / chunkSize; chunkIndex = ((uintptr_t)pointer - (uintptr_t)page->page) / chunkSize; |
︙ | ︙ | |||
281 282 283 284 285 286 287 | + (void)preallocateUnswappableMemoryWithSize: (size_t)size { #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) size_t pageSize = [OFSystemInfo pageSize]; size_t numPages = OFRoundUpToPowerOf2(pageSize, size) / pageSize; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) | | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | + (void)preallocateUnswappableMemoryWithSize: (size_t)size { #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) size_t pageSize = [OFSystemInfo 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; if (preallocatedPages != NULL) @throw [OFInvalidArgumentException exception]; preallocatedPages = OFAllocZeroedMemory(numPages, sizeof(struct Page)); # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) OFEnsure(OFTLSKeySet(preallocatedPagesKey, preallocatedPages) == 0); # endif @try { for (i = 0; i < numPages; i++) preallocatedPages[i] = addPage(false); |
︙ | ︙ | |||
419 420 421 422 423 424 425 | memset(_items, 0, count * itemSize); #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) } else if (count * itemSize >= pageSize) _items = mapPages(OFRoundUpToPowerOf2(pageSize, count * itemSize) / pageSize); else { # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) | | | | 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | memset(_items, 0, count * itemSize); #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) } else if (count * itemSize >= 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 for (struct Page *page = lastPage; page != NULL; page = page->previous) { _items = allocateMemory(page, count * itemSize); if (_items != NULL) { _page = page; break; } |
︙ | ︙ |