summaryrefslogtreecommitdiff
path: root/navit/support/glib
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2010-07-04 17:50:10 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2010-07-04 17:50:10 +0000
commitd3fbb8084c01917050d4c007de7647b7179efa45 (patch)
treebe723dac76b7baaa325fb72f2302973b7f8719ac /navit/support/glib
parent490dbcc240fae761a39f78f21f143dd081b77a03 (diff)
downloadnavit-d3fbb8084c01917050d4c007de7647b7179efa45.tar.gz
Fix:support_glib:Made g_slice allocator work on android
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@3473 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/support/glib')
-rw-r--r--navit/support/glib/fake.c11
-rw-r--r--navit/support/glib/fake.h18
2 files changed, 21 insertions, 8 deletions
diff --git a/navit/support/glib/fake.c b/navit/support/glib/fake.c
index 60b7b8e8a..f4db2dc15 100644
--- a/navit/support/glib/fake.c
+++ b/navit/support/glib/fake.c
@@ -42,7 +42,8 @@ CRITICAL_SECTION* g_mutex_new_navit(void)
#endif
#endif
-int g_private_new_navit ()
+GPrivate
+g_private_new_navit ()
{
int dwTlsIndex;
#if HAVE_API_WIN32_BASE
@@ -50,10 +51,14 @@ int g_private_new_navit ()
if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES)
printf(0, "TlsAlloc failed");
printf("return dwTlsIndex = 0x%x\n",dwTlsIndex);
+ return dwTlsIndex;
#else
-#warning g_private implementation is missing
+ pthread_key_t key;
+ if (pthread_key_create(&key, NULL)) {
+ fprintf(stderr,"pthread_key_create failed\n");
+ }
+ return key;
#endif
- return dwTlsIndex;
}
/**
diff --git a/navit/support/glib/fake.h b/navit/support/glib/fake.h
index 798bcf86d..ba80619f4 100644
--- a/navit/support/glib/fake.h
+++ b/navit/support/glib/fake.h
@@ -1,4 +1,7 @@
#include "config.h"
+#ifdef HAVE_API_ANDROID
+#define USE_POSIX_THREADS 1
+#endif
#if USE_POSIX_THREADS
#include <pthread.h>
#endif
@@ -6,12 +9,17 @@
#define g_return_if_fail
+
#if USE_POSIX_THREADS
# define GMutex pthread_mutex_t
# define g_mutex_new g_mutex_new_navit
# define g_mutex_lock(lock) (pthread_mutex_lock(lock))
# define g_mutex_unlock(lock) (pthread_mutex_unlock(lock))
-# define g_mutex_trylock(lock) (pthread_mutex_trylock(lock))
+# define g_mutex_trylock(lock) (pthread_mutex_trylock(lock) == 0)
+# define GPrivate pthread_key_t
+# define g_private_new(xd) g_private_new_navit()
+# define g_private_get(xd) pthread_getspecific(xd)
+# define g_private_set(a,b) pthread_setspecific(a, b)
#else
# if HAVE_API_WIN32_BASE
# define GMutex CRITICAL_SECTION
@@ -19,13 +27,13 @@
# define g_mutex_lock(lock) (EnterCriticalSection(lock))
# define g_mutex_unlock(lock) (LeaveCriticalSection(lock))
# define g_mutex_trylock(lock) (TryEnterCriticalSection(lock))
+# define GPrivate int
+# define g_private_new(xd) g_private_new_navit()
+# define g_private_get(xd) TlsGetValue(xd)
+# define g_private_set(a,b) TlsSetValue(a, b)
# endif
#endif
-#define GPrivate int
-#define g_private_new(xd) g_private_new_navit()
-#define g_private_get(xd) TlsGetValue(xd)
-#define g_private_set(a,b) TlsSetValue(a, b)
#define G_LOCK_DEFINE_STATIC(name) void
#define G_LOCK(name) void //g_mutex_lock (&G_LOCK_NAME (name))