added win32 api based implementation for G_PLATFORM_WIN32, !__GNUC__

2003-02-29  Hans Breuer  <hans@breuer.org>

	* glib/gatomic.c : added win32 api based implementation
	for G_PLATFORM_WIN32, !__GNUC__

	* glb/glib.def : change to g_atomi_* no _fallback
This commit is contained in:
Hans Breuer 2004-02-29 21:32:27 +00:00 committed by Hans Breuer
parent 769f36db47
commit 3761f849cc
8 changed files with 92 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2003-02-29 Hans Breuer <hans@breuer.org>
* glib/gatomic.c : added win32 api based implementation
for G_PLATFORM_WIN32, !__GNUC__
* glb/glib.def : change to g_atomi_* no _fallback
2004-02-29 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in, glib/gatomic.c, glib/gatomic.h: Moved the

View File

@ -1,3 +1,10 @@
2003-02-29 Hans Breuer <hans@breuer.org>
* glib/gatomic.c : added win32 api based implementation
for G_PLATFORM_WIN32, !__GNUC__
* glb/glib.def : change to g_atomi_* no _fallback
2004-02-29 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in, glib/gatomic.c, glib/gatomic.h: Moved the

View File

@ -1,3 +1,10 @@
2003-02-29 Hans Breuer <hans@breuer.org>
* glib/gatomic.c : added win32 api based implementation
for G_PLATFORM_WIN32, !__GNUC__
* glb/glib.def : change to g_atomi_* no _fallback
2004-02-29 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in, glib/gatomic.c, glib/gatomic.h: Moved the

View File

@ -1,3 +1,10 @@
2003-02-29 Hans Breuer <hans@breuer.org>
* glib/gatomic.c : added win32 api based implementation
for G_PLATFORM_WIN32, !__GNUC__
* glb/glib.def : change to g_atomi_* no _fallback
2004-02-29 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in, glib/gatomic.c, glib/gatomic.h: Moved the

View File

@ -1,3 +1,10 @@
2003-02-29 Hans Breuer <hans@breuer.org>
* glib/gatomic.c : added win32 api based implementation
for G_PLATFORM_WIN32, !__GNUC__
* glb/glib.def : change to g_atomi_* no _fallback
2004-02-29 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in, glib/gatomic.c, glib/gatomic.h: Moved the

View File

@ -1,3 +1,10 @@
2003-02-29 Hans Breuer <hans@breuer.org>
* glib/gatomic.c : added win32 api based implementation
for G_PLATFORM_WIN32, !__GNUC__
* glb/glib.def : change to g_atomi_* no _fallback
2004-02-29 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in, glib/gatomic.c, glib/gatomic.h: Moved the

View File

@ -417,9 +417,52 @@ g_atomic_pointer_compare_and_exchange (gpointer *atomic,
# define DEFINE_WITH_MUTEXES
# endif /* G_ATOMIC */
#else /* !__GNUC__ */
# define DEFINE_WITH_MUTEXES
# ifdef G_PLATFORM_WIN32
# define DEFINE_WITH_WIN32_INTERLOCKED
# else
# define DEFINE_WITH_MUTEXES
# endif
#endif /* __GNUC__ */
#ifdef DEFINE_WITH_WIN32_INTERLOCKED
# include <windows.h>
gint32
g_atomic_int_exchange_and_add (gint32 *atomic,
gint32 val)
{
return InterlockedExchangeAdd (atomic, val);
}
void
g_atomic_int_add (gint32 *atomic,
gint32 val)
{
InterlockedExchangeAdd (atomic, val);
}
gboolean
g_atomic_int_compare_and_exchange (gint32 *atomic,
gint32 oldval,
gint32 newval)
{
return (guint32)InterlockedCompareExchange ((PVOID*)atomic,
(PVOID)newval,
(PVOID)oldval) == oldval;
}
gboolean
g_atomic_pointer_compare_and_exchange (gpointer *atomic,
gpointer oldval,
gpointer newval)
{
# if GLIB_SIZEOF_VOID_P != 4 /* no 32-bit system */
# error "InterlockedCompareExchangePointer needed"
# else
return InterlockedCompareExchange (atomic, newval, oldval) == oldval;
# endif
}
#endif /* DEFINE_WITH_WIN32_INTERLOCKED */
#ifdef DEFINE_WITH_MUTEXES
/* We have to use the slow, but safe locking method */
G_LOCK_DEFINE_STATIC (g_atomic_lock);

View File

@ -44,12 +44,12 @@ EXPORTS
g_async_queue_unref
g_async_queue_unref_and_unlock
g_atexit
g_atomic_int_add_fallback
g_atomic_int_compare_and_exchange_fallback
g_atomic_int_exchange_and_add_fallback
; g_atomic_int_get_fallback
g_atomic_pointer_compare_and_exchange_fallback
; g_atomic_pointer_get_fallback
g_atomic_int_add
g_atomic_int_compare_and_exchange
g_atomic_int_exchange_and_add
; g_atomic_int_get
g_atomic_pointer_compare_and_exchange
; g_atomic_pointer_get
g_basename
g_bit_nth_lsf
g_bit_nth_msf