]> git.sesse.net Git - vlc/commitdiff
* src/misc/threads.c, include/vlc_threads.h: Removed the pthread wrapper for
authorSam Hocevar <sam@videolan.org>
Thu, 28 Aug 2003 17:19:42 +0000 (17:19 +0000)
committerSam Hocevar <sam@videolan.org>
Thu, 28 Aug 2003 17:19:42 +0000 (17:19 +0000)
  gprof. If you still want to profile pthread applications using gprof please
  see http://sam.zoy.org/writings/programming/gprof.html and also consider
  using oprofile if you are using ia32.

include/vlc_threads.h
src/misc/threads.c

index 657f057e3674b532721a3244d58e6a10a5708ddf..4bcabb18544102bfa6c88003b0bdd2e0e1dd5925 100644 (file)
@@ -3,7 +3,7 @@
  * This header provides portable declarations for mutexes & conditions
  *****************************************************************************
  * Copyright (C) 1999, 2002 VideoLAN
- * $Id: vlc_threads.h,v 1.32 2003/06/14 00:49:58 titer Exp $
+ * $Id: vlc_threads.h,v 1.33 2003/08/28 17:19:42 sam Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@via.ecp.fr>
 
 #include <stdio.h>
 
-#if defined(GPROF) || defined(DEBUG)
-#   ifdef HAVE_SYS_TIME_H
-#       include <sys/time.h>
-#   endif
+#if defined(DEBUG) && defined(HAVE_SYS_TIME_H)
+#   include <sys/time.h>
 #endif
 
 #if defined( PTH_INIT_IN_PTH_H )                                  /* GNU Pth */
index 61964d1ef46a5788efda5491bc186f33d4e94f7c..a9e39701cf6cc51dffedb955c4d28d92ea35340d 100644 (file)
@@ -2,7 +2,7 @@
  * threads.c : threads implementation for the VideoLAN client
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
- * $Id: threads.c,v 1.40 2003/03/10 00:04:14 massiot Exp $
+ * $Id: threads.c,v 1.41 2003/08/28 17:19:41 sam Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -212,46 +212,6 @@ int __vlc_threads_end( vlc_object_t *p_this )
     return VLC_SUCCESS;
 }
 
-/*****************************************************************************
- * Prototype for GPROF wrapper
- *****************************************************************************/
-#ifdef GPROF
-typedef void *(*vlc_thread_func_t)(void *p_data);
-
-/* Wrapper function for profiling */
-static void *      vlc_thread_wrapper ( void *p_wrapper );
-
-#   if defined( WIN32 ) && !defined( UNDER_CE )
-
-#       define ITIMER_REAL 1
-#       define ITIMER_PROF 2
-
-struct itimerval
-{
-    struct timeval it_value;
-    struct timeval it_interval;
-};
-
-int setitimer(int kind, const struct itimerval* itnew, struct itimerval* itold);
-#   endif /* WIN32 && !UNDER_CE */
-
-typedef struct wrapper_t
-{
-    /* Data lock access */
-    vlc_mutex_t lock;
-    vlc_cond_t  wait;
-
-    /* Data used to spawn the real thread */
-    vlc_thread_func_t func;
-    void *p_data;
-
-    /* Profiling timer passed to the thread */
-    struct itimerval itimer;
-
-} wrapper_t;
-
-#endif /* GPROF */
-
 /*****************************************************************************
  * vlc_mutex_init: initialize a mutex
  *****************************************************************************/
@@ -549,29 +509,10 @@ int __vlc_thread_create( vlc_object_t *p_this, char * psz_file, int i_line,
                          int i_priority, vlc_bool_t b_wait )
 {
     int i_ret;
-    void *p_data;
+    void *p_data = (void *)p_this;
 
     vlc_mutex_lock( &p_this->object_lock );
 
-#ifdef GPROF
-    wrapper_t wrapper;
-
-    /* Initialize the wrapper structure */
-    wrapper.func = func;
-    wrapper.p_data = (void *)p_this;
-    getitimer( ITIMER_PROF, &wrapper.itimer );
-    vlc_mutex_init( p_this, &wrapper.lock );
-    vlc_cond_init( p_this, &wrapper.wait );
-    vlc_mutex_lock( &wrapper.lock );
-
-    /* Alter user-passed data so that we call the wrapper instead
-     * of the real function */
-    p_data = &wrapper;
-    func = vlc_thread_wrapper;
-#else
-    p_data = (void *)p_this;
-#endif
-
 #if defined( PTH_INIT_IN_PTH_H )
     p_this->thread_id = pth_spawn( PTH_ATTR_DEFAULT, func, p_data );
     i_ret = p_this->thread_id == NULL;
@@ -648,17 +589,6 @@ int __vlc_thread_create( vlc_object_t *p_this, char * psz_file, int i_line,
 
 #endif
 
-#ifdef GPROF
-    if( i_ret == 0 )
-    {
-        vlc_cond_wait( &wrapper.wait, &wrapper.lock );
-    }
-
-    vlc_mutex_unlock( &wrapper.lock );
-    vlc_mutex_destroy( &wrapper.lock );
-    vlc_cond_destroy( &wrapper.wait );
-#endif
-
     if( i_ret == 0 )
     {
         if( b_wait )
@@ -800,25 +730,3 @@ void __vlc_thread_join( vlc_object_t *p_this, char * psz_file, int i_line )
     p_this->b_thread = 0;
 }
 
-/*****************************************************************************
- * vlc_thread_wrapper: wrapper around thread functions used when profiling.
- *****************************************************************************/
-#ifdef GPROF
-static void *vlc_thread_wrapper( void *p_wrapper )
-{
-    /* Put user data in thread-local variables */
-    void *            p_data = ((wrapper_t*)p_wrapper)->p_data;
-    vlc_thread_func_t func   = ((wrapper_t*)p_wrapper)->func;
-
-    /* Set the profile timer value */
-    setitimer( ITIMER_PROF, &((wrapper_t*)p_wrapper)->itimer, NULL );
-
-    /* Tell the calling thread that we don't need its data anymore */
-    vlc_mutex_lock( &((wrapper_t*)p_wrapper)->lock );
-    vlc_cond_signal( &((wrapper_t*)p_wrapper)->wait );
-    vlc_mutex_unlock( &((wrapper_t*)p_wrapper)->lock );
-
-    /* Call the real function */
-    return func( p_data );
-}
-#endif