ObjFW  Check-in [f6afff33eb]

Overview
Comment:OFObject: Use posix_memalign() on Solaris

In 32 bit mode, malloc() doesn't always return pointers correctly
aligned for SSE.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f6afff33ebc4bdf7d7cb74a4509b335e14d2c356404f1efa0865aea8b634214d
User & Date: js on 2024-04-09 19:35:13
Other Links: manifest | tags
Context
2024-04-09
19:59
ofhttp: Don't limit setting xattr to Linux check-in: 9c9dc239ba user: js tags: trunk
19:35
OFObject: Use posix_memalign() on Solaris check-in: f6afff33eb user: js tags: trunk
2024-04-08
00:21
Don't depend on EXTATTR_NAMESPACE_NAMES on NetBSD check-in: e38777bbf2 user: js tags: trunk
Changes

Modified src/OFObject.m from [d8ad2314c9] to [88eeb2453d].

376
377
378
379
380
381
382
383
384
385
386
387


388

389

390
391

392
393
394
395
396
397
398
376
377
378
379
380
381
382


383
384
385
386
387

388

389
390

391
392
393
394
395
396
397
398







-
-



+
+
-
+
-
+

-
+







		extraAlignment = OFRoundUpToPowerOf2(extraAlignment,
		    PRE_IVARS_ALIGN + instanceSize) -
		    PRE_IVARS_ALIGN - instanceSize;

#if defined(OF_WINDOWS)
	instance = __mingw_aligned_malloc(PRE_IVARS_ALIGN + instanceSize +
	    extraAlignment + extraSize, OF_BIGGEST_ALIGNMENT);
	memset(instance, 0, PRE_IVARS_ALIGN + instanceSize + extraAlignment +
	    extraSize);
#elif defined(OF_MSDOS)
	instance = alignedAlloc(PRE_IVARS_ALIGN + instanceSize +
	    extraAlignment + extraSize, OF_BIGGEST_ALIGNMENT, &offset);
#elif defined(OF_SOLARIS)
	if (posix_memalign((void **)&instance, OF_BIGGEST_ALIGNMENT,
	memset(instance, 0, PRE_IVARS_ALIGN + instanceSize + extraAlignment +
	    PRE_IVARS_ALIGN + instanceSize + extraAlignment + extraSize) != 0)
	    extraSize);
		instance = NULL;
#else
	instance = calloc(1, PRE_IVARS_ALIGN + instanceSize +
	instance = malloc(PRE_IVARS_ALIGN + instanceSize +
	    extraAlignment + extraSize);
#endif

	if OF_UNLIKELY (instance == nil) {
		object_setClass((id)&allocFailedException,
		    [OFAllocFailedException class]);
		@throw (id)&allocFailedException;
415
416
417
418
419
420
421


422
423
424
425
426
427
428
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430







+
+







# endif
		@throw [OFInitializationFailedException
		    exceptionWithClass: class];
	}
#endif

	instance = (OFObject *)(void *)((char *)instance + PRE_IVARS_ALIGN);

	memset(instance, 0, instanceSize + extraAlignment + extraSize);

	if (!objc_constructInstance(class, instance)) {
#if !defined(OF_HAVE_ATOMIC_OPS) && !defined(OF_AMIGAOS)
		OFSpinlockFree(&((struct PreIvars *)(void *)
		    ((char *)instance - PRE_IVARS_ALIGN))->retainCountSpinlock);
#endif
#if defined(OF_WINDOWS)