ObjFW  Check-in [f050580b33]

Overview
Comment:OFSystemInfo: Add +[wineVersion]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f050580b33628751b6d2c9c63420904e8cc64eb1cd1750183fc971da3902add6
User & Date: js on 2024-03-17 15:57:42
Other Links: manifest | tags
Context
2024-03-17
16:14
OFMutableIRI: Fix -[appendPathComponent:] check-in: 1970fcd564 user: js tags: trunk
15:57
OFSystemInfo: Add +[wineVersion] check-in: f050580b33 user: js tags: trunk
14:29
GitHub Actions: Add macos-14 check-in: b6f77c627a user: js tags: trunk
Changes

Modified src/OFSystemInfo.h from [968aead0d7] to [c3ae251de2].

33
34
35
36
37
38
39



40
41
42
43
44
45
46
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49







+
+
+







@property (class, readonly, nonatomic) size_t numberOfCPUs;
@property (class, readonly, nonatomic) OFString *ObjFWVersion;
@property (class, readonly, nonatomic) unsigned short ObjFWVersionMajor;
@property (class, readonly, nonatomic) unsigned short ObjFWVersionMinor;
@property (class, readonly, nullable, nonatomic) OFString *operatingSystemName;
@property (class, readonly, nullable, nonatomic)
    OFString *operatingSystemVersion;
#if defined(OF_WINDOWS) || defined(DOXYGEN)
@property (class, readonly, nullable, nonatomic) OFString *wineVersion;
#endif
@property (class, readonly, nullable, nonatomic) OFIRI *userDataIRI;
@property (class, readonly, nullable, nonatomic) OFIRI *userConfigIRI;
@property (class, readonly, nullable, nonatomic) OFIRI *temporaryDirectoryIRI;
@property (class, readonly, nullable, nonatomic) OFString *CPUVendor;
@property (class, readonly, nullable, nonatomic) OFString *CPUModel;
# if defined(OF_AMD64) || defined(OF_X86) || defined(DOXYGEN)
@property (class, readonly, nonatomic) bool supportsMMX;
142
143
144
145
146
147
148













149
150
151
152
153
154
155
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







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







/**
 * @brief Returns the version of the operating system the application is
 *	  running on.
 *
 * @return The version of the operating system the application is running on
 */
+ (nullable OFString *)operatingSystemVersion;

#if defined(OF_WINDOWS) || defined(DOXYGEN)
/**
 * @brief Returns the version of Wine the application is running on, or `nil`
 *	  if not running on Wine (e.g. on Windows natively).
 *
 * @note This is only available on Windows.
 *
 * @return The version of Wine the application is running on, or `nil` if not
 *	   running on Wine (e.g. on Windows natively)
 */
+ (nullable OFString *)wineVersion;
#endif

/**
 * @brief Returns the path where user data for the application can be stored.
 *
 * On UNIX systems, this adheres to the XDG Base Directory specification.@n
 * On macOS and iOS, it uses the `NSApplicationSupportDirectory` directory.@n
 * On Windows, it uses the `APPDATA` environment variable.@n

Modified src/OFSystemInfo.m from [601054135e] to [d0a8a94e19].

154
155
156
157
158
159
160




161
162
163
164
165
166
167
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171







+
+
+
+







# endif
#endif

static size_t pageSize = 4096;
static size_t numberOfCPUs = 1;
static OFString *operatingSystemName = nil;
static OFString *operatingSystemVersion = nil;

#ifdef OF_WINDOWS
static const char *(*wine_get_version)(void);
#endif

static void
initOperatingSystemName(void)
{
#if defined(OF_IOS)
	operatingSystemName = @"iOS";
#elif defined(OF_MACOS)
387
388
389
390
391
392
393


394
395
396
397




398
399
400
401
402
403
404
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414







+
+




+
+
+
+







	 * Required as cpuid can return SSE support while the OS has not
	 * enabled it.
	 */
	SSETest();
#endif

#if defined(OF_WINDOWS)
	HANDLE module;

	SYSTEM_INFO si;
	GetSystemInfo(&si);
	pageSize = si.dwPageSize;
	numberOfCPUs = si.dwNumberOfProcessors;

	if ((module = GetModuleHandle("ntdll.dll")) != NULL)
		wine_get_version = (const char *(*)(void))
		    GetProcAddress(module, "wine_get_version");
#elif defined(OF_QNX)
	if ((tmp = sysconf(_SC_PAGESIZE)) > 0)
		pageSize = tmp;
	numberOfCPUs = _syspage_ptr->num_cpu;
#else
# if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
	if ((tmp = sysconf(_SC_PAGESIZE)) > 0)
454
455
456
457
458
459
460











461
462
463
464
465
466
467
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488







+
+
+
+
+
+
+
+
+
+
+







+ (OFString *)operatingSystemVersion
{
	static OFOnceControl onceControl = OFOnceControlInitValue;
	OFOnce(&onceControl, initOperatingSystemVersion);

	return operatingSystemVersion;
}

#ifdef OF_WINDOWS
+ (OFString *)wineVersion
{
	if (wine_get_version != NULL)
		return [OFString stringWithCString: wine_get_version()
					  encoding: [OFLocale encoding]];

	return nil;
}
#endif

+ (OFIRI *)userDataIRI
{
#ifdef OF_HAVE_FILES
# if defined(OF_MACOS) || defined(OF_IOS)
	char pathC[PATH_MAX];
	OFMutableString *path;

Modified tests/OFSystemInfoTests.m from [0545403f54] to [3eed8858f0].

61
62
63
64
65
66
67



68
69
70
71
72
73
74
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77







+
+
+







	ADD(name, [OFNumber numberWithBool: value]);

	ADD(@"ObjFW version", [OFSystemInfo ObjFWVersion])
	ADD_UINT(@"ObjFW version major", [OFSystemInfo ObjFWVersionMajor])
	ADD_UINT(@"ObjFW version minor", [OFSystemInfo ObjFWVersionMinor])
	ADD(@"Operating system name", [OFSystemInfo operatingSystemName]);
	ADD(@"Operating system version", [OFSystemInfo operatingSystemVersion]);
#ifdef OF_WINDOWS
	ADD(@"Wine version", [OFSystemInfo wineVersion]);
#endif
	ADD_ULONGLONG(@"Page size", [OFSystemInfo pageSize]);
	ADD_ULONGLONG(@"Number of CPUs", [OFSystemInfo numberOfCPUs]);
	ADD(@"User config IRI", [OFSystemInfo userConfigIRI].string);
	ADD(@"User data IRI", [OFSystemInfo userDataIRI].string);
	ADD(@"Temporary directory IRI",
	    [OFSystemInfo temporaryDirectoryIRI].string);
	ADD(@"CPU vendor", [OFSystemInfo CPUVendor]);