Commit dd4f2531 authored by Sam Hocevar's avatar Sam Hocevar

* ./src/misc/darwin_specific.c, ./src/misc/extras.c: moved our custom

    strndup to a separate file so that Win32 can benefit from it.
  * ./include/vlc_threads.h: Borland compilation fix.
parent 4565dc6e
......@@ -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) \
......
......@@ -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
......
......@@ -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,
......
......@@ -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 );
......@@ -142,6 +142,9 @@
/* 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
......
......@@ -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
......
......@@ -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 );
......
......@@ -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 );
}
/*****************************************************************************
* 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 */
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment