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 ...@@ -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 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 VIDEO_OUTPUT := video_output video_text vout_pictures vout_subpictures
AUDIO_OUTPUT := audio_output aout_ext-dec aout_pcm aout_spdif 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) \ LIBVLC_OBJ := $(LIBVLC:%=src/%.o) \
$(INTERFACE:%=src/interface/%.o) \ $(INTERFACE:%=src/interface/%.o) \
......
...@@ -3298,7 +3298,7 @@ fi ...@@ -3298,7 +3298,7 @@ fi
save_CFLAGS="${save_CFLAGS} -DSYS_`echo ${SYS} | sed -e 's/-.*//' | tr 'abcdefghijklmnopqrstuvwxyz.' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`" 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 do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:3305: checking for $ac_func" >&5 echo "configure:3305: checking for $ac_func" >&5
......
...@@ -126,7 +126,7 @@ dnl The -DSYS_FOO flag ...@@ -126,7 +126,7 @@ dnl The -DSYS_FOO flag
save_CFLAGS="${save_CFLAGS} -DSYS_`echo ${SYS} | sed -e 's/-.*//' | tr 'abcdefghijklmnopqrstuvwxyz.' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`" save_CFLAGS="${save_CFLAGS} -DSYS_`echo ${SYS} | sed -e 's/-.*//' | tr 'abcdefghijklmnopqrstuvwxyz.' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`"
dnl Check for system libs needed 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_FUNC(connect,,[
AC_CHECK_LIB(socket,connect, AC_CHECK_LIB(socket,connect,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* darwin_specific.h: Darwin specific features * darwin_specific.h: Darwin specific features
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -25,4 +25,3 @@ ...@@ -25,4 +25,3 @@
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
char * system_GetProgramPath( void ); char * system_GetProgramPath( void );
extern char *strndup( const char *string, size_t n );
...@@ -142,6 +142,9 @@ ...@@ -142,6 +142,9 @@
/* Define if you have the strerror function. */ /* Define if you have the strerror function. */
#undef HAVE_STRERROR #undef HAVE_STRERROR
/* Define if you have the strndup function. */
#undef HAVE_STRNDUP
/* Define if you have the strtod function. */ /* Define if you have the strtod function. */
#undef HAVE_STRTOD #undef HAVE_STRTOD
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions * Collection of useful common types and macros definitions
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * 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> * Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -436,6 +436,11 @@ struct vlc_object_s ...@@ -436,6 +436,11 @@ struct vlc_object_s
#endif #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 #define I64C(x) x##LL
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* This header provides a portable threads implementation. * This header provides a portable threads implementation.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * 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> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
...@@ -123,7 +123,6 @@ typedef struct ...@@ -123,7 +123,6 @@ typedef struct
vlc_bool_t b_broadcast; vlc_bool_t b_broadcast;
SIGNALOBJECTANDWAIT SignalObjectAndWait; SIGNALOBJECTANDWAIT SignalObjectAndWait;
/* Win95/98/ME implementation */ /* Win95/98/ME implementation */
enum { SIGNAL = 0, BROADCAST = 1 };
HANDLE p_events[2]; HANDLE p_events[2];
} vlc_cond_t; } vlc_cond_t;
...@@ -364,7 +363,7 @@ static inline int vlc_cond_signal( vlc_cond_t *p_condvar ) ...@@ -364,7 +363,7 @@ static inline int vlc_cond_signal( vlc_cond_t *p_condvar )
} }
else else
{ {
SetEvent( p_condvar->p_events[SIGNAL] ); SetEvent( p_condvar->p_events[0/*signal*/] );
} }
} }
return 0; return 0;
...@@ -451,7 +450,7 @@ static inline int vlc_cond_broadcast( vlc_cond_t *p_condvar ) ...@@ -451,7 +450,7 @@ static inline int vlc_cond_broadcast( vlc_cond_t *p_condvar )
} }
else else
{ {
SetEvent( p_condvar->p_events[BROADCAST] ); SetEvent( p_condvar->p_events[1/*broadcast*/] );
} }
} }
return 0; return 0;
...@@ -574,10 +573,10 @@ static inline int __vlc_cond_wait( char * psz_file, int i_line, ...@@ -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 /* If we are the last waiter and it was a broadcast signal, reset
* the broadcast event. */ * the broadcast event. */
if( i_ret == WAIT_OBJECT_0 + BROADCAST if( i_ret == WAIT_OBJECT_0 + 1/*broadcast*/
&& p_condvar->i_waiting_threads == 0 ) && p_condvar->i_waiting_threads == 0 )
{ {
ResetEvent( p_condvar->p_events[BROADCAST] ); ResetEvent( p_condvar->p_events[1/*broadcast*/] );
} }
return( i_ret == WAIT_FAILED ); return( i_ret == WAIT_FAILED );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* darwin_specific.c: Darwin specific features * darwin_specific.c: Darwin specific features
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -89,23 +89,3 @@ char * system_GetProgramPath( void ) ...@@ -89,23 +89,3 @@ char * system_GetProgramPath( void )
return( psz_program_path ); 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 @@ ...@@ -2,7 +2,7 @@
* threads.c : threads implementation for the VideoLAN client * threads.c : threads implementation for the VideoLAN client
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN * 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> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -308,10 +308,10 @@ int __vlc_cond_init( vlc_object_t *p_this, vlc_cond_t *p_condvar ) ...@@ -308,10 +308,10 @@ int __vlc_cond_init( vlc_object_t *p_this, vlc_cond_t *p_condvar )
p_condvar->signal = NULL; p_condvar->signal = NULL;
/* Create an auto-reset event and a manual-reset event. */ /* Create an auto-reset event and a manual-reset event. */
p_condvar->p_events[SIGNAL] = CreateEvent( NULL, FALSE, FALSE, NULL ); p_condvar->p_events[0] = CreateEvent( NULL, FALSE, FALSE, NULL );
p_condvar->p_events[BROADCAST] = CreateEvent( NULL, TRUE, 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 ) #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 ) ...@@ -363,8 +363,8 @@ int __vlc_cond_destroy( char * psz_file, int i_line, vlc_cond_t *p_condvar )
} }
else else
{ {
return !CloseHandle( p_condvar->p_events[SIGNAL] ) return !CloseHandle( p_condvar->p_events[0] )
|| !CloseHandle( p_condvar->p_events[BROADCAST] ); || !CloseHandle( p_condvar->p_events[1] );
} }
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) #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