ObjFW  Check-in [72c6e67a23]

Overview
Comment:OFSystemInfo: Add +[supportsL(A)SX]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 72c6e67a23fac1c5935e767a586cc7629726c6198be20f4265209ea761a10eda
User & Date: js on 2024-08-18 12:54:06
Other Links: manifest | tags
Context
2024-08-18
15:26
Move PLATFORMS.md to wiki check-in: abe7e4f7f8 user: js tags: trunk
12:54
OFSystemInfo: Add +[supportsL(A)SX] check-in: 72c6e67a23 user: js tags: trunk
2024-08-17
21:25
PLATFORMS.md: Add Solaris/SPARC64 check-in: 7ccd2db127 user: js tags: trunk
Changes

Modified src/OFSystemInfo.h from [c74583c9f4] to [c155a2119a].

90
91
92
93
94
95
96




97
98
99
100
101
102
103
@property (class, readonly, nonatomic) bool supportsAVX512BitAlgorithms;
@property (class, readonly, nonatomic) bool supportsAVX512Float16Instructions;
@property (class, readonly, nonatomic) bool supportsAVX512BFloat16Instructions;
# endif
# if defined(OF_POWERPC) || defined(OF_POWERPC64) || defined(DOXYGEN)
@property (class, readonly, nonatomic) bool supportsAltiVec;
# endif




# if defined(OF_WINDOWS) || defined(DOXYGEN)
@property (class, readonly, nonatomic, getter=isWindowsNT) bool windowsNT;
# endif
#endif

/**
 * @brief Returns the size of a page.







>
>
>
>







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
@property (class, readonly, nonatomic) bool supportsAVX512BitAlgorithms;
@property (class, readonly, nonatomic) bool supportsAVX512Float16Instructions;
@property (class, readonly, nonatomic) bool supportsAVX512BFloat16Instructions;
# endif
# if defined(OF_POWERPC) || defined(OF_POWERPC64) || defined(DOXYGEN)
@property (class, readonly, nonatomic) bool supportsAltiVec;
# endif
# if defined(OF_LOONGARCH64) || defined(DOXYGEN)
@property (class, readonly, nonatomic) bool supportsLSX;
@property (class, readonly, nonatomic) bool supportsLASX;
# endif
# if defined(OF_WINDOWS) || defined(DOXYGEN)
@property (class, readonly, nonatomic, getter=isWindowsNT) bool windowsNT;
# endif
#endif

/**
 * @brief Returns the size of a page.
526
527
528
529
530
531
532




















533
534
535
536
537
538
539
 *
 * @note This method is only available on PowerPC and PowerPC 64.
 *
 * @return Whether the CPU and OS support AltiVec
 */
+ (bool)supportsAltiVec;
#endif





















#if defined(OF_WINDOWS) || defined(DOXYGEN)
/**
 * @brief Returns whether the application is running on Windows NT.
 *
 * @note This method is only available on Windows.
 *







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
 *
 * @note This method is only available on PowerPC and PowerPC 64.
 *
 * @return Whether the CPU and OS support AltiVec
 */
+ (bool)supportsAltiVec;
#endif

#if defined(OF_LOONGARCH64) || defined(DOXYGEN)
/**
 * @brief Returns whether the CPU and OS support LSX.
 *
 * @note This method is only available on LoongArch 64!
 *
 * @return Whether the CPU and OS support LSX
 */
+ (bool)supportsLSX;

/**
 * @brief Returns whether the CPU and OS support LASX.
 *
 * @note This method is only available on LoongArch 64!
 *
 * @return Whether the CPU and OS support LASX
 */
+ (bool)supportsLASX;
#endif

#if defined(OF_WINDOWS) || defined(DOXYGEN)
/**
 * @brief Returns whether the application is running on Windows NT.
 *
 * @note This method is only available on Windows.
 *

Modified src/OFSystemInfo.m from [88de548cfa] to [4ca3a2659e].

374
375
376
377
378
379
380
















381
382
383
384
385
386
387
	      "=d" (regs.edx)
	    : "c" (ecx)
	);

	return regs;
}
#endif

















@implementation OFSystemInfo
+ (void)initialize
{
	long tmp;

	if (self != [OFSystemInfo class])







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
	      "=d" (regs.edx)
	    : "c" (ecx)
	);

	return regs;
}
#endif

#ifdef OF_LOONGARCH64
static uint32_t
cpucfg(uint32_t word)
{
	uint32_t ret;

	__asm__ (
	    "cpucfg	%0, %1"
	    : "=r" (ret)
	    : "r" (word)
	);

	return ret;
}
#endif

@implementation OFSystemInfo
+ (void)initialize
{
	long tmp;

	if (self != [OFSystemInfo class])
1023
1024
1025
1026
1027
1028
1029












1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
	    SYSTEMINFOTYPE_PPC_ALTIVEC, TAG_DONE) > 0)
		return supportsAltiVec;
# endif

	return false;
}
#endif













#ifdef OF_WINDOWS
+ (bool)isWindowsNT
{
	return !(GetVersion() & 0x80000000);
}
#endif

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}
@end







>
>
>
>
>
>
>
>
>
>
>
>













1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
	    SYSTEMINFOTYPE_PPC_ALTIVEC, TAG_DONE) > 0)
		return supportsAltiVec;
# endif

	return false;
}
#endif

#ifdef OF_LOONGARCH64
+ (bool)supportsLSX
{
	return cpucfg(2) & (1 << 6);
}

+ (bool)supportsLASX
{
	return cpucfg(2) & (1 << 7);
}
#endif

#ifdef OF_WINDOWS
+ (bool)isWindowsNT
{
	return !(GetVersion() & 0x80000000);
}
#endif

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}
@end

Modified tests/OFSystemInfoTests.m from [9d8e320163] to [655d6b2a77].

131
132
133
134
135
136
137





138
139
140
141
142
143
144
	ADD_BOOL(@"Supports AVX-512 BFloat16 Instructions",
	    [OFSystemInfo supportsAVX512BFloat16Instructions]);
#endif

#ifdef OF_POWERPC
	ADD_BOOL(@"Supports AltiVec", [OFSystemInfo supportsAltiVec]);
#endif






#undef ADD
#undef ADD_UINT
#undef ADD_ULONGLONG
#undef ADD_BOOL

#ifdef OF_HAVE_SOCKETS







>
>
>
>
>







131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
	ADD_BOOL(@"Supports AVX-512 BFloat16 Instructions",
	    [OFSystemInfo supportsAVX512BFloat16Instructions]);
#endif

#ifdef OF_POWERPC
	ADD_BOOL(@"Supports AltiVec", [OFSystemInfo supportsAltiVec]);
#endif

#ifdef OF_LOONGARCH64
	ADD_BOOL(@"Supports LSX", [OFSystemInfo supportsLSX]);
	ADD_BOOL(@"Supports LASX", [OFSystemInfo supportsLASX]);
#endif

#undef ADD
#undef ADD_UINT
#undef ADD_ULONGLONG
#undef ADD_BOOL

#ifdef OF_HAVE_SOCKETS