2bbb333fda4131199446dc330d2eb8dd9ad970f9
[vlc.git] / 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.5 2002/07/16 21:29:10 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     HANDLE              p_events[2];
127 } vlc_cond_t;
128
129 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
130 typedef pthread_t        vlc_thread_t;
131 typedef pthread_mutex_t  vlc_mutex_t;
132 typedef pthread_cond_t   vlc_cond_t;
133
134 #elif defined( HAVE_CTHREADS_H )
135 typedef cthread_t        vlc_thread_t;
136
137 /* Those structs are the ones defined in /include/cthreads.h but we need
138  * to handle (&foo) where foo is a (mutex_t) while they handle (foo) where
139  * foo is a (mutex_t*) */
140 typedef struct
141 {
142     spin_lock_t held;
143     spin_lock_t lock;
144     char *name;
145     struct cthread_queue queue;
146 } vlc_mutex_t;
147
148 typedef struct
149 {
150     spin_lock_t lock;
151     struct cthread_queue queue;
152     char *name;
153     struct cond_imp *implications;
154 } vlc_cond_t;
155
156 #elif defined( HAVE_KERNEL_SCHEDULER_H )
157 /* This is the BeOS implementation of the vlc threads, note that the mutex is
158  * not a real mutex and the cond_var is not like a pthread cond_var but it is
159  * enough for what wee need */
160
161 typedef thread_id vlc_thread_t;
162
163 typedef struct
164 {
165     int32           init;
166     sem_id          lock;
167 } vlc_mutex_t;
168
169 typedef struct
170 {
171     int32           init;
172     thread_id       thread;
173 } vlc_cond_t;
174
175 #endif
176
177 /*****************************************************************************
178  * Function definitions
179  *****************************************************************************/
180 VLC_EXPORT( int,  __vlc_threads_init,  ( vlc_object_t * ) );
181 VLC_EXPORT( int,  __vlc_threads_end,   ( vlc_object_t * ) );
182 VLC_EXPORT( int,  __vlc_mutex_init,    ( vlc_object_t *, vlc_mutex_t * ) );
183 VLC_EXPORT( int,  __vlc_mutex_destroy, ( char *, int, vlc_mutex_t * ) );
184 VLC_EXPORT( int,  __vlc_cond_init,     ( vlc_object_t *, vlc_cond_t * ) );
185 VLC_EXPORT( int,  __vlc_cond_destroy,  ( char *, int, vlc_cond_t * ) );
186 VLC_EXPORT( int,  __vlc_thread_create, ( vlc_object_t *, char *, int, char *, void * ( * ) ( void * ), vlc_bool_t ) );
187 VLC_EXPORT( void, __vlc_thread_ready,  ( vlc_object_t * ) );
188 VLC_EXPORT( void, __vlc_thread_join,   ( vlc_object_t *, char *, int ) );
189
190 /*****************************************************************************
191  * vlc_threads_init: initialize threads system
192  *****************************************************************************/
193 #define vlc_threads_init( P_THIS )                                          \
194     __vlc_threads_init( CAST_TO_VLC_OBJECT(P_THIS) )
195
196 /*****************************************************************************
197  * vlc_threads_end: deinitialize threads system
198  *****************************************************************************/
199 #define vlc_threads_end( P_THIS )                                          \
200     __vlc_threads_end( CAST_TO_VLC_OBJECT(P_THIS) )
201
202 /*****************************************************************************
203  * vlc_mutex_init: initialize a mutex
204  *****************************************************************************/
205 #define vlc_mutex_init( P_THIS, P_MUTEX )                                   \
206     __vlc_mutex_init( CAST_TO_VLC_OBJECT(P_THIS), P_MUTEX )
207
208 /*****************************************************************************
209  * vlc_mutex_lock: lock a mutex
210  *****************************************************************************/
211 #ifdef DEBUG
212 #   define vlc_mutex_lock( P_MUTEX )                                        \
213         __vlc_mutex_lock( __FILE__, __LINE__, P_MUTEX )
214 #else
215 #   define vlc_mutex_lock( P_MUTEX )                                        \
216         __vlc_mutex_lock( "(unknown)", 0, P_MUTEX )
217 #endif
218
219 static inline int __vlc_mutex_lock( char * psz_file, int i_line,
220                                     vlc_mutex_t *p_mutex )
221 {
222 #if defined( PTH_INIT_IN_PTH_H )
223     return pth_mutex_acquire( p_mutex, TRUE, NULL );
224
225 #elif defined( ST_INIT_IN_ST_H )
226     return st_mutex_lock( *p_mutex );
227
228 #elif defined( WIN32 )
229     if( p_mutex->mutex )
230     {
231         WaitForSingleObject( p_mutex->mutex, INFINITE );
232     }
233     else
234     {
235         EnterCriticalSection( &p_mutex->csection );
236     }
237     return 0;
238
239 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
240     int i_return = pthread_mutex_lock( p_mutex );
241     if( i_return )
242     {
243 //        msg_Err( "thread %d: mutex_lock failed at %s:%d (%s)",
244 //                 pthread_self(), psz_file, i_line, strerror(i_return) );
245     }
246     return i_return;
247
248 #elif defined( HAVE_CTHREADS_H )
249     mutex_lock( p_mutex );
250     return 0;
251
252 #elif defined( HAVE_KERNEL_SCHEDULER_H )
253     status_t err;
254
255     if( !p_mutex )
256     {
257         return B_BAD_VALUE;
258     }
259
260     if( p_mutex->init < 2000 )
261     {
262         return B_NO_INIT;
263     }
264
265     err = acquire_sem( p_mutex->lock );
266     return err;
267
268 #endif
269 }
270
271 /*****************************************************************************
272  * vlc_mutex_unlock: unlock a mutex
273  *****************************************************************************/
274 #ifdef DEBUG
275 #   define vlc_mutex_unlock( P_MUTEX )                                      \
276         __vlc_mutex_unlock( __FILE__, __LINE__, P_MUTEX )
277 #else
278 #   define vlc_mutex_unlock( P_MUTEX )                                      \
279         __vlc_mutex_unlock( "(unknown)", 0, P_MUTEX )
280 #endif
281
282 static inline int __vlc_mutex_unlock( char * psz_file, int i_line,
283                                       vlc_mutex_t *p_mutex )
284 {
285 #if defined( PTH_INIT_IN_PTH_H )
286     return pth_mutex_release( p_mutex );
287
288 #elif defined( ST_INIT_IN_ST_H )
289     return st_mutex_unlock( *p_mutex );
290
291 #elif defined( WIN32 )
292     if( p_mutex->mutex )
293     {
294         ReleaseMutex( p_mutex->mutex );
295     }
296     else
297     {
298         LeaveCriticalSection( &p_mutex->csection );
299     }
300     return 0;
301
302 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
303     int i_return = pthread_mutex_unlock( p_mutex );
304     if( i_return )
305     {
306 //        msg_Err( "thread %d: mutex_unlock failed at %s:%d (%s)",
307 //                 pthread_self(), psz_file, i_line, strerror(i_return) );
308     }
309     return i_return;
310
311 #elif defined( HAVE_CTHREADS_H )
312     mutex_unlock( p_mutex );
313     return 0;
314
315 #elif defined( HAVE_KERNEL_SCHEDULER_H )
316     if( !p_mutex)
317     {
318         return B_BAD_VALUE;
319     }
320
321     if( p_mutex->init < 2000 )
322     {
323         return B_NO_INIT;
324     }
325
326     release_sem( p_mutex->lock );
327     return B_OK;
328
329 #endif
330 }
331
332 /*****************************************************************************
333  * vlc_mutex_destroy: destroy a mutex
334  *****************************************************************************/
335 #ifdef DEBUG
336 #   define vlc_mutex_destroy( P_MUTEX )                                     \
337         __vlc_mutex_destroy( __FILE__, __LINE__, P_MUTEX )
338 #else
339 #   define vlc_mutex_destroy( P_MUTEX )                                     \
340         __vlc_mutex_destroy( "(unknown)", 0, P_MUTEX )
341 #endif
342
343 /*****************************************************************************
344  * vlc_cond_init: initialize a condition
345  *****************************************************************************/
346 #define vlc_cond_init( P_THIS, P_COND )                                   \
347     __vlc_cond_init( CAST_TO_VLC_OBJECT(P_THIS), P_COND )
348
349 /*****************************************************************************
350  * vlc_cond_signal: start a thread on condition completion
351  *****************************************************************************/
352 static inline int vlc_cond_signal( vlc_cond_t *p_condvar )
353 {
354 #if defined( PTH_INIT_IN_PTH_H )
355     return pth_cond_notify( p_condvar, FALSE );
356
357 #elif defined( ST_INIT_IN_ST_H )
358     return st_cond_signal( *p_condvar );
359
360 #elif defined( WIN32 )
361     /* Release one waiting thread if one is available. */
362     /* For this trick to work properly, the vlc_cond_signal must be surrounded
363      * by a mutex. This will prevent another thread from stealing the signal */
364     if( p_condvar->i_waiting_threads )
365     {
366         if( p_condvar->signal )
367         {
368             ReleaseSemaphore( p_condvar->semaphore, 1, 0 );
369         }
370         else
371         {
372             SetEvent( p_condvar->p_events[0/*signal*/] );
373         }
374     }
375     return 0;
376
377 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
378     return pthread_cond_signal( p_condvar );
379
380 #elif defined( HAVE_CTHREADS_H )
381     /* condition_signal() */
382     if ( p_condvar->queue.head || p_condvar->implications )
383     {
384         cond_signal( (condition_t)p_condvar );
385     }
386     return 0;
387
388 #elif defined( HAVE_KERNEL_SCHEDULER_H )
389     if( !p_condvar )
390     {
391         return B_BAD_VALUE;
392     }
393
394     if( p_condvar->init < 2000 )
395     {
396         return B_NO_INIT;
397     }
398
399     while( p_condvar->thread != -1 )
400     {
401         thread_info info;
402         if( get_thread_info(p_condvar->thread, &info) == B_BAD_VALUE )
403         {
404             return 0;
405         }
406
407         if( info.state != B_THREAD_SUSPENDED )
408         {
409             /* The  waiting thread is not suspended so it could
410              * have been interrupted beetwen the unlock and the
411              * suspend_thread line. That is why we sleep a little
412              * before retesting p_condver->thread. */
413             snooze( 10000 );
414         }
415         else
416         {
417             /* Ok, we have to wake up that thread */
418             resume_thread( p_condvar->thread );
419             return 0;
420         }
421     }
422     return 0;
423
424 #endif
425 }
426
427 /*****************************************************************************
428  * vlc_cond_broadcast: start all threads waiting on condition completion
429  *****************************************************************************/
430 /*
431  * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
432  * Only works with pthreads, you need to adapt it for others
433  * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
434  */
435 static inline int vlc_cond_broadcast( vlc_cond_t *p_condvar )
436 {
437 #if defined( PTH_INIT_IN_PTH_H )
438     return pth_cond_notify( p_condvar, FALSE );
439
440 #elif defined( ST_INIT_IN_ST_H )
441     return st_cond_broadcast( p_condvar );
442
443 #elif defined( WIN32 )
444     /* Release all waiting threads. */
445     if( p_condvar->i_waiting_threads )
446     {
447         if( p_condvar->signal )
448         {
449             p_condvar->b_broadcast = 1;
450             /* This call is atomic */
451             ReleaseSemaphore( p_condvar->semaphore,
452                               p_condvar->i_waiting_threads, 0 );
453             /* Wait for all threads to get the semaphore */
454             WaitForSingleObject( p_condvar->signal, INFINITE );
455             p_condvar->b_broadcast = 0;
456         }
457         else
458         {
459             SetEvent( p_condvar->p_events[1/*broadcast*/] );
460         }
461     }
462     return 0;
463
464 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
465     return pthread_cond_broadcast( p_condvar );
466
467 #elif defined( HAVE_CTHREADS_H )
468     /* condition_signal() */
469     if ( p_condvar->queue.head || p_condvar->implications )
470     {
471         cond_signal( (condition_t)p_condvar );
472     }
473     return 0;
474
475 #elif defined( HAVE_KERNEL_SCHEDULER_H )
476     if( !p_condvar )
477     {
478         return B_BAD_VALUE;
479     }
480
481     if( p_condvar->init < 2000 )
482     {
483         return B_NO_INIT;
484     }
485
486     while( p_condvar->thread != -1 )
487     {
488         thread_info info;
489         if( get_thread_info(p_condvar->thread, &info) == B_BAD_VALUE )
490         {
491             return 0;
492         }
493
494         if( info.state != B_THREAD_SUSPENDED )
495         {
496             /* The  waiting thread is not suspended so it could
497              * have been interrupted beetwen the unlock and the
498              * suspend_thread line. That is why we sleep a little
499              * before retesting p_condver->thread. */
500             snooze( 10000 );
501         }
502         else
503         {
504             /* Ok, we have to wake up that thread */
505             resume_thread( p_condvar->thread );
506             return 0;
507         }
508     }
509     return 0;
510
511 #endif
512 }
513
514 /*****************************************************************************
515  * vlc_cond_wait: wait until condition completion
516  *****************************************************************************/
517 #ifdef DEBUG
518 #   define vlc_cond_wait( P_COND, P_MUTEX )                                   \
519         __vlc_cond_wait( __FILE__, __LINE__, P_COND, P_MUTEX  )
520 #else
521 #   define vlc_cond_wait( P_COND, P_MUTEX )                                   \
522         __vlc_cond_wait( "(unknown)", 0, P_COND, P_MUTEX )
523 #endif
524
525 static inline int __vlc_cond_wait( char * psz_file, int i_line,
526                                    vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex )
527 {
528 #if defined( PTH_INIT_IN_PTH_H )
529     return pth_cond_await( p_condvar, p_mutex, NULL );
530
531 #elif defined( ST_INIT_IN_ST_H )
532     int i_ret;
533
534     st_mutex_unlock( *p_mutex );
535     i_ret = st_cond_wait( *p_condvar );
536     st_mutex_lock( *p_mutex );
537
538     return i_ret;
539
540 #elif defined( WIN32 )
541     /* Increase our wait count */
542     p_condvar->i_waiting_threads++;
543
544     if( p_condvar->signal )
545     {
546         /* It is only possible to atomically release the mutex and initiate the
547          * waiting on WinNT/2K/XP. Win9x doesn't have SignalObjectAndWait(). */
548         p_condvar->SignalObjectAndWait( p_mutex->mutex, p_condvar->semaphore,
549                                         INFINITE, FALSE );
550         /* XXX: we should protect i_waiting_threads with a mutex, but
551          * is it really worth it ? */
552         p_condvar->i_waiting_threads--;
553
554         if( p_condvar->b_broadcast
555              && p_condvar->i_waiting_threads == 0 )
556         {
557             p_condvar->SignalObjectAndWait( p_condvar->signal, p_mutex->mutex,
558                                             INFINITE, FALSE );
559         }
560         else
561         {
562             /* Just take back the lock */
563             WaitForSingleObject( p_mutex->mutex, INFINITE );
564         }
565         return 0;
566     }
567     else
568     {
569         int i_ret;
570
571         /* Release the mutex, wait, and reacquire. */
572         LeaveCriticalSection( &p_mutex->csection );
573         i_ret = WaitForMultipleObjects( 2, p_condvar->p_events,
574                                         FALSE, INFINITE );
575         EnterCriticalSection( &p_mutex->csection );
576
577         /* Decrease our wait count */
578         p_condvar->i_waiting_threads--;
579
580         /* If we are the last waiter and it was a broadcast signal, reset
581          * the broadcast event. */
582         if( i_ret == WAIT_OBJECT_0 + 1/*broadcast*/
583              && p_condvar->i_waiting_threads == 0 )
584         {
585             ResetEvent( p_condvar->p_events[1/*broadcast*/] );
586         }
587
588         return( i_ret == WAIT_FAILED );
589     }
590
591 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
592
593 #   ifdef DEBUG
594     /* In debug mode, timeout */
595     struct timeval now;
596     struct timespec timeout;
597     int    i_result;
598
599     for( ; ; )
600     {
601         gettimeofday( &now, NULL );
602         timeout.tv_sec = now.tv_sec + THREAD_COND_TIMEOUT;
603         timeout.tv_nsec = now.tv_usec * 1000;
604
605         i_result = pthread_cond_timedwait( p_condvar, p_mutex, &timeout );
606
607         if( i_result == ETIMEDOUT )
608         {
609 //X            msg_Warn( "thread %d: possible deadlock detected "
610 //X                      "in cond_wait at %s:%d (%s)", pthread_self(),
611 //X                      psz_file, i_line, strerror(i_result) );
612             continue;
613         }
614
615         if( i_result )
616         {
617 //X            msg_Err( "thread %d: cond_wait failed at %s:%d (%s)",
618 //X                     pthread_self(), psz_file, i_line, strerror(i_result) );
619         }
620         return( i_result );
621     }
622 #   else
623     return pthread_cond_wait( p_condvar, p_mutex );
624 #   endif
625
626 #elif defined( HAVE_CTHREADS_H )
627     condition_wait( (condition_t)p_condvar, (mutex_t)p_mutex );
628     return 0;
629
630 #elif defined( HAVE_KERNEL_SCHEDULER_H )
631     if( !p_condvar )
632     {
633         return B_BAD_VALUE;
634     }
635
636     if( !p_mutex )
637     {
638         return B_BAD_VALUE;
639     }
640
641     if( p_condvar->init < 2000 )
642     {
643         return B_NO_INIT;
644     }
645
646     /* The p_condvar->thread var is initialized before the unlock because
647      * it enables to identify when the thread is interrupted beetwen the
648      * unlock line and the suspend_thread line */
649     p_condvar->thread = find_thread( NULL );
650     vlc_mutex_unlock( p_mutex );
651     suspend_thread( p_condvar->thread );
652     p_condvar->thread = -1;
653
654     vlc_mutex_lock( p_mutex );
655     return 0;
656
657 #endif
658 }
659
660 /*****************************************************************************
661  * vlc_cond_destroy: destroy a condition
662  *****************************************************************************/
663 #ifdef DEBUG
664 #   define vlc_cond_destroy( P_COND )                                       \
665         __vlc_cond_destroy( __FILE__, __LINE__, P_COND )
666 #else
667 #   define vlc_cond_destroy( P_COND )                                       \
668         __vlc_cond_destroy( "(unknown)", 0, P_COND )
669 #endif
670
671 /*****************************************************************************
672  * vlc_thread_create: create a thread
673  *****************************************************************************/
674 #   define vlc_thread_create( P_THIS, PSZ_NAME, FUNC, WAIT )                \
675         __vlc_thread_create( CAST_TO_VLC_OBJECT(P_THIS), __FILE__, __LINE__, PSZ_NAME, (void * ( * ) ( void * ))FUNC, WAIT )
676
677 /*****************************************************************************
678  * vlc_thread_ready: tell the parent thread we were successfully spawned
679  *****************************************************************************/
680 #   define vlc_thread_ready( P_THIS )                                       \
681         __vlc_thread_ready( CAST_TO_VLC_OBJECT(P_THIS) )
682
683 /*****************************************************************************
684  * vlc_thread_join: wait until a thread exits
685  *****************************************************************************/
686 #ifdef DEBUG
687 #   define vlc_thread_join( P_THIS )                                        \
688         __vlc_thread_join( CAST_TO_VLC_OBJECT(P_THIS), __FILE__, __LINE__ ) 
689 #else
690 #   define vlc_thread_join( P_THIS )                                        \
691         __vlc_thread_join( CAST_TO_VLC_OBJECT(P_THIS), "(unknown)", 0 ) 
692 #endif