ObjFW  Diff

Differences From Artifact [13b78669de]:

To Artifact [2f5eb2340c]:


20
21
22
23
24
25
26

27
28
29
30
31
32
33
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34







+








/* 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 <locale.h>
#include <unistd.h>

#include "platform.h"

#ifdef OF_MAC_OS_X
# include <sys/sysctl.h>
#endif
61
62
63
64
65
66
67




68





69
70
71























































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



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140







+
+
+
+

+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







struct x86_regs {
	uint32_t eax, ebx, ecx, edx;
};
#endif

static size_t pageSize;
static size_t numberOfCPUs;
static of_string_encoding_t native8BitEncoding = OF_STRING_ENCODING_UTF_8;
static OFString *language = nil;
static OFString *territory = nil;
static OFString *decimalPoint = @".";

void
of_system_info_parse_locale(char *locale)
{
	if (locale == NULL)
		return;
of_string_encoding_t of_system_info_native_8bit_encoding =
    OF_STRING_ENCODING_UTF_8;
OFString *of_system_info_decimal_point = @".";

	locale = of_strdup(locale);

	@try {
		char *tmp;

		/* We don't care for extras behind the @ */
		if ((tmp = strrchr(locale, '@')) != NULL)
			*tmp = '\0';

		/* Encoding */
		if ((tmp = strrchr(locale, '.')) != NULL) {
			size_t tmpLen;

			*tmp++ = '\0';

			tmpLen = strlen(tmp);
			for (size_t i = 0; i < tmpLen; i++)
				tmp[i] = of_ascii_tolower(tmp[i]);

			if (strcmp(tmp, "utf8") == 0 ||
			    strcmp(tmp, "utf-8") == 0)
				native8BitEncoding = OF_STRING_ENCODING_UTF_8;
			else if (strcmp(tmp, "ascii") == 0 ||
			    strcmp(tmp, "us-ascii") == 0)
				native8BitEncoding = OF_STRING_ENCODING_ASCII;
			else if (strcmp(tmp, "iso8859-1") == 0 ||
			    strcmp(tmp, "iso-8859-1") == 0)
				native8BitEncoding =
				    OF_STRING_ENCODING_ISO_8859_1;
			else if (strcmp(tmp, "iso8859-15") == 0 ||
			    strcmp(tmp, "iso-8859-15") == 0)
				native8BitEncoding =
				    OF_STRING_ENCODING_ISO_8859_15;
		}

		/* Territory */
		if ((tmp = strrchr(locale, '_')) != NULL) {
			*tmp++ = '\0';
			territory = [[OFString alloc]
			    initWithCString: tmp
				   encoding: OF_STRING_ENCODING_ASCII];
		}

		language = [[OFString alloc]
		    initWithCString: locale
			   encoding: OF_STRING_ENCODING_ASCII];
	} @finally {
		free(locale);
	}

	decimalPoint = [[OFString alloc]
	    initWithCString: localeconv()->decimal_point
		   encoding: native8BitEncoding];
}

#if defined(OF_X86_64) || defined(OF_X86)
static OF_INLINE struct x86_regs OF_CONST_FUNC
x86_cpuid(uint32_t eax, uint32_t ecx)
{
	struct x86_regs regs;

145
146
147
148
149
150
151


152









153
154
155
156
157

158
159
160
161
162
163
164
207
208
209
210
211
212
213
214
215

216
217
218
219
220
221
222
223
224
225
226
227
228

229
230
231
232
233
234
235
236







+
+
-
+
+
+
+
+
+
+
+
+




-
+







+ (size_t)numberOfCPUs
{
	return numberOfCPUs;
}

+ (of_string_encoding_t)native8BitEncoding
{
	return native8BitEncoding;
}
	return of_system_info_native_8bit_encoding;

+ (OFString*)language
{
	return language;
}

+ (OFString*)territory
{
	return territory;
}

+ (OFString*)decimalPoint
{
	return of_system_info_decimal_point;
	return decimalPoint;
}

+ (OFString*)userDataPath
{
#if defined(OF_MAC_OS_X) || defined(OF_IOS)
	void *pool = objc_autoreleasePoolPush();
	char pathC[PATH_MAX];