Overview
| Comment: | Make struct size a multiple of the alignment |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
b52c4a41e4c688ced06a5629af8e8339 |
| User & Date: | js on 2017-10-22 20:58:20 |
| Other Links: | manifest | tags |
Context
|
2017-10-23
| ||
| 20:43 | runtime: Make Apple GCC with -Wshadow happy (check-in: 31155755cc user: js tags: trunk) | |
|
2017-10-22
| ||
| 20:58 | Make struct size a multiple of the alignment (check-in: b52c4a41e4 user: js tags: trunk) | |
| 18:31 | OFMethodSignature: Correctly handle Darwin/PPC ABI (check-in: f641fc7faa user: js tags: trunk) | |
Changes
Modified src/OFMethodSignature.m from [70534fd085] to [1e877ea8dd].
| ︙ | ︙ | |||
297 298 299 300 301 302 303 |
return count * size;
}
size_t
sizeofStruct(const char **type, size_t *length)
{
size_t size = 0;
| < < < < < | | | < > > | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
return count * size;
}
size_t
sizeofStruct(const char **type, size_t *length)
{
size_t size = 0;
const char *typeCopy = *type;
size_t lengthCopy = *length;
size_t alignment = alignofStruct(&typeCopy, &lengthCopy);
#if defined(OF_POWERPC) && defined(OF_MACOS)
bool first = true;
#endif
assert(*length > 0);
(*type)++;
(*length)--;
|
| ︙ | ︙ | |||
327 328 329 330 331 332 333 |
@throw [OFInvalidFormatException exception];
/* Skip '=' */
(*type)++;
(*length)--;
while (*length > 0 && **type != '}') {
| > > | | | | | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
@throw [OFInvalidFormatException exception];
/* Skip '=' */
(*type)++;
(*length)--;
while (*length > 0 && **type != '}') {
size_t fieldSize, fieldAlign;
typeCopy = *type;
lengthCopy = *length;
fieldSize = sizeofEncoding(type, length);
fieldAlign = alignofEncoding(&typeCopy, &lengthCopy);
#if defined(OF_POWERPC) && defined(OF_MACOS)
if (!first && fieldAlign > 4)
fieldAlign = 4;
first = false;
#endif
|
| ︙ | ︙ | |||
360 361 362 363 364 365 366 | if (*length == 0 || **type != '}') @throw [OFInvalidFormatException exception]; (*type)++; (*length)--; | < < | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
if (*length == 0 || **type != '}')
@throw [OFInvalidFormatException exception];
(*type)++;
(*length)--;
if (size % alignment != 0) {
size_t padding = alignment - (size % alignment);
if (SIZE_MAX - size < padding)
@throw [OFOutOfRangeException exception];
size += padding;
}
return size;
}
size_t
sizeofUnion(const char **type, size_t *length)
{
|
| ︙ | ︙ |