summaryrefslogtreecommitdiff
path: root/liblangtag/liblangtag-0.4.0-windows.patch
blob: b76dfe943558eef7ded58d6feb258afb742add2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
141
142
143
144
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
--- misc/liblangtag-0.4.0/liblangtag/lt-macros.h
+++ misc/build/liblangtag-0.4.0/liblangtag/lt-macros.h
@@ -14,7 +14,9 @@
 #error "Only <liblangtag/langtag.h> can be included directly."
 #endif
 
+#ifndef _WIN32
 #include <sys/param.h>
+#endif
 
 #ifndef __LT_MACROS_H__
 #define __LT_MACROS_H__
@@ -206,6 +206,14 @@
 
 LT_BEGIN_DECLS
 
+#ifdef _MSC_VER
+#ifdef _M_AMD64
+typedef signed long long ssize_t;
+#else
+typedef signed int ssize_t;
+#endif
+#endif
+
 typedef void *		lt_pointer_t;
 typedef int		lt_bool_t;
 typedef lt_pointer_t (* lt_copy_func_t)	(lt_pointer_t data);
--- misc/liblangtag-0.4.0/liblangtag/lt-atomic.h
+++ misc/build/liblangtag-0.4.0/liblangtag/lt-atomic.h
@@ -17,7 +17,11 @@
 #include "config.h"
 #endif
 
+#if !defined(LT_HAVE_ATOMIC_BUILTINS) && !defined(_WIN32)
 #include <pthread.h>
+#elif defined(_WIN32)
+#include <windows.h>
+#endif
 #include "lt-messages.h"
 
 LT_BEGIN_DECLS
@@ -26,14 +30,40 @@
 LT_INLINE_FUNC int       lt_atomic_int_inc         (volatile int *v);
 LT_INLINE_FUNC lt_bool_t lt_atomic_int_dec_and_test(volatile int *v);
 
-#ifndef LT_HAVE_ATOMIC_BUILTINS
+#if !defined(LT_HAVE_ATOMIC_BUILTINS) && !defined(_WIN32)
 static pthread_mutex_t __lt_atomic_lock = PTHREAD_MUTEX_INITIALIZER;
 #endif
 
 /*< private >*/
 
 /*< public >*/
-#ifdef LT_HAVE_ATOMIC_BUILTINS
+#ifdef _WIN32
+LT_INLINE_FUNC int
+lt_atomic_int_get(volatile int *v)
+{
+       lt_return_val_if_fail (v != NULL, 0);
+
+       return (int)InterlockedExchange((LONG*)v, (LONG)*v);
+}
+
+LT_INLINE_FUNC int
+lt_atomic_int_inc(volatile int *v)
+{
+       lt_return_val_if_fail (v != NULL, 0);
+
+       return (int)InterlockedIncrement((LONG*)v);
+}
+
+lt_bool_t
+lt_atomic_int_dec_and_test(volatile int *v)
+{
+       lt_return_val_if_fail (v != NULL, FALSE);
+
+       return !InterlockedDecrement((LONG*)v);
+}
+
+
+#elif defined(LT_HAVE_ATOMIC_BUILTINS)
 LT_INLINE_FUNC int
 lt_atomic_int_get(volatile int *v)
 {
@@ -123,7 +153,7 @@
 {
 	lt_bool_t retval;
 
-	lt_return_if_fail (v != NULL, FALSE);
+       lt_return_val_if_fail (v != NULL, FALSE);
 
 	pthread_mutex_lock(&__lt_atomic_lock);
 	retval = --(*v) == 0;
--- misc/liblangtag-0.4.0/liblangtag/lt-messages.h
+++ misc/build/liblangtag-0.4.0/liblangtag/lt-messages.h
@@ -298,10 +298,17 @@
 	_lt_return_after_eval_if_fail(__expr__,__eval__)
 #define lt_return_val_after_eval_if_fail(__expr__,__val__,__eval__)	\
 	_lt_return_val_after_eval_if_fail(__expr__,__val__,__eval__)
+#ifdef __GNUC__
 #define lt_warn_if_reached()						\
 	lt_message_printf(LT_MSG_WARNING, LT_MSG_FLAG_NONE, 0,		\
 			  "(%s:%d): %s: code should not be reached",	\
 			  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#else
+#define lt_warn_if_reached()						\
+	lt_message_printf(LT_MSG_WARNING, LT_MSG_FLAG_NONE, 0,		\
+			  "(%s:%d): code should not be reached",	\
+			  __FILE__, __LINE__)
+#endif
 
 LT_END_DECLS
 
--- misc/liblangtag-0.4.0/liblangtag/lt-error.c
+++ misc/build/liblangtag-0.4.0/liblangtag/lt-error.c
@@ -14,7 +14,9 @@
 #include "config.h"
 #endif
 
+#ifndef _WIN32
 #include <execinfo.h>
+#endif
 #include <stdlib.h>
 #include "lt-list.h"
 #include "lt-mem.h"
@@ -120,13 +120,18 @@
 	d->message = lt_strdup_vprintf(message, ap);
 	va_end(ap);
 
+#ifdef _WIN32
+	size = 0;
+#else
 	size = backtrace(traces, 1024);
 	if (size > 0)
 		d->traces = backtrace_symbols(traces, size);
+#endif
 	d->stack_size = size;
 
 	lt_mem_add_ref(&d->parent, d->message, free);
-	lt_mem_add_ref(&d->parent, d->traces, free);
+	if (d->traces != NULL)
+		lt_mem_add_ref(&d->parent, d->traces, free);
 
 	allocated = (*error)->data == NULL;
 	(*error)->data = lt_list_append((*error)->data, d, (lt_destroy_func_t)lt_mem_unref);
--- misc/liblangtag-0.4.0/liblangtag/lt-ext-module.c
+++ misc/build/liblangtag-0.4.0/liblangtag/lt-ext-module.c
@@ -15,11 +15,15 @@
 #endif
 
 #include <ctype.h>
+#ifdef ENABLE_MODULE
 #include <dirent.h>
+#endif
 #ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
 #endif
+#ifndef _WIN32
 #include <libgen.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
--- misc/liblangtag-0.4.0/liblangtag/lt-xml.c
+++ misc/build/liblangtag-0.4.0/liblangtag/lt-xml.c
@@ -14,7 +14,11 @@
 #include "config.h"
 #endif
 
+#ifndef _WIN32
 #include <pthread.h>
+#else
+#include <windows.h>
+#endif
 #include <sys/stat.h>
 #include <libxml/parser.h>
 #include <libxml/xpath.h>
@@ -40,7 +44,9 @@
 };
 
 static lt_xml_t *__xml = NULL;
+#ifndef _WIN32
 static pthread_mutex_t __lt_xml_lock = PTHREAD_MUTEX_INITIALIZER;
+#endif
 
 /*< private >*/
 static lt_bool_t
@@ -309,11 +315,18 @@
 {
 	lt_error_t *err = NULL;
 
+#ifdef _WIN32
+       HANDLE __lt_xml_lock = CreateMutex(NULL, FALSE, NULL);
+#else
 	pthread_mutex_lock(&__lt_xml_lock);
+#endif
 
 	if (__xml) {
+#ifdef _WIN32
+		ReleaseMutex(__lt_xml_lock);
+#else
 		pthread_mutex_unlock(&__lt_xml_lock);
-
+#endif
 		return lt_xml_ref(__xml);
 	}
 
@@ -389,8 +402,11 @@
 		lt_xml_unref(__xml);
 	}
 
+#ifdef _WIN32
+	ReleaseMutex(__lt_xml_lock);
+#else
 	pthread_mutex_unlock(&__lt_xml_lock);
-
+#endif
 	return __xml;
 }
 
--- misc/liblangtag-0.4.0/liblangtag/lt-messages.c
+++ misc/build/liblangtag-0.4.0/liblangtag/lt-messages.c
@@ -17,7 +17,9 @@
 #include "config.h"
 #endif
 
+#ifndef _WIN32
 #include <execinfo.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -98,6 +98,7 @@
 static void
 _lt_message_stacktrace(void)
 {
+#ifndef _WIN32
 	void *traces[1024];
 	char **strings;
 	int size, i;
@@ -119,6 +119,7 @@
 		}
 		free(strings);
 	}
+#endif
 }
 
 static void
--- misc/liblangtag-0.4.0/liblangtag/lt-string.c
+++ misc/build/liblangtag-0.4.0/liblangtag/lt-string.c
@@ -302,8 +302,10 @@
 	lt_return_val_if_fail (string != NULL, NULL);
 	lt_return_val_if_fail (path != NULL, string);
 
+#ifndef _WIN32
 	if (lt_string_length(string) == 0 && path[0] != LT_DIR_SEPARATOR)
 		lt_string_append(string, LT_DIR_SEPARATOR_S);
+#endif
 
 	va_start(ap, path);
 	p = path;
--- misc/liblangtag-0.4.0/liblangtag/lt-tag.c
+++ misc/build/liblangtag-0.4.0/liblangtag/lt-tag.c
@@ -15,9 +15,15 @@
 #endif
 
 #include <ctype.h>
+#ifndef _WIN32
 #include <langinfo.h>
+#endif
 #include <locale.h>
+#ifndef HAVE_STDINT_H
+typedef int int32_t;
+#else
 #include <stdint.h>
+#endif
 #include <string.h>
 #include <libxml/xpath.h>
 #include "lt-database.h"