strndup to a separate file so that Win32 can benefit from it.
* ./include/vlc_threads.h: Borland compilation fix.
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) \
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
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,
* 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>
*
* Prototypes
*****************************************************************************/
char * system_GetProgramPath( void );
-extern char *strndup( const char *string, size_t n );
/* 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
* 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>
#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
* 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>
vlc_bool_t b_broadcast;
SIGNALOBJECTANDWAIT SignalObjectAndWait;
/* Win95/98/ME implementation */
- enum { SIGNAL = 0, BROADCAST = 1 };
HANDLE p_events[2];
} vlc_cond_t;
}
else
{
- SetEvent( p_condvar->p_events[SIGNAL] );
+ SetEvent( p_condvar->p_events[0/*signal*/] );
}
}
return 0;
}
else
{
- SetEvent( p_condvar->p_events[BROADCAST] );
+ SetEvent( p_condvar->p_events[1/*broadcast*/] );
}
}
return 0;
/* 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 );
* 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>
*
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 );
-}
--- /dev/null
+/*****************************************************************************
+ * 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 */
* 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>
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 )
}
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 )