]> git.sesse.net Git - vlc/blob - include/vlc_threads_funcs.h
Fix the most common strerror() usages (threads, network, input) - refs #1297
[vlc] / include / vlc_threads_funcs.h
1 /*****************************************************************************
2  * vlc_threads_funcs.h : threads implementation for the VideoLAN client
3  * This header provides a portable threads implementation.
4  *****************************************************************************
5  * Copyright (C) 1999-2007 the VideoLAN team
6  * $Id$
7  *
8  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
9  *          Samuel Hocevar <sam@via.ecp.fr>
10  *          Gildas Bazin <gbazin@netcourrier.com>
11  *          Christophe Massiot <massiot@via.ecp.fr>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26  *****************************************************************************/
27
28 #if !defined( __LIBVLC__ )
29   #error You are not libvlc or one of its plugins. You cannot include this file
30 #endif
31
32 #ifndef _VLC_THREADFUNCS_H_
33 #define _VLC_THREADFUNCS_H_
34
35 /*****************************************************************************
36  * Function definitions
37  *****************************************************************************/
38 VLC_EXPORT( int,  __vlc_mutex_init,    ( vlc_object_t *, vlc_mutex_t * ) );
39 VLC_EXPORT( int,  __vlc_mutex_destroy, ( const char *, int, vlc_mutex_t * ) );
40 VLC_EXPORT( int,  __vlc_cond_init,     ( vlc_object_t *, vlc_cond_t * ) );
41 VLC_EXPORT( int,  __vlc_cond_destroy,  ( const char *, int, vlc_cond_t * ) );
42 VLC_EXPORT( int, __vlc_threadvar_create, (vlc_object_t *, vlc_threadvar_t * ) );
43 VLC_EXPORT( int,  __vlc_thread_create, ( vlc_object_t *, const char *, int, const char *, void * ( * ) ( void * ), int, vlc_bool_t ) );
44 VLC_EXPORT( int,  __vlc_thread_set_priority, ( vlc_object_t *, const char *, int, int ) );
45 VLC_EXPORT( void, __vlc_thread_ready,  ( vlc_object_t * ) );
46 VLC_EXPORT( void, __vlc_thread_join,   ( vlc_object_t *, const char *, int ) );
47
48 /*****************************************************************************
49  * vlc_threads_init: initialize threads system
50  *****************************************************************************/
51 #define vlc_threads_init( P_THIS )                                          \
52     __vlc_threads_init( VLC_OBJECT(P_THIS) )
53
54 /*****************************************************************************
55  * vlc_threads_end: deinitialize threads system
56  *****************************************************************************/
57 #define vlc_threads_end( P_THIS )                                           \
58     __vlc_threads_end( VLC_OBJECT(P_THIS) )
59
60 /*****************************************************************************
61  * vlc_mutex_init: initialize a mutex
62  *****************************************************************************/
63 #define vlc_mutex_init( P_THIS, P_MUTEX )                                   \
64     __vlc_mutex_init( VLC_OBJECT(P_THIS), P_MUTEX )
65
66 /*****************************************************************************
67  * vlc_mutex_lock: lock a mutex
68  *****************************************************************************/
69 #define vlc_mutex_lock( P_MUTEX )                                           \
70     __vlc_mutex_lock( __FILE__, __LINE__, P_MUTEX )
71
72 #ifdef __APPLE__
73 #   define CAST_PTHREAD_TO_INT(t) (unsigned long int)(uintptr_t)(void *)t
74 #else
75 #   define CAST_PTHREAD_TO_INT(t) (unsigned long int)t
76 #endif
77
78 static inline int __vlc_mutex_lock( const char * psz_file, int i_line,
79                                     vlc_mutex_t * p_mutex )
80 {
81     int i_result;
82     /* In case of error : */
83     unsigned long int i_thread = 0;
84
85 #if defined( PTH_INIT_IN_PTH_H )
86     i_result = ( pth_mutex_acquire( &p_mutex->mutex, FALSE, NULL ) == FALSE );
87
88 #elif defined( ST_INIT_IN_ST_H )
89     i_result = st_mutex_lock( p_mutex->mutex );
90
91 #elif defined( UNDER_CE )
92     EnterCriticalSection( &p_mutex->csection );
93     i_result = 0;
94
95 #elif defined( WIN32 )
96     if( p_mutex->mutex )
97     {
98         WaitForSingleObject( p_mutex->mutex, INFINITE );
99     }
100     else
101     {
102         EnterCriticalSection( &p_mutex->csection );
103     }
104     i_result = 0;
105
106 #elif defined( HAVE_KERNEL_SCHEDULER_H )
107     if( p_mutex == NULL )
108     {
109         i_result = B_BAD_VALUE;
110     }
111     else if( p_mutex->init < 2000 )
112     {
113         i_result = B_NO_INIT;
114     }
115     else
116     {
117         i_result = acquire_sem( p_mutex->lock );
118     }
119
120 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
121 #   define vlc_assert_locked( m ) \
122            assert (pthread_mutex_lock (&((m)->mutex)) == EDEADLK)
123
124     i_result = pthread_mutex_lock( &p_mutex->mutex );
125     if ( i_result )
126     {
127         i_thread = CAST_PTHREAD_TO_INT(pthread_self());
128         errno = i_result;
129     }
130
131 #elif defined( HAVE_CTHREADS_H )
132     mutex_lock( p_mutex->mutex );
133     i_result = 0;
134
135 #endif
136
137     if( i_result )
138     {
139         msg_Err( p_mutex->p_this,
140                  "thread %li: mutex_lock failed at %s:%d (%d:%m)",
141                  i_thread, psz_file, i_line, i_result );
142     }
143     return i_result;
144 }
145
146 #ifndef vlc_assert_locked
147 # define vlc_assert_locked( m ) (void)0
148 #endif
149
150 /*****************************************************************************
151  * vlc_mutex_unlock: unlock a mutex
152  *****************************************************************************/
153 #define vlc_mutex_unlock( P_MUTEX )                                         \
154     __vlc_mutex_unlock( __FILE__, __LINE__, P_MUTEX )
155
156 static inline int __vlc_mutex_unlock( const char * psz_file, int i_line,
157                                       vlc_mutex_t *p_mutex )
158 {
159     int i_result;
160     /* In case of error : */
161     unsigned long int i_thread = 0;
162
163 #if defined( PTH_INIT_IN_PTH_H )
164     i_result = ( pth_mutex_release( &p_mutex->mutex ) == FALSE );
165
166 #elif defined( ST_INIT_IN_ST_H )
167     i_result = st_mutex_unlock( p_mutex->mutex );
168
169 #elif defined( UNDER_CE )
170     LeaveCriticalSection( &p_mutex->csection );
171     i_result = 0;
172
173 #elif defined( WIN32 )
174     if( p_mutex->mutex )
175     {
176         ReleaseMutex( p_mutex->mutex );
177     }
178     else
179     {
180         LeaveCriticalSection( &p_mutex->csection );
181     }
182     i_result = 0;
183
184 #elif defined( HAVE_KERNEL_SCHEDULER_H )
185     if( p_mutex == NULL )
186     {
187         i_result = B_BAD_VALUE;
188     }
189     else if( p_mutex->init < 2000 )
190     {
191         i_result = B_NO_INIT;
192     }
193     else
194     {
195         release_sem( p_mutex->lock );
196         return B_OK;
197     }
198
199 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
200     i_result = pthread_mutex_unlock( &p_mutex->mutex );
201     if ( i_result )
202     {
203         i_thread = CAST_PTHREAD_TO_INT(pthread_self());
204         errno = i_result;
205     }
206
207 #elif defined( HAVE_CTHREADS_H )
208     mutex_unlock( p_mutex );
209     i_result = 0;
210
211 #endif
212
213     if( i_result )
214     {
215         msg_Err( p_mutex->p_this,
216                  "thread %li: mutex_unlock failed at %s:%d (%d:%m)",
217                  i_thread, psz_file, i_line, i_result );
218     }
219
220     return i_result;
221 }
222
223 /*****************************************************************************
224  * vlc_mutex_destroy: destroy a mutex
225  *****************************************************************************/
226 #define vlc_mutex_destroy( P_MUTEX )                                        \
227     __vlc_mutex_destroy( __FILE__, __LINE__, P_MUTEX )
228
229 /*****************************************************************************
230  * vlc_cond_init: initialize a condition
231  *****************************************************************************/
232 #define vlc_cond_init( P_THIS, P_COND )                                     \
233     __vlc_cond_init( VLC_OBJECT(P_THIS), P_COND )
234
235 /*****************************************************************************
236  * vlc_cond_signal: start a thread on condition completion
237  *****************************************************************************/
238 #define vlc_cond_signal( P_COND )                                           \
239     __vlc_cond_signal( __FILE__, __LINE__, P_COND )
240
241 static inline int __vlc_cond_signal( const char * psz_file, int i_line,
242                                      vlc_cond_t *p_condvar )
243 {
244     int i_result;
245     /* In case of error : */
246     unsigned long int i_thread = 0;
247
248 #if defined( PTH_INIT_IN_PTH_H )
249     i_result = ( pth_cond_notify( &p_condvar->cond, FALSE ) == FALSE );
250
251 #elif defined( ST_INIT_IN_ST_H )
252     i_result = st_cond_signal( p_condvar->cond );
253
254 #elif defined( UNDER_CE )
255     PulseEvent( p_condvar->event );
256     i_result = 0;
257
258 #elif defined( WIN32 )
259     /* Release one waiting thread if one is available. */
260     /* For this trick to work properly, the vlc_cond_signal must be surrounded
261      * by a mutex. This will prevent another thread from stealing the signal */
262     if( !p_condvar->semaphore )
263     {
264         PulseEvent( p_condvar->event );
265     }
266     else if( p_condvar->i_win9x_cv == 1 )
267     {
268         /* Wait for the gate to be open */
269         WaitForSingleObject( p_condvar->event, INFINITE );
270
271         if( p_condvar->i_waiting_threads )
272         {
273             /* Using a semaphore exposes us to a race condition. It is
274              * possible for another thread to start waiting on the semaphore
275              * just after we signaled it and thus steal the signal.
276              * We have to prevent new threads from entering the cond_wait(). */
277             ResetEvent( p_condvar->event );
278
279             /* A semaphore is used here because Win9x doesn't have
280              * SignalObjectAndWait() and thus a race condition exists
281              * during the time we release the mutex and the time we start
282              * waiting on the event (more precisely, the signal can sometimes
283              * be missed by the waiting thread if we use PulseEvent()). */
284             ReleaseSemaphore( p_condvar->semaphore, 1, 0 );
285         }
286     }
287     else
288     {
289         if( p_condvar->i_waiting_threads )
290         {
291             ReleaseSemaphore( p_condvar->semaphore, 1, 0 );
292
293             /* Wait for the last thread to be awakened */
294             WaitForSingleObject( p_condvar->event, INFINITE );
295         }
296     }
297     i_result = 0;
298
299 #elif defined( HAVE_KERNEL_SCHEDULER_H )
300     if( p_condvar == NULL )
301     {
302         i_result = B_BAD_VALUE;
303     }
304     else if( p_condvar->init < 2000 )
305     {
306         i_result = B_NO_INIT;
307     }
308     else
309     {
310         while( p_condvar->thread != -1 )
311         {
312             thread_info info;
313             if( get_thread_info(p_condvar->thread, &info) == B_BAD_VALUE )
314             {
315                 return 0;
316             }
317
318             if( info.state != B_THREAD_SUSPENDED )
319             {
320                 /* The  waiting thread is not suspended so it could
321                  * have been interrupted beetwen the unlock and the
322                  * suspend_thread line. That is why we sleep a little
323                  * before retesting p_condver->thread. */
324                 snooze( 10000 );
325             }
326             else
327             {
328                 /* Ok, we have to wake up that thread */
329                 resume_thread( p_condvar->thread );
330                 return 0;
331             }
332         }
333         i_result = 0;
334     }
335
336 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
337     i_result = pthread_cond_signal( &p_condvar->cond );
338     if ( i_result )
339     {
340         i_thread = CAST_PTHREAD_TO_INT(pthread_self());
341         errno = i_result;
342     }
343
344 #elif defined( HAVE_CTHREADS_H )
345     /* condition_signal() */
346     if ( p_condvar->queue.head || p_condvar->implications )
347     {
348         cond_signal( (condition_t)p_condvar );
349     }
350     i_result = 0;
351
352 #endif
353
354     if( i_result )
355     {
356         msg_Err( p_condvar->p_this,
357                  "thread %li: cond_signal failed at %s:%d (%d:%m)",
358                  i_thread, psz_file, i_line, i_result );
359     }
360
361     return i_result;
362 }
363
364 /*****************************************************************************
365  * vlc_cond_wait: wait until condition completion
366  *****************************************************************************/
367 #define vlc_cond_wait( P_COND, P_MUTEX )                                     \
368     __vlc_cond_wait( __FILE__, __LINE__, P_COND, P_MUTEX  )
369
370 static inline int __vlc_cond_wait( const char * psz_file, int i_line,
371                                    vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex )
372 {
373     int i_result;
374     /* In case of error : */
375     unsigned long int i_thread = 0;
376
377 #if defined( PTH_INIT_IN_PTH_H )
378     i_result = ( pth_cond_await( &p_condvar->cond, &p_mutex->mutex, NULL )
379                  == FALSE );
380
381 #elif defined( ST_INIT_IN_ST_H )
382     st_mutex_unlock( p_mutex->mutex );
383     i_result = st_cond_wait( p_condvar->cond );
384     st_mutex_lock( p_mutex->mutex );
385
386 #elif defined( UNDER_CE )
387     p_condvar->i_waiting_threads++;
388     LeaveCriticalSection( &p_mutex->csection );
389     WaitForSingleObject( p_condvar->event, INFINITE );
390     p_condvar->i_waiting_threads--;
391
392     /* Reacquire the mutex before returning. */
393     vlc_mutex_lock( p_mutex );
394
395     i_result = 0;
396
397 #elif defined( WIN32 )
398     if( !p_condvar->semaphore )
399     {
400         /* Increase our wait count */
401         p_condvar->i_waiting_threads++;
402
403         if( p_mutex->mutex )
404         {
405             /* It is only possible to atomically release the mutex and
406              * initiate the waiting on WinNT/2K/XP. Win9x doesn't have
407              * SignalObjectAndWait(). */
408             p_condvar->SignalObjectAndWait( p_mutex->mutex,
409                                             p_condvar->event,
410                                             INFINITE, FALSE );
411         }
412         else
413         {
414             LeaveCriticalSection( &p_mutex->csection );
415             WaitForSingleObject( p_condvar->event, INFINITE );
416         }
417
418         p_condvar->i_waiting_threads--;
419     }
420     else if( p_condvar->i_win9x_cv == 1 )
421     {
422         int i_waiting_threads;
423
424         /* Wait for the gate to be open */
425         WaitForSingleObject( p_condvar->event, INFINITE );
426
427         /* Increase our wait count */
428         p_condvar->i_waiting_threads++;
429
430         LeaveCriticalSection( &p_mutex->csection );
431         WaitForSingleObject( p_condvar->semaphore, INFINITE );
432
433         /* Decrement and test must be atomic */
434         EnterCriticalSection( &p_condvar->csection );
435
436         /* Decrease our wait count */
437         i_waiting_threads = --p_condvar->i_waiting_threads;
438
439         LeaveCriticalSection( &p_condvar->csection );
440
441         /* Reopen the gate if we were the last waiting thread */
442         if( !i_waiting_threads )
443             SetEvent( p_condvar->event );
444     }
445     else
446     {
447         int i_waiting_threads;
448
449         /* Increase our wait count */
450         p_condvar->i_waiting_threads++;
451
452         LeaveCriticalSection( &p_mutex->csection );
453         WaitForSingleObject( p_condvar->semaphore, INFINITE );
454
455         /* Decrement and test must be atomic */
456         EnterCriticalSection( &p_condvar->csection );
457
458         /* Decrease our wait count */
459         i_waiting_threads = --p_condvar->i_waiting_threads;
460
461         LeaveCriticalSection( &p_condvar->csection );
462
463         /* Signal that the last waiting thread just went through */
464         if( !i_waiting_threads )
465             SetEvent( p_condvar->event );
466     }
467
468     /* Reacquire the mutex before returning. */
469     vlc_mutex_lock( p_mutex );
470
471     i_result = 0;
472
473 #elif defined( HAVE_KERNEL_SCHEDULER_H )
474     if( p_condvar == NULL )
475     {
476         i_result = B_BAD_VALUE;
477     }
478     else if( p_mutex == NULL )
479     {
480         i_result = B_BAD_VALUE;
481     }
482     else if( p_condvar->init < 2000 )
483     {
484         i_result = B_NO_INIT;
485     }
486
487     /* The p_condvar->thread var is initialized before the unlock because
488      * it enables to identify when the thread is interrupted beetwen the
489      * unlock line and the suspend_thread line */
490     p_condvar->thread = find_thread( NULL );
491     vlc_mutex_unlock( p_mutex );
492     suspend_thread( p_condvar->thread );
493     p_condvar->thread = -1;
494
495     vlc_mutex_lock( p_mutex );
496     i_result = 0;
497
498 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
499
500 #   ifdef DEBUG
501     /* In debug mode, timeout */
502     struct timespec timeout = {
503         (mdate() / 1000000) + THREAD_COND_TIMEOUT,
504         0 /* 1Hz precision is sufficient here :-) */
505     };
506
507     i_result = pthread_cond_timedwait( &p_condvar->cond, &p_mutex->mutex,
508                                        &timeout );
509
510     if( i_result == ETIMEDOUT )
511     {
512         errno = ETIMEDOUT;
513         msg_Dbg( p_condvar->p_this,
514                   "thread %li: possible condition deadlock "
515                   "at %s:%d (%m)", CAST_PTHREAD_TO_INT(pthread_self()),
516                   psz_file, i_line );
517
518         i_result = pthread_cond_wait( &p_condvar->cond, &p_mutex->mutex );
519     }
520
521 #   else
522     i_result = pthread_cond_wait( &p_condvar->cond, &p_mutex->mutex );
523 #   endif
524
525     if ( i_result )
526     {
527         i_thread = CAST_PTHREAD_TO_INT(pthread_self());
528         errno = i_result;
529     }
530
531 #elif defined( HAVE_CTHREADS_H )
532     condition_wait( (condition_t)p_condvar, (mutex_t)p_mutex );
533     i_result = 0;
534
535 #endif
536
537     if( i_result )
538     {
539         msg_Err( p_condvar->p_this,
540                  "thread %li: cond_wait failed at %s:%d (%d:%m)",
541                  i_thread, psz_file, i_line, i_result );
542     }
543
544     return i_result;
545 }
546
547
548 /*****************************************************************************
549  * vlc_cond_timedwait: wait until condition completion or expiration
550  *****************************************************************************
551  * Returns 0 if object signaled, an error code in case of timeout or error.
552  *****************************************************************************/
553 #define vlc_cond_timedwait( P_COND, P_MUTEX, DEADLINE )                      \
554     __vlc_cond_timedwait( __FILE__, __LINE__, P_COND, P_MUTEX, DEADLINE  )
555
556 static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
557                                         vlc_cond_t *p_condvar,
558                                         vlc_mutex_t *p_mutex,
559                                         mtime_t deadline )
560 {
561     int i_res;
562     unsigned long int i_thread = 0;
563
564 #if defined( PTH_INIT_IN_PTH_H )
565 #   error Unimplemented
566 #elif defined( ST_INIT_IN_ST_H )
567 #   error Unimplemented
568 #elif defined( UNDER_CE )
569 #   error Unimplemented
570 #elif defined( WIN32 )
571     abort();
572 #   warning Unimplemented FIXME FIXME
573
574 #elif defined( HAVE_KERNEL_SCHEDULER_H )
575 #   error Unimplemented
576 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
577     lldiv_t d = lldiv( deadline, 1000000 );
578     struct timespec ts = { d.quot, d.rem * 1000 };
579
580     i_res = pthread_cond_timedwait( &p_condvar->cond, &p_mutex->mutex, &ts );
581     if( i_res == ETIMEDOUT )
582         return ETIMEDOUT; /* this error is perfectly normal */
583     else
584     if ( i_res ) /* other errors = bug */
585     {
586         i_thread = CAST_PTHREAD_TO_INT(pthread_self());
587         errno = i_res;
588     }
589
590 #elif defined( HAVE_CTHREADS_H )
591 #   error Unimplemented
592 #endif
593
594     if( i_res )
595     {
596         msg_Err( p_condvar->p_this,
597                  "thread %li: cond_wait failed at %s:%d (%d:%m)",
598                  i_thread, psz_file, i_line, i_res );
599     }
600
601     return i_res;
602 }
603
604 /*****************************************************************************
605  * vlc_cond_destroy: destroy a condition
606  *****************************************************************************/
607 #define vlc_cond_destroy( P_COND )                                          \
608     __vlc_cond_destroy( __FILE__, __LINE__, P_COND )
609
610 /*****************************************************************************
611  * vlc_threadvar_create: create a thread-local variable
612  *****************************************************************************/
613 #define vlc_threadvar_create( PTHIS, P_TLS )                                 \
614    __vlc_threadvar_create( PTHIS, P_TLS )
615
616 /*****************************************************************************
617  * vlc_threadvar_set: create: set the value of a thread-local variable
618  *****************************************************************************/
619 static inline int vlc_threadvar_set( vlc_threadvar_t * p_tls, void *p_value )
620 {
621     int i_ret;
622
623 #if defined( PTH_INIT_IN_PTH_H )
624     return pth_key_setdata( p_tls->handle, p_value );
625 #elif  defined( ST_INIT_IN_ST_H )
626     return st_thread_setspecific( p_tls->handle, p_value );
627 #elif defined( HAVE_KERNEL_SCHEDULER_H )
628     return -1;
629
630 #elif defined( UNDER_CE ) || defined( WIN32 )
631     i_ret = ( TlsSetValue( p_tls->handle, p_value ) != 0 );
632
633 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
634     i_ret = pthread_setspecific( p_tls->handle, p_value );
635
636 #elif defined( HAVE_CTHREADS_H )
637     i_ret = cthread_setspecific( p_tls->handle, p_value );
638 #endif
639
640     return i_ret;
641 }
642
643 /*****************************************************************************
644  * vlc_threadvar_get: create: get the value of a thread-local variable
645  *****************************************************************************/
646 static inline void* vlc_threadvar_get( vlc_threadvar_t * p_tls )
647 {
648     void* p_ret;
649
650 #if defined( PTH_INIT_IN_PTH_H )
651     p_ret = pth_key_getdata( p_handle->key );
652 #elif defined( ST_INIT_IN_ST_H )
653     p_ret = st_thread_getspecific( p_handle->key );
654 #elif defined( HAVE_KERNEL_SCHEDULER_H )
655     p_ret = NULL;
656 #elif defined( UNDER_CE ) || defined( WIN32 )
657     p_ret = TlsGetValue( p_tls->handle );
658
659 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
660     p_ret = pthread_getspecific( p_tls->handle );
661
662 #elif defined( HAVE_CTHREADS_H )
663     if ( !cthread_getspecific( p_tls->handle, &p_ret ) )
664     {
665         p_ret = NULL;
666     }
667 #endif
668
669     return p_ret;
670 }
671
672 /*****************************************************************************
673  * vlc_thread_create: create a thread
674  *****************************************************************************/
675 #define vlc_thread_create( P_THIS, PSZ_NAME, FUNC, PRIORITY, WAIT )         \
676     __vlc_thread_create( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PSZ_NAME, (void * ( * ) ( void * ))FUNC, PRIORITY, WAIT )
677
678 /*****************************************************************************
679  * vlc_thread_set_priority: set the priority of the calling thread
680  *****************************************************************************/
681 #define vlc_thread_set_priority( P_THIS, PRIORITY )                         \
682     __vlc_thread_set_priority( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PRIORITY )
683
684 /*****************************************************************************
685  * vlc_thread_ready: tell the parent thread we were successfully spawned
686  *****************************************************************************/
687 #define vlc_thread_ready( P_THIS )                                          \
688     __vlc_thread_ready( VLC_OBJECT(P_THIS) )
689
690 /*****************************************************************************
691  * vlc_thread_join: wait until a thread exits
692  *****************************************************************************/
693 #define vlc_thread_join( P_THIS )                                           \
694     __vlc_thread_join( VLC_OBJECT(P_THIS), __FILE__, __LINE__ )
695
696 #endif