]> git.sesse.net Git - vlc/blob - include/vlc_threads.h
* ./include/vlc_threads.h, ./src/misc/threads.c: improved the cond_wait
[vlc] / include / vlc_threads.h
1 /*****************************************************************************
2  * threads.h : threads implementation for the VideoLAN client
3  * This header provides a portable threads implementation.
4  *****************************************************************************
5  * Copyright (C) 1999, 2000 VideoLAN
6  * $Id: vlc_threads.h,v 1.3 2002/06/08 14:08:46 sam Exp $
7  *
8  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
9  *          Samuel Hocevar <sam@via.ecp.fr>
10  *          Gildas Bazin <gbazin@netcourrier.com>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  * 
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
25  *****************************************************************************/
26
27 #include <stdio.h>
28
29 #if defined(GPROF) || defined(DEBUG)
30 #   include <sys/time.h>
31 #endif
32
33 #if defined( PTH_INIT_IN_PTH_H )                                  /* GNU Pth */
34 #   include <pth.h>
35
36 #elif defined( ST_INIT_IN_ST_H )                            /* State threads */
37 #   include <st.h>
38
39 #elif defined( WIN32 )                                          /* Win32 API */
40 #   include <process.h>
41
42 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )  /* pthreads (like Linux & BSD) */
43 #   include <pthread.h>
44 #   ifdef DEBUG
45         /* Needed for pthread_cond_timedwait */
46 #       include <errno.h>
47 #   endif
48     /* This is not prototyped under Linux, though it exists. */
49     int pthread_mutexattr_setkind_np( pthread_mutexattr_t *attr, int kind );
50
51 #elif defined( HAVE_CTHREADS_H )                                  /* GNUMach */
52 #   include <cthreads.h>
53
54 #elif defined( HAVE_KERNEL_SCHEDULER_H )                             /* BeOS */
55 #   include <kernel/OS.h>
56 #   include <kernel/scheduler.h>
57 #   include <byteorder.h>
58
59 #else
60 #   error no threads available on your system !
61
62 #endif
63
64 /*****************************************************************************
65  * Constants
66  *****************************************************************************
67  * These constants are used by all threads in *_CreateThread() and
68  * *_DestroyThreads() functions. Since those calls are non-blocking, an integer
69  * value is used as a shared flag to represent the status of the thread.
70  *****************************************************************************/
71
72 /* Void status - this value can be used to make sure no operation is currently
73  * in progress on the concerned thread in an array of recorded threads */
74 #define THREAD_NOP          0                            /* nothing happened */
75
76 /* Creation status */
77 #define THREAD_CREATE       10                     /* thread is initializing */
78 #define THREAD_START        11                          /* thread has forked */
79 #define THREAD_READY        19                            /* thread is ready */
80
81 /* Destructions status */
82 #define THREAD_DESTROY      20            /* destruction order has been sent */
83 #define THREAD_END          21        /* destruction order has been received */
84 #define THREAD_OVER         29             /* thread does not exist any more */
85
86 /* Error status */
87 #define THREAD_ERROR        30                           /* an error occured */
88 #define THREAD_FATAL        31  /* an fatal error occured - program must end */
89
90 /*****************************************************************************
91  * Type definitions
92  *****************************************************************************/
93
94 #if defined( PTH_INIT_IN_PTH_H )
95 typedef pth_t            vlc_thread_t;
96 typedef pth_mutex_t      vlc_mutex_t;
97 typedef pth_cond_t       vlc_cond_t;
98
99 #elif defined( ST_INIT_IN_ST_H )
100 typedef st_thread_t *    vlc_thread_t;
101 typedef st_mutex_t *     vlc_mutex_t;
102 typedef st_cond_t *      vlc_cond_t;
103
104 #elif defined( WIN32 )
105 typedef HANDLE vlc_thread_t;
106 typedef BOOL (WINAPI *SIGNALOBJECTANDWAIT) ( HANDLE, HANDLE, DWORD, BOOL );
107 typedef unsigned (__stdcall *PTHREAD_START) (void *);
108
109 typedef struct
110 {
111     /* WinNT/2K/XP implementation */
112     HANDLE              mutex;
113     /* Win95/98/ME implementation */
114     CRITICAL_SECTION    csection;
115 } vlc_mutex_t;
116
117 typedef struct
118 {
119     int                 i_waiting_threads;
120     /* WinNT/2K/XP implementation */
121     HANDLE              semaphore;
122     HANDLE              signal;
123     vlc_bool_t          b_broadcast;
124     SIGNALOBJECTANDWAIT SignalObjectAndWait;
125     /* Win95/98/ME implementation */
126     enum                { SIGNAL = 0, BROADCAST = 1 };
127     HANDLE              p_events[2];
128 } vlc_cond_t;
129
130 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
131 typedef pthread_t        vlc_thread_t;
132 typedef pthread_mutex_t  vlc_mutex_t;
133 typedef pthread_cond_t   vlc_cond_t;
134
135 #elif defined( HAVE_CTHREADS_H )
136 typedef cthread_t        vlc_thread_t;
137
138 /* Those structs are the ones defined in /include/cthreads.h but we need
139  * to handle (&foo) where foo is a (mutex_t) while they handle (foo) where
140  * foo is a (mutex_t*) */
141 typedef struct
142 {
143     spin_lock_t held;
144     spin_lock_t lock;
145     char *name;
146     struct cthread_queue queue;
147 } vlc_mutex_t;
148
149 typedef struct
150 {
151     spin_lock_t lock;
152     struct cthread_queue queue;
153     char *name;
154     struct cond_imp *implications;
155 } vlc_cond_t;
156
157 #elif defined( HAVE_KERNEL_SCHEDULER_H )
158 /* This is the BeOS implementation of the vlc threads, note that the mutex is
159  * not a real mutex and the cond_var is not like a pthread cond_var but it is
160  * enough for what wee need */
161
162 typedef thread_id vlc_thread_t;
163
164 typedef struct
165 {
166     int32           init;
167     sem_id          lock;
168 } vlc_mutex_t;
169
170 typedef struct
171 {
172     int32           init;
173     thread_id       thread;
174 } vlc_cond_t;
175
176 #endif
177
178 /*****************************************************************************
179  * Function definitions
180  *****************************************************************************/
181 VLC_EXPORT( int,  __vlc_threads_init,  ( vlc_object_t * ) );
182 VLC_EXPORT( int,    vlc_threads_end,   ( void ) );
183 VLC_EXPORT( int,  __vlc_mutex_init,    ( vlc_object_t *, vlc_mutex_t * ) );
184 VLC_EXPORT( int,  __vlc_mutex_destroy, ( char *, int, vlc_mutex_t * ) );
185 VLC_EXPORT( int,  __vlc_cond_init,     ( vlc_object_t *, vlc_cond_t * ) );
186 VLC_EXPORT( int,  __vlc_cond_destroy,  ( char *, int, vlc_cond_t * ) );
187 VLC_EXPORT( int,  __vlc_thread_create, ( vlc_object_t *, char *, int, char *, void * ( * ) ( void * ), vlc_bool_t ) );
188 VLC_EXPORT( void, __vlc_thread_ready,  ( vlc_object_t * ) );
189 VLC_EXPORT( void, __vlc_thread_join,   ( vlc_object_t *, char *, int ) );
190
191 /*****************************************************************************
192  * vlc_threads_init: initialize threads system
193  *****************************************************************************/
194 #define vlc_threads_init( P_THIS )                                          \
195     __vlc_threads_init( CAST_TO_VLC_OBJECT(P_THIS) )
196
197 /*****************************************************************************
198  * vlc_mutex_init: initialize a mutex
199  *****************************************************************************/
200 #define vlc_mutex_init( P_THIS, P_MUTEX )                                   \
201     __vlc_mutex_init( CAST_TO_VLC_OBJECT(P_THIS), P_MUTEX )
202
203 /*****************************************************************************
204  * vlc_mutex_lock: lock a mutex
205  *****************************************************************************/
206 #ifdef DEBUG
207 #   define vlc_mutex_lock( P_MUTEX )                                        \
208         __vlc_mutex_lock( __FILE__, __LINE__, P_MUTEX )
209 #else
210 #   define vlc_mutex_lock( P_MUTEX )                                        \
211         __vlc_mutex_lock( "(unknown)", 0, P_MUTEX )
212 #endif
213
214 static inline int __vlc_mutex_lock( char * psz_file, int i_line,
215                                     vlc_mutex_t *p_mutex )
216 {
217 #if defined( PTH_INIT_IN_PTH_H )
218     return pth_mutex_acquire( p_mutex, TRUE, NULL );
219
220 #elif defined( ST_INIT_IN_ST_H )
221     return st_mutex_lock( *p_mutex );
222
223 #elif defined( WIN32 )
224     if( p_mutex->mutex )
225     {
226         WaitForSingleObject( p_mutex->mutex, INFINITE );
227     }
228     else
229     {
230         EnterCriticalSection( &p_mutex->csection );
231     }
232     return 0;
233
234 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
235     int i_return = pthread_mutex_lock( p_mutex );
236     if( i_return )
237     {
238 //        msg_Err( "thread %d: mutex_lock failed at %s:%d (%s)",
239 //                 pthread_self(), psz_file, i_line, strerror(i_return) );
240     }
241     return i_return;
242
243 #elif defined( HAVE_CTHREADS_H )
244     mutex_lock( p_mutex );
245     return 0;
246
247 #elif defined( HAVE_KERNEL_SCHEDULER_H )
248     status_t err;
249
250     if( !p_mutex )
251     {
252         return B_BAD_VALUE;
253     }
254
255     if( p_mutex->init < 2000 )
256     {
257         return B_NO_INIT;
258     }
259
260     err = acquire_sem( p_mutex->lock );
261     return err;
262
263 #endif
264 }
265
266 /*****************************************************************************
267  * vlc_mutex_unlock: unlock a mutex
268  *****************************************************************************/
269 #ifdef DEBUG
270 #   define vlc_mutex_unlock( P_MUTEX )                                      \
271         __vlc_mutex_unlock( __FILE__, __LINE__, P_MUTEX )
272 #else
273 #   define vlc_mutex_unlock( P_MUTEX )                                      \
274         __vlc_mutex_unlock( "(unknown)", 0, P_MUTEX )
275 #endif
276
277 static inline int __vlc_mutex_unlock( char * psz_file, int i_line,
278                                       vlc_mutex_t *p_mutex )
279 {
280 #if defined( PTH_INIT_IN_PTH_H )
281     return pth_mutex_release( p_mutex );
282
283 #elif defined( ST_INIT_IN_ST_H )
284     return st_mutex_unlock( *p_mutex );
285
286 #elif defined( WIN32 )
287     if( p_mutex->mutex )
288     {
289         ReleaseMutex( p_mutex->mutex );
290     }
291     else
292     {
293         LeaveCriticalSection( &p_mutex->csection );
294     }
295     return 0;
296
297 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
298     int i_return = pthread_mutex_unlock( p_mutex );
299     if( i_return )
300     {
301 //        msg_Err( "thread %d: mutex_unlock failed at %s:%d (%s)",
302 //                 pthread_self(), psz_file, i_line, strerror(i_return) );
303     }
304     return i_return;
305
306 #elif defined( HAVE_CTHREADS_H )
307     mutex_unlock( p_mutex );
308     return 0;
309
310 #elif defined( HAVE_KERNEL_SCHEDULER_H )
311     if( !p_mutex)
312     {
313         return B_BAD_VALUE;
314     }
315
316     if( p_mutex->init < 2000 )
317     {
318         return B_NO_INIT;
319     }
320
321     release_sem( p_mutex->lock );
322     return B_OK;
323
324 #endif
325 }
326
327 /*****************************************************************************
328  * vlc_mutex_destroy: destroy a mutex
329  *****************************************************************************/
330 #ifdef DEBUG
331 #   define vlc_mutex_destroy( P_MUTEX )                                     \
332         __vlc_mutex_destroy( __FILE__, __LINE__, P_MUTEX )
333 #else
334 #   define vlc_mutex_destroy( P_MUTEX )                                     \
335         __vlc_mutex_destroy( "(unknown)", 0, P_MUTEX )
336 #endif
337
338 /*****************************************************************************
339  * vlc_cond_init: initialize a condition
340  *****************************************************************************/
341 #define vlc_cond_init( P_THIS, P_COND )                                   \
342     __vlc_cond_init( CAST_TO_VLC_OBJECT(P_THIS), P_COND )
343
344 /*****************************************************************************
345  * vlc_cond_signal: start a thread on condition completion
346  *****************************************************************************/
347 static inline int vlc_cond_signal( vlc_cond_t *p_condvar )
348 {
349 #if defined( PTH_INIT_IN_PTH_H )
350     return pth_cond_notify( p_condvar, FALSE );
351
352 #elif defined( ST_INIT_IN_ST_H )
353     return st_cond_signal( *p_condvar );
354
355 #elif defined( WIN32 )
356     /* Release one waiting thread if one is available. */
357     /* For this trick to work properly, the vlc_cond_signal must be surrounded
358      * by a mutex. This will prevent another thread from stealing the signal */
359     if( p_condvar->i_waiting_threads )
360     {
361         if( p_condvar->signal )
362         {
363             ReleaseSemaphore( p_condvar->semaphore, 1, 0 );
364         }
365         else
366         {
367             SetEvent( p_condvar->p_events[SIGNAL] );
368         }
369     }
370     return 0;
371
372 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
373     return pthread_cond_signal( p_condvar );
374
375 #elif defined( HAVE_CTHREADS_H )
376     /* condition_signal() */
377     if ( p_condvar->queue.head || p_condvar->implications )
378     {
379         cond_signal( (condition_t)p_condvar );
380     }
381     return 0;
382
383 #elif defined( HAVE_KERNEL_SCHEDULER_H )
384     if( !p_condvar )
385     {
386         return B_BAD_VALUE;
387     }
388
389     if( p_condvar->init < 2000 )
390     {
391         return B_NO_INIT;
392     }
393
394     while( p_condvar->thread != -1 )
395     {
396         thread_info info;
397         if( get_thread_info(p_condvar->thread, &info) == B_BAD_VALUE )
398         {
399             return 0;
400         }
401
402         if( info.state != B_THREAD_SUSPENDED )
403         {
404             /* The  waiting thread is not suspended so it could
405              * have been interrupted beetwen the unlock and the
406              * suspend_thread line. That is why we sleep a little
407              * before retesting p_condver->thread. */
408             snooze( 10000 );
409         }
410         else
411         {
412             /* Ok, we have to wake up that thread */
413             resume_thread( p_condvar->thread );
414             return 0;
415         }
416     }
417     return 0;
418
419 #endif
420 }
421
422 /*****************************************************************************
423  * vlc_cond_broadcast: start all threads waiting on condition completion
424  *****************************************************************************/
425 /*
426  * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
427  * Only works with pthreads, you need to adapt it for others
428  * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
429  */
430 static inline int vlc_cond_broadcast( vlc_cond_t *p_condvar )
431 {
432 #if defined( PTH_INIT_IN_PTH_H )
433     return pth_cond_notify( p_condvar, FALSE );
434
435 #elif defined( ST_INIT_IN_ST_H )
436     return st_cond_broadcast( p_condvar );
437
438 #elif defined( WIN32 )
439     /* Release all waiting threads. */
440     if( p_condvar->i_waiting_threads )
441     {
442         if( p_condvar->signal )
443         {
444             p_condvar->b_broadcast = 1;
445             /* This call is atomic */
446             ReleaseSemaphore( p_condvar->semaphore,
447                               p_condvar->i_waiting_threads, 0 );
448             /* Wait for all threads to get the semaphore */
449             WaitForSingleObject( p_condvar->signal, INFINITE );
450             p_condvar->b_broadcast = 0;
451         }
452         else
453         {
454             SetEvent( p_condvar->p_events[BROADCAST] );
455         }
456     }
457     return 0;
458
459 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
460     return pthread_cond_broadcast( p_condvar );
461
462 #elif defined( HAVE_CTHREADS_H )
463     /* condition_signal() */
464     if ( p_condvar->queue.head || p_condvar->implications )
465     {
466         cond_signal( (condition_t)p_condvar );
467     }
468     return 0;
469
470 #elif defined( HAVE_KERNEL_SCHEDULER_H )
471     if( !p_condvar )
472     {
473         return B_BAD_VALUE;
474     }
475
476     if( p_condvar->init < 2000 )
477     {
478         return B_NO_INIT;
479     }
480
481     while( p_condvar->thread != -1 )
482     {
483         thread_info info;
484         if( get_thread_info(p_condvar->thread, &info) == B_BAD_VALUE )
485         {
486             return 0;
487         }
488
489         if( info.state != B_THREAD_SUSPENDED )
490         {
491             /* The  waiting thread is not suspended so it could
492              * have been interrupted beetwen the unlock and the
493              * suspend_thread line. That is why we sleep a little
494              * before retesting p_condver->thread. */
495             snooze( 10000 );
496         }
497         else
498         {
499             /* Ok, we have to wake up that thread */
500             resume_thread( p_condvar->thread );
501             return 0;
502         }
503     }
504     return 0;
505
506 #endif
507 }
508
509 /*****************************************************************************
510  * vlc_cond_wait: wait until condition completion
511  *****************************************************************************/
512 #ifdef DEBUG
513 #   define vlc_cond_wait( P_COND, P_MUTEX )                                   \
514         __vlc_cond_wait( __FILE__, __LINE__, P_COND, P_MUTEX  )
515 #else
516 #   define vlc_cond_wait( P_COND, P_MUTEX )                                   \
517         __vlc_cond_wait( "(unknown)", 0, P_COND, P_MUTEX )
518 #endif
519
520 static inline int __vlc_cond_wait( char * psz_file, int i_line,
521                                    vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex )
522 {
523 #if defined( PTH_INIT_IN_PTH_H )
524     return pth_cond_await( p_condvar, p_mutex, NULL );
525
526 #elif defined( ST_INIT_IN_ST_H )
527     int i_ret;
528
529     st_mutex_unlock( *p_mutex );
530     i_ret = st_cond_wait( *p_condvar );
531     st_mutex_lock( *p_mutex );
532
533     return i_ret;
534
535 #elif defined( WIN32 )
536     /* Increase our wait count */
537     p_condvar->i_waiting_threads++;
538
539     if( p_condvar->signal )
540     {
541         /* It is only possible to atomically release the mutex and initiate the
542          * waiting on WinNT/2K/XP. Win9x doesn't have SignalObjectAndWait(). */
543         p_condvar->SignalObjectAndWait( p_mutex->mutex, p_condvar->semaphore,
544                                         INFINITE, FALSE );
545         /* XXX: we should protect i_waiting_threads with a mutex, but
546          * is it really worth it ? */
547         p_condvar->i_waiting_threads--;
548
549         if( p_condvar->b_broadcast
550              && p_condvar->i_waiting_threads == 0 )
551         {
552             p_condvar->SignalObjectAndWait( p_condvar->signal, p_mutex->mutex,
553                                             INFINITE, FALSE );
554         }
555         else
556         {
557             /* Just take back the lock */
558             WaitForSingleObject( p_mutex->mutex, INFINITE );
559         }
560         return 0;
561     }
562     else
563     {
564         int i_ret;
565
566         /* Release the mutex, wait, and reacquire. */
567         LeaveCriticalSection( &p_mutex->csection );
568         i_ret = WaitForMultipleObjects( 2, p_condvar->p_events,
569                                         FALSE, INFINITE );
570         EnterCriticalSection( &p_mutex->csection );
571
572         /* Decrease our wait count */
573         p_condvar->i_waiting_threads--;
574
575         /* If we are the last waiter and it was a broadcast signal, reset
576          * the broadcast event. */
577         if( i_ret == WAIT_OBJECT_0 + BROADCAST
578              && p_condvar->i_waiting_threads == 0 )
579         {
580             ResetEvent( p_condvar->p_events[BROADCAST] );
581         }
582
583         return( i_ret == WAIT_FAILED );
584     }
585
586 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
587
588 #   ifdef DEBUG
589     /* In debug mode, timeout */
590     struct timeval now;
591     struct timespec timeout;
592     int    i_result;
593
594     for( ; ; )
595     {
596         gettimeofday( &now, NULL );
597         timeout.tv_sec = now.tv_sec + THREAD_COND_TIMEOUT;
598         timeout.tv_nsec = now.tv_usec * 1000;
599
600         i_result = pthread_cond_timedwait( p_condvar, p_mutex, &timeout );
601
602         if( i_result == ETIMEDOUT )
603         {
604 //X            msg_Warn( "thread %d: possible deadlock detected "
605 //X                      "in cond_wait at %s:%d (%s)", pthread_self(),
606 //X                      psz_file, i_line, strerror(i_result) );
607             continue;
608         }
609
610         if( i_result )
611         {
612 //X            msg_Err( "thread %d: cond_wait failed at %s:%d (%s)",
613 //X                     pthread_self(), psz_file, i_line, strerror(i_result) );
614         }
615         return( i_result );
616     }
617 #   else
618     return pthread_cond_wait( p_condvar, p_mutex );
619 #   endif
620
621 #elif defined( HAVE_CTHREADS_H )
622     condition_wait( (condition_t)p_condvar, (mutex_t)p_mutex );
623     return 0;
624
625 #elif defined( HAVE_KERNEL_SCHEDULER_H )
626     if( !p_condvar )
627     {
628         return B_BAD_VALUE;
629     }
630
631     if( !p_mutex )
632     {
633         return B_BAD_VALUE;
634     }
635
636     if( p_condvar->init < 2000 )
637     {
638         return B_NO_INIT;
639     }
640
641     /* The p_condvar->thread var is initialized before the unlock because
642      * it enables to identify when the thread is interrupted beetwen the
643      * unlock line and the suspend_thread line */
644     p_condvar->thread = find_thread( NULL );
645     vlc_mutex_unlock( p_mutex );
646     suspend_thread( p_condvar->thread );
647     p_condvar->thread = -1;
648
649     vlc_mutex_lock( p_mutex );
650     return 0;
651
652 #endif
653 }
654
655 /*****************************************************************************
656  * vlc_cond_destroy: destroy a condition
657  *****************************************************************************/
658 #ifdef DEBUG
659 #   define vlc_cond_destroy( P_COND )                                       \
660         __vlc_cond_destroy( __FILE__, __LINE__, P_COND )
661 #else
662 #   define vlc_cond_destroy( P_COND )                                       \
663         __vlc_cond_destroy( "(unknown)", 0, P_COND )
664 #endif
665
666 /*****************************************************************************
667  * vlc_thread_create: create a thread
668  *****************************************************************************/
669 #   define vlc_thread_create( P_THIS, PSZ_NAME, FUNC, WAIT )                \
670         __vlc_thread_create( CAST_TO_VLC_OBJECT(P_THIS), __FILE__, __LINE__, PSZ_NAME, (void * ( * ) ( void * ))FUNC, WAIT )
671
672 /*****************************************************************************
673  * vlc_thread_ready: tell the parent thread we were successfully spawned
674  *****************************************************************************/
675 #   define vlc_thread_ready( P_THIS )                                       \
676         __vlc_thread_ready( CAST_TO_VLC_OBJECT(P_THIS) )
677
678 /*****************************************************************************
679  * vlc_thread_join: wait until a thread exits
680  *****************************************************************************/
681 #ifdef DEBUG
682 #   define vlc_thread_join( P_THIS )                                        \
683         __vlc_thread_join( CAST_TO_VLC_OBJECT(P_THIS), __FILE__, __LINE__ ) 
684 #else
685 #   define vlc_thread_join( P_THIS )                                        \
686         __vlc_thread_join( CAST_TO_VLC_OBJECT(P_THIS), "(unknown)", 0 ) 
687 #endif