VLC_EXPORT( void, vlc_threadvar_delete, (vlc_threadvar_t *) );
VLC_EXPORT( int, __vlc_thread_create, ( vlc_object_t *, const char *, int, const char *, void * ( * ) ( void * ), int, bool ) );
VLC_EXPORT( int, __vlc_thread_set_priority, ( vlc_object_t *, const char *, int, int ) );
-VLC_EXPORT( void, __vlc_thread_ready, ( vlc_object_t * ) );
VLC_EXPORT( void, __vlc_thread_join, ( vlc_object_t *, const char *, int ) );
+#define vlc_thread_ready vlc_object_signal
+
/*****************************************************************************
* vlc_mutex_lock: lock a mutex
*****************************************************************************/
if (val) \
vlc_pthread_fatal (action, val, psz_file, i_line)
#else
-# define VLC_THREAD_ASSERT (void)0
+# define VLC_THREAD_ASSERT ((void)(val))
#endif
static inline void __vlc_mutex_lock( const char * psz_file, int i_line,
# define vlc_spin_destroy vlc_mutex_destroy
#endif
+/**
+ * Issues a full memory barrier.
+ */
+#if defined (__APPLE__)
+# include <libkern/OSAtomic.h> /* OSMemoryBarrier() */
+#endif
+static inline void barrier (void)
+{
+#if defined (__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
+ __sync_synchronize ();
+#elif defined(__APPLE__)
+ OSMemoryBarrier ();
+#elif defined(__powerpc__)
+ asm volatile ("sync":::"memory");
+#elif defined(__i386__)
+ asm volatile ("mfence":::"memory");
+#elif defined (LIBVLC_USE_PTHREAD)
+ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_lock (&lock);
+ pthread_mutex_unlock (&lock);
+#else
+# error barrier not implemented!
+#endif
+}
+
/*****************************************************************************
* vlc_thread_create: create a thread
*****************************************************************************/
#define vlc_thread_set_priority( P_THIS, PRIORITY ) \
__vlc_thread_set_priority( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PRIORITY )
-/*****************************************************************************
- * vlc_thread_ready: tell the parent thread we were successfully spawned
- *****************************************************************************/
-#define vlc_thread_ready( P_THIS ) \
- __vlc_thread_ready( VLC_OBJECT(P_THIS) )
-
/*****************************************************************************
* vlc_thread_join: wait until a thread exits
*****************************************************************************/