2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
+ * glib/gatomic.h: empty G_ATOMIC_MEMORY_BARRIER() definition for
+ !G_THREADS_ENABLED
+
+ * glib/gthread.h: Define g_once and
+ g_static_mutex_get_mutex_impl_shortcut in terms of
+ G_MEMORY_BARRIER, if defined and if we can inline.
+
+ * configure.in: Remove double checked locking feature check.
+
* configure.in, config.h.win32.in, glib/gthread.c: Removed the PID
niceness surrogate for thread priorities as requested by Tim. It
does more harm than good.
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
+ * glib/gatomic.h: empty G_ATOMIC_MEMORY_BARRIER() definition for
+ !G_THREADS_ENABLED
+
+ * glib/gthread.h: Define g_once and
+ g_static_mutex_get_mutex_impl_shortcut in terms of
+ G_MEMORY_BARRIER, if defined and if we can inline.
+
+ * configure.in: Remove double checked locking feature check.
+
* configure.in, config.h.win32.in, glib/gthread.c: Removed the PID
niceness surrogate for thread priorities as requested by Tim. It
does more harm than good.
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
+ * glib/gatomic.h: empty G_ATOMIC_MEMORY_BARRIER() definition for
+ !G_THREADS_ENABLED
+
+ * glib/gthread.h: Define g_once and
+ g_static_mutex_get_mutex_impl_shortcut in terms of
+ G_MEMORY_BARRIER, if defined and if we can inline.
+
+ * configure.in: Remove double checked locking feature check.
+
* configure.in, config.h.win32.in, glib/gthread.c: Removed the PID
niceness surrogate for thread priorities as requested by Tim. It
does more harm than good.
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
+ * glib/gatomic.h: empty G_ATOMIC_MEMORY_BARRIER() definition for
+ !G_THREADS_ENABLED
+
+ * glib/gthread.h: Define g_once and
+ g_static_mutex_get_mutex_impl_shortcut in terms of
+ G_MEMORY_BARRIER, if defined and if we can inline.
+
+ * configure.in: Remove double checked locking feature check.
+
* configure.in, config.h.win32.in, glib/gthread.c: Removed the PID
niceness surrogate for thread priorities as requested by Tim. It
does more harm than good.
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
+ * glib/gatomic.h: empty G_ATOMIC_MEMORY_BARRIER() definition for
+ !G_THREADS_ENABLED
+
+ * glib/gthread.h: Define g_once and
+ g_static_mutex_get_mutex_impl_shortcut in terms of
+ G_MEMORY_BARRIER, if defined and if we can inline.
+
+ * configure.in: Remove double checked locking feature check.
+
* configure.in, config.h.win32.in, glib/gthread.c: Removed the PID
niceness surrogate for thread priorities as requested by Tim. It
does more harm than good.
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
+ * glib/gatomic.h: empty G_ATOMIC_MEMORY_BARRIER() definition for
+ !G_THREADS_ENABLED
+
+ * glib/gthread.h: Define g_once and
+ g_static_mutex_get_mutex_impl_shortcut in terms of
+ G_MEMORY_BARRIER, if defined and if we can inline.
+
+ * configure.in: Remove double checked locking feature check.
+
* configure.in, config.h.win32.in, glib/gthread.c: Removed the PID
niceness surrogate for thread priorities as requested by Tim. It
does more harm than good.
AC_MSG_RESULT($GIO)
AC_SUBST(GIO)
-dnl check for cpu to enable double checked locking when possible
-dnl ************************************************************
-
-if test x"$have_threads" != xno; then
- AC_MSG_CHECKING(whether double checked locking is safe)
- # According to glibc/linuxthreads the following platforms do
- # not have the notion of a read or write memory barrier and
- # therefore the double checked locking should be safe. Have a
- # look at pthread_once in glibc/linuxthreads/mutex.c to see,
- # what this means.
- case $host_cpu in
- arm|hppa|i386|i686|ia64|m68k|sh|cris|x86_64)
- g_use_double_checked_locking=yes
- ;;
- *)
- g_use_double_checked_locking=no
- ;;
- esac
- AC_MSG_RESULT($g_use_double_checked_locking)
-fi
-
dnl ****************************************
dnl *** platform dependent source checks ***
dnl ****************************************
_______EOF
fi
- if test x$g_use_double_checked_locking = xyes; then
- cat >>$outfile <<_______EOF
-/* double checked locking can be used on this platform */
-#define g_once(once, func, arg) \\
- ((once)->status == G_ONCE_STATUS_READY ? (once)->retval : \\
- g_once_impl (once, func, arg))
-#define g_static_mutex_get_mutex_impl_shortcut(mutex) \\
- (*(mutex) ? *(mutex) : g_static_mutex_get_mutex_impl (mutex))
-_______EOF
- else
- cat >>$outfile <<_______EOF
-/* double checked locking is unsafe to use on this platform, do full locking */
-#define g_once(once, func, arg) (g_once_impl(once, func, arg))
-#define g_static_mutex_get_mutex_impl_shortcut(mutex) \\
- (g_static_mutex_get_mutex_impl (mutex))
-_______EOF
-fi
-
cat >>$outfile <<_______EOF
/* This represents a system thread as used by the implementation. An
* alien implementaion, as loaded by g_thread_init can only count on
esac
g_threads_impl_def=$g_threads_impl
-g_use_double_checked_locking=$g_use_double_checked_locking
g_mutex_has_default="$mutex_has_default"
g_mutex_sizeof="$glib_cv_sizeof_gmutex"
return result == oldval;
}
-# define G_ATOMIC_MEMORY_BARRIER() /* Not needed */
+# define G_ATOMIC_MEMORY_BARRIER() /* Not needed */
# elif defined(G_ATOMIC_INLINED_IMPLEMENTATION_POWERPC)
/* Adapted from CVS version 1.12 of glibc's sysdeps/powerpc/bits/atomic.h
# error "Your system has an unsupported pointer size"
# endif /* GLIB_SIZEOF_VOID_P */
-# define G_ATOMIC_MEMORY_BARRIER() __asm ("sync" : : : "memory")
+# define G_ATOMIC_MEMORY_BARRIER() __asm ("sync" : : : "memory")
# elif defined(G_ATOMIC_INLINED_IMPLEMENTATION_IA64)
/* Adapted from CVS version 1.8 of glibc's sysdeps/ia64/bits/atomic.h
(long)oldval, (long)newval);
}
-# define G_ATOMIC_MEMORY_BARRIER() __sync_synchronize ()
+# define G_ATOMIC_MEMORY_BARRIER() __sync_synchronize ()
# else /* !G_ATOMIC_INLINED_IMPLEMENTATION_... */
# define G_ATOMIC_USE_FALLBACK_IMPLEMENTATION
(*(atomic) == (oldval) ? (*(atomic) = (newval), TRUE) : FALSE)
# define g_atomic_int_get(atomic) (*(atomic))
# define g_atomic_pointer_get(atomic) (*(atomic))
+# define G_ATOMIC_MEMORY_BARRIER() /* Not needed */
#endif /* G_THREADS_ENABLED */
#ifdef G_ATOMIC_USE_FALLBACK_IMPLEMENTATION
#include <glib/gerror.h>
#include <glib/gtypes.h>
+#include <glib/gutils.h> /* for G_CAN_INLINE */
+#include <glib/gatomic.h> /* for G_ATOMIC_MEMORY_BARRIER */
G_BEGIN_DECLS
gpointer g_once_impl (GOnce *once, GThreadFunc func, gpointer arg);
+#if defined (G_CAN_INLINE) && defined (G_ATOMIC_MEMORY_BARRIER)
+static inline gpointer
+g_once (GOnce *once, GThreadFunc func, gpointer arg)
+{
+ if (once->status != G_ONCE_STATUS_READY)
+ return g_once_impl (once, func, arg);
+
+ G_ATOMIC_MEMORY_BARRIER ();
+ return once->retval;
+}
+static inline GMutex*
+g_static_mutex_get_mutex_impl_shortcut (GMutex **mutex)
+{
+ if (! *mutex)
+ return g_static_mutex_get_mutex_impl (mutex);
+
+ G_ATOMIC_MEMORY_BARRIER ();
+ return *mutex;
+}
+#else /* !G_CAN_INLINE || !G_ATOMIC_MEMORY_BARRIER */
+# define g_once g_once_impl
+# define g_static_mutex_get_mutex_impl_shortcut g_static_mutex_get_mutex_impl
+#endif /* G_CAN_INLINE && G_ATOMIC_MEMORY_BARRIER*/
+
/* these are some convenience macros that expand to nothing if GLib
* was configured with --disable-threads. for using StaticMutexes,
* you define them with G_LOCK_DEFINE_STATIC (name) or G_LOCK_DEFINE (name)