ObjFW  Check-in [2ba8ec1bf1]

Overview
Comment:Add +[OFSystemInfo supportsAltiVec]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2ba8ec1bf17de27521fe5dcaa6c1157950ba94c2bce14df17705217db086bcd0
User & Date: js on 2015-11-02 21:49:33
Other Links: manifest | tags
Context
2015-11-04
20:43
configure.ac: Avoid a rare warning check-in: f7a80d7d63 user: js tags: trunk
2015-11-02
21:49
Add +[OFSystemInfo supportsAltiVec] check-in: 2ba8ec1bf1 user: js tags: trunk
19:27
OFSHA*Hash: Minor cleanup check-in: 6a3c47863d user: js tags: trunk
Changes

Modified src/OFSystemInfo.h from [cb7463de6c] to [5abab9f67b].

180
181
182
183
184
185
186











187
188
189
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200







+
+
+
+
+
+
+
+
+
+
+



 *
 * @note This method is only available on x86 and x86_64.
 *
 * @return Whether the CPU supports AVX2
 */
+ (bool)supportsAVX2;
#endif

#if defined(OF_POWERPC) || defined(OF_POWERPC64)
/*!
 * @brief Returns whether the CPU and OS support AltiVec.
 *
 * @note This method is only available on PowerPC and PowerPC64.
 *
 * @return Whether the CPU and OS support AltiVec
 */
+ (bool)supportsAltiVec;
#endif
@end

OF_ASSUME_NONNULL_END

Modified src/OFSystemInfo.m from [db62f84bfb] to [918d680213].

21
22
23
24
25
26
27






28
29
30
31
32
33
34
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40







+
+
+
+
+
+







/* Work around __block being used by glibc */
#include <stdlib.h>	/* include any libc header to get the libc defines */
#ifdef __GLIBC__
# undef __USE_XOPEN
#endif

#include <unistd.h>

#include "platform.h"

#ifdef OF_MAC_OS_X
# include <sys/sysctl.h>
#endif

#import "OFSystemInfo.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFApplication.h"

363
364
365
366
367
368
369















370
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

}

+ (bool)supportsAVX2
{
	return x86_cpuid(0, 0).eax >= 7 && (x86_cpuid(7, 0).ebx & (1 << 5));
}
#endif

#if defined(OF_POWERPC) || defined(OF_POWERPC64)
+ (bool)supportsAltiVec
{
# ifdef OF_MAC_OS_X
	int name[2] = { CTL_HW, HW_VECTORUNIT }, value = 0;
	size_t length = sizeof(value);

	if (sysctl(name, 2, &value, &length, NULL, 0) == 0)
		return value;
# endif

	return 0;
}
#endif
@end