Kaydet (Commit) 93e83584 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Start making liblangtag 0.4.0 build for Windows

Harder than I expected. Still incomplete. Thanks to Fridrich for the
atomic stuff.

Change-Id: Iacf6d3708ee04c75b98da4ffe250194657fda7c8
üst 78c5ba99
--- misc/liblangtag-0.4.0/configure.ac
+++ misc/build/liblangtag-0.4.0/configure.ac
@@ -291,8 +291,14 @@
dnl ======================================================================
dnl check another libraries
dnl ======================================================================
+case $host_os in
+ cygwin* | mingw*)
+ ;;
-AX_PTHREAD([],
+ *)
+ AX_PTHREAD([],
[AC_MSG_ERROR([*** pthread library are required])])
+ ;;
+esac
GOBJECT_INTROSPECTION_CHECK([1.30.0])
if test "x$enable_introspection" != "xyes"; then
--- misc/liblangtag-0.4.0/configure
+++ misc/build/liblangtag-0.4.0/configure
@@ -13203,6 +13203,10 @@
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
+case $host_os in
+ cygwin* | mingw*)
+ ;;
+ *)
ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
@@ -13584,6 +13584,8 @@
ax_pthread_ok=no
as_fn_error $? "*** pthread library are required" "$LINENO" 5
fi
+;;
+esac
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
--- 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)InterlockedAdd((LONG*)v, 0);
+}
+
+LT_INLINE_FUNC int
+lt_atomic_int_inc(volatile int *v)
+{
+ lt_return_val_if_fail (v != NULL, 0);
+
+ return (int)InterlockedAdd((LONG*)v, 1);
+}
+
+lt_bool_t
+lt_atomic_int_dec_and_test(volatile int *v)
+{
+ lt_return_val_if_fail (v != NULL, FALSE);
+
+ return 1 == InterlockedAdd((LONG*)v, -1);
+}
+
+
+#elif defined(LT_HAVE_ATOMIC_BUILTINS)
LT_INLINE_FUNC int
lt_atomic_int_get(volatile int *v)
{
--- 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,9 +120,13 @@
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);
--- 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-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>
+#ifdef _MSC_VER
+typedef int int32_t;
+#else
#include <stdint.h>
+#endif
#include <string.h>
#include <libxml/xpath.h>
#include "lt-database.h"
...@@ -35,6 +35,7 @@ TARFILE_NAME=liblangtag-$(LIBLANGTAG_MAJOR).$(LIBLANGTAG_MINOR).$(LIBLANGTAG_MIC ...@@ -35,6 +35,7 @@ TARFILE_NAME=liblangtag-$(LIBLANGTAG_MAJOR).$(LIBLANGTAG_MINOR).$(LIBLANGTAG_MIC
TARFILE_MD5=54e578c91b1b68e69c72be22adcb2195 TARFILE_MD5=54e578c91b1b68e69c72be22adcb2195
PATCH_FILES=liblangtag-0.4.0-msvc-warning.patch PATCH_FILES=liblangtag-0.4.0-msvc-warning.patch
PATCH_FILES+=liblangtag-0.4.0-windows.patch
PATCH_FILES+=liblangtag-0.4.0-reg2xml-encoding-problem.patch PATCH_FILES+=liblangtag-0.4.0-reg2xml-encoding-problem.patch
.IF "$(OS)" == "MACOSX" .IF "$(OS)" == "MACOSX"
PATCH_FILES=liblangtag-0.4.0-mac.patch PATCH_FILES=liblangtag-0.4.0-mac.patch
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment