]> git.sesse.net Git - vlc/commitdiff
* ./src/misc/darwin_specific.c, ./src/misc/extras.c: moved our custom
authorSam Hocevar <sam@videolan.org>
Fri, 5 Jul 2002 11:18:56 +0000 (11:18 +0000)
committerSam Hocevar <sam@videolan.org>
Fri, 5 Jul 2002 11:18:56 +0000 (11:18 +0000)
    strndup to a separate file so that Win32 can benefit from it.
  * ./include/vlc_threads.h: Borland compilation fix.

Makefile
configure
configure.in
include/darwin_specific.h
include/defs.h.in
include/vlc_common.h
include/vlc_threads.h
src/misc/darwin_specific.c
src/misc/extras.c [new file with mode: 0644]
src/misc/threads.c

index b71005637b7bc31ff269934d9ce4f7c21d0b106a..5f8046a2659e66c11f91a79b4a771123e9809e42 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -172,7 +172,7 @@ PLAYLIST := playlist
 INPUT := input input_ext-plugins input_ext-dec input_ext-intf input_dec input_programs input_clock mpeg_system
 VIDEO_OUTPUT := video_output video_text vout_pictures vout_subpictures
 AUDIO_OUTPUT := audio_output aout_ext-dec aout_pcm aout_spdif
-MISC := mtime modules threads cpu configuration netutils iso_lang messages objects
+MISC := mtime modules threads cpu configuration netutils iso_lang messages objects extras
 
 LIBVLC_OBJ :=  $(LIBVLC:%=src/%.o) \
                $(INTERFACE:%=src/interface/%.o) \
index 307fcc6e122b4f0b77fbc95c0c976467325f785b..c552d1c0653e82145a9809ac67fcef474272216a 100755 (executable)
--- a/configure
+++ b/configure
@@ -3298,7 +3298,7 @@ fi
 
 save_CFLAGS="${save_CFLAGS} -DSYS_`echo ${SYS} | sed -e 's/-.*//' | tr 'abcdefghijklmnopqrstuvwxyz.' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`"
 
-for ac_func in gettimeofday select strerror strtod strtol isatty vasprintf swab sigrelse getpwuid memalign posix_memalign gethostbyname2 atoll
+for ac_func in gettimeofday select strerror strtod strtol isatty vasprintf swab sigrelse getpwuid memalign posix_memalign gethostbyname2 atoll strndup
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
 echo "configure:3305: checking for $ac_func" >&5
index 150ecf72f77c6cde3a08a7d77fba8b8cdaeee304..6b028026288079ab893b0f4e660eb1dcff7364e4 100644 (file)
@@ -126,7 +126,7 @@ dnl The -DSYS_FOO flag
 save_CFLAGS="${save_CFLAGS} -DSYS_`echo ${SYS} | sed -e 's/-.*//' | tr 'abcdefghijklmnopqrstuvwxyz.' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`"
 
 dnl Check for system libs needed
-AC_CHECK_FUNCS(gettimeofday select strerror strtod strtol isatty vasprintf swab sigrelse getpwuid memalign posix_memalign gethostbyname2 atoll)
+AC_CHECK_FUNCS(gettimeofday select strerror strtod strtol isatty vasprintf swab sigrelse getpwuid memalign posix_memalign gethostbyname2 atoll strndup)
 
 AC_CHECK_FUNC(connect,,[
   AC_CHECK_LIB(socket,connect,
index 6a30db29836850ec08004f45328d8abe9585388c..2f6bef3d74fef1abbe1799a5433151f4aef1edb0 100644 (file)
@@ -2,7 +2,7 @@
  * darwin_specific.h: Darwin specific features 
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: darwin_specific.h,v 1.4 2002/07/02 22:07:02 jlj Exp $
+ * $Id: darwin_specific.h,v 1.5 2002/07/05 11:18:56 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -25,4 +25,3 @@
  * Prototypes
  *****************************************************************************/
 char  * system_GetProgramPath( void );
-extern char *strndup( const char *string, size_t n );
index 6f60c4f16d591addf0906abb0f3e58c5f0de2c8a..75aa9d39b8902c6a23cfb4928225ef2017338264 100644 (file)
 /* Define if you have the strerror function.  */
 #undef HAVE_STRERROR
 
+/* Define if you have the strndup function.  */
+#undef HAVE_STRNDUP
+
 /* Define if you have the strtod function.  */
 #undef HAVE_STRTOD
 
index 065b99f4261d056bb037b0556cec18b37e80ba06..bca56c9e60b2684e2cdcfa9d189733bc79dce185 100644 (file)
@@ -3,7 +3,7 @@
  * Collection of useful common types and macros definitions
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: vlc_common.h,v 1.7 2002/06/07 23:53:44 sam Exp $
+ * $Id: vlc_common.h,v 1.8 2002/07/05 11:18:56 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@via.ecp.fr>
  *          Vincent Seguin <seguin@via.ecp.fr>
@@ -436,6 +436,11 @@ struct vlc_object_s
 
 #endif
 
+/* strndup (defined in src/misc/extras.c) */
+#ifndef HAVE_STRNDUP
+char * strndup( const char *s, size_t n );
+#endif
+
 
 #define I64C(x)         x##LL
 
index 90e18ea38c44e047fe0475a5a59e8242dd600e23..bf017f4720a9f95c82d383c2f27433c8bef1eb2f 100644 (file)
@@ -3,7 +3,7 @@
  * This header provides a portable threads implementation.
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: vlc_threads.h,v 1.3 2002/06/08 14:08:46 sam Exp $
+ * $Id: vlc_threads.h,v 1.4 2002/07/05 11:18:56 sam Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@via.ecp.fr>
@@ -123,7 +123,6 @@ typedef struct
     vlc_bool_t          b_broadcast;
     SIGNALOBJECTANDWAIT SignalObjectAndWait;
     /* Win95/98/ME implementation */
-    enum                { SIGNAL = 0, BROADCAST = 1 };
     HANDLE              p_events[2];
 } vlc_cond_t;
 
@@ -364,7 +363,7 @@ static inline int vlc_cond_signal( vlc_cond_t *p_condvar )
         }
         else
         {
-            SetEvent( p_condvar->p_events[SIGNAL] );
+            SetEvent( p_condvar->p_events[0/*signal*/] );
         }
     }
     return 0;
@@ -451,7 +450,7 @@ static inline int vlc_cond_broadcast( vlc_cond_t *p_condvar )
         }
         else
         {
-            SetEvent( p_condvar->p_events[BROADCAST] );
+            SetEvent( p_condvar->p_events[1/*broadcast*/] );
         }
     }
     return 0;
@@ -574,10 +573,10 @@ static inline int __vlc_cond_wait( char * psz_file, int i_line,
 
         /* If we are the last waiter and it was a broadcast signal, reset
          * the broadcast event. */
-        if( i_ret == WAIT_OBJECT_0 + BROADCAST
+        if( i_ret == WAIT_OBJECT_0 + 1/*broadcast*/
              && p_condvar->i_waiting_threads == 0 )
         {
-            ResetEvent( p_condvar->p_events[BROADCAST] );
+            ResetEvent( p_condvar->p_events[1/*broadcast*/] );
         }
 
         return( i_ret == WAIT_FAILED );
index baf214a77eaedad4b168b853e1576f95ca33eadf..24b3f2ea63c1865aba113a1d834a3fdec66954b9 100644 (file)
@@ -2,7 +2,7 @@
  * darwin_specific.c: Darwin specific features 
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: darwin_specific.c,v 1.13 2002/07/02 22:07:02 jlj Exp $
+ * $Id: darwin_specific.c,v 1.14 2002/07/05 11:18:56 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -89,23 +89,3 @@ char * system_GetProgramPath( void )
     return( psz_program_path );
 }
 
-/*****************************************************************************
- * strndup: returns a malloc'd copy of at most n bytes of string 
- * Does anyone know whether or not it will be present in Jaguar?
- *****************************************************************************/
-char *strndup( const char *string, size_t n )
-{
-    char *psz;
-    size_t len;
-
-    len = __MIN( strlen( string ), n ); 
-    psz = (char*)malloc( len + 1 );
-
-    if( psz != NULL )
-    {
-        memcpy( (void*)psz, (const void*)string, len );
-        psz[ len ] = 0;
-    }
-
-    return( psz );
-}
diff --git a/src/misc/extras.c b/src/misc/extras.c
new file mode 100644 (file)
index 0000000..0ce94c2
--- /dev/null
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * extras.c: Extra libc functions for some systems.
+ *****************************************************************************
+ * Copyright (C) 2002 VideoLAN
+ * $Id: extras.c,v 1.1 2002/07/05 11:18:56 sam Exp $
+ *
+ * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+#include <string.h>                                              /* strdup() */
+#include <stdlib.h>
+
+#include <vlc/vlc.h>
+
+#ifndef HAVE_STRNDUP
+/*****************************************************************************
+ * strndup: returns a malloc'd copy of at most n bytes of string 
+ * Does anyone know whether or not it will be present in Jaguar?
+ *****************************************************************************/
+char *strndup( const char *string, size_t n )
+{
+    char *psz;
+    size_t len;
+
+    len = __MIN( strlen( string ), n ); 
+    psz = (char*)malloc( len + 1 );
+
+    if( psz != NULL )
+    {
+        memcpy( (void*)psz, (const void*)string, len );
+        psz[ len ] = 0;
+    }
+
+    return( psz );
+}
+#endif /* HAVE_STRNDUP */
index 5bacf2dbfc8db80c12b41031ffd3f3b9cda55e40..d6583653189d9be5526ae29c4aa39ce9494475d4 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.7 2002/06/08 14:08:46 sam Exp $
+ * $Id: threads.c,v 1.8 2002/07/05 11:18:56 sam Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -308,10 +308,10 @@ int __vlc_cond_init( vlc_object_t *p_this, vlc_cond_t *p_condvar )
         p_condvar->signal = NULL;
 
         /* Create an auto-reset event and a manual-reset event. */
-        p_condvar->p_events[SIGNAL] = CreateEvent( NULL, FALSE, FALSE, NULL );
-        p_condvar->p_events[BROADCAST] = CreateEvent( NULL, TRUE, FALSE, NULL );
+        p_condvar->p_events[0] = CreateEvent( NULL, FALSE, FALSE, NULL );
+        p_condvar->p_events[1] = CreateEvent( NULL, TRUE, FALSE, NULL );
 
-        return !p_condvar->p_events[SIGNAL] || !p_condvar->p_events[BROADCAST];
+        return !p_condvar->p_events[0] || !p_condvar->p_events[1];
     }
 
 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
@@ -363,8 +363,8 @@ int __vlc_cond_destroy( char * psz_file, int i_line, vlc_cond_t *p_condvar )
     }
     else
     {
-        return !CloseHandle( p_condvar->p_events[SIGNAL] )
-                 || !CloseHandle( p_condvar->p_events[BROADCAST] );
+        return !CloseHandle( p_condvar->p_events[0] )
+                 || !CloseHandle( p_condvar->p_events[1] );
     }
 
 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )