From: Sam Hocevar Date: Fri, 3 Mar 2000 00:59:56 +0000 (+0000) Subject: . portage des vlc_threads aux cthreads de Mach pour GNU/Hurd X-Git-Tag: 0.1.99e~78 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=7a0afd69fd2574bf075be9ed566f547dd93efd37;p=vlc . portage des vlc_threads aux cthreads de Mach pour GNU/Hurd . rajout de #ifdef SYS_LINUX autour du code concernant les interfaces . suppression de quelques #include qui trainaient encore . option PPRO dans le Makefile (si vous avez des erreurs 'Illegal instruction', �a venait probablement de l�) . rajout de quelques commentaires pour expliquer en quoi certains #include sont n�cessaires, aux endroits o� je ne comprenais pas, et suppression de #include qui semblaient inutiles. --- diff --git a/Makefile b/Makefile index 2d6205b131..7b6b985c04 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,9 @@ SHELL=/bin/sh # Audio output settings AUDIO = dsp -# Not yet supported #AUDIO += esd +# Not yet supported +#AUDIO += alsa # Fallback method that should always work AUDIO += dummy @@ -38,12 +39,17 @@ ARCH=X86 # Target operating system SYS=LINUX +#SYS=GNU #SYS=BSD #SYS=BEOS # For x86 architecture, choose MMX support MMX=YES #MMX=NO +# For x86 architecture, optimize for Pentium Pro +# (choose NO if you get `Invalid instruction' errors) +PPRO=YES +#PPRO=NO # Decoder choice - ?? old decoder will be removed soon #DECODER=old @@ -124,8 +130,14 @@ CCFLAGS += -fomit-frame-pointer # Optimizations for x86 familiy ifeq ($(ARCH),X86) CCFLAGS += -malign-double -CCFLAGS += -march=pentiumpro #CCFLAGS += -march=pentium +ifeq ($(PPRO), YES) +CCFLAGS += -march=pentiumpro +endif +# Eventual MMX optimizations for x86 +ifeq ($(MMX), YES) +CFLAGS += -DHAVE_MMX +endif endif # Optimizations for PowerPC @@ -151,17 +163,6 @@ LCFLAGS += $(LIB) LCFLAGS += -Wall #LCFLAGS += -s -# -# C compiler flags: common flags -# - -# Eventual MMX optimizations for x86 -ifeq ($(ARCH),X86) -ifeq ($(MMX), YES) -CFLAGS += -DHAVE_MMX -endif -endif - # # Additionnal debugging flags # @@ -285,9 +286,7 @@ interface_plugin = $(video:%=interface/intf_%.so) audio_plugin = $(audio:%=audio_output/aout_%.so) video_plugin = $(video:%=video_output/vout_%.so) -PLUGIN_OBJ = $(interface_plugin) \ - $(audio_plugin) \ - $(video_plugin) \ +PLUGIN_OBJ = $(interface_plugin) $(audio_plugin) $(video_plugin) # # Other lists of files @@ -351,8 +350,7 @@ $(PLUGIN_OBJ): %.so: Makefile.dep $(PLUGIN_OBJ): %.so: dep/%.d # audio plugins -audio_output/aout_dummy.so \ - audio_output/aout_dsp.so: %.so: %.c +audio_output/aout_dummy.so audio_output/aout_dsp.so: %.so: %.c @echo "compiling $*.so from $*.c" @$(CC) $(CCFLAGS) $(CFLAGS) -shared -o $@ $< @@ -361,25 +359,20 @@ audio_output/aout_esd.so: %.so: %.c @$(CC) $(CCFLAGS) $(CFLAGS) -laudiofile -lesd -shared -o $@ $< # video plugins -interface/intf_dummy.so \ - video_output/vout_dummy.so \ - interface/intf_fb.so \ - video_output/vout_fb.so: %.so: %.c +interface/intf_dummy.so video_output/vout_dummy.so \ + interface/intf_fb.so video_output/vout_fb.so: %.so: %.c @echo "compiling $*.so from $*.c" @$(CC) $(CCFLAGS) $(CFLAGS) -shared -o $@ $< -interface/intf_x11.so \ - video_output/vout_x11.so: %.so: %.c +interface/intf_x11.so video_output/vout_x11.so: %.so: %.c @echo "compiling $*.so from $*.c" @$(CC) $(CCFLAGS) $(CFLAGS) -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXext -shared -o $@ $< -interface/intf_glide.so \ - video_output/vout_glide.so: %.so: %.c +interface/intf_glide.so video_output/vout_glide.so: %.so: %.c @echo "compiling $*.so from $*.c" @$(CC) $(CCFLAGS) $(CFLAGS) -I/usr/include/glide -lglide2x -shared -o $@ $< -interface/intf_ggi.so \ - video_output/vout_ggi.so: %.so: %.c +interface/intf_ggi.so video_output/vout_ggi.so: %.so: %.c @echo "compiling $*.so from $*.c" @$(CC) $(CCFLAGS) $(CFLAGS) -lggi -shared -o $@ $< diff --git a/include/common.h b/include/common.h index fb4cb9b2ff..af734ad62f 100644 --- a/include/common.h +++ b/include/common.h @@ -18,6 +18,9 @@ typedef u8 byte_t; /* Boolean type */ typedef int boolean_t; +#ifdef SYS_GNU +#define _MACH_I386_BOOLEAN_H_ +#endif /* Counter for statistics and profiling */ typedef unsigned long count_t; diff --git a/include/vlc_thread.h b/include/vlc_thread.h index 57c9e0d8b5..8b6abaa513 100644 --- a/include/vlc_thread.h +++ b/include/vlc_thread.h @@ -3,9 +3,14 @@ * (c)1999 VideoLAN ***************************************************************************** * This header is supposed to provide a portable threads implementation. - * Currently, it is a wrapper to the POSIX pthreads library. + * Currently, it is a wrapper to either the POSIX pthreads library, or + * the Mach cthreads (for the GNU/Hurd). *****************************************************************************/ +#ifdef SYS_GNU +#include +#else #include +#endif /***************************************************************************** * Constants @@ -36,10 +41,35 @@ /***************************************************************************** * Types definition *****************************************************************************/ + +#ifdef SYS_GNU + +typedef cthread_t vlc_thread_t; + +/* those structs are the ones defined in /include/cthreads.h but we need + * * to handle *foo where foo is a mutex_t */ +typedef struct s_mutex { + spin_lock_t held; + spin_lock_t lock; + char *name; + struct cthread_queue queue; +} vlc_mutex_t; + +typedef struct s_condition { + spin_lock_t lock; + struct cthread_queue queue; + char *name; + struct cond_imp *implications; +} vlc_cond_t; + +#else /* SYS_GNU */ + typedef pthread_t vlc_thread_t; typedef pthread_mutex_t vlc_mutex_t; typedef pthread_cond_t vlc_cond_t; +#endif /* SYS_GNU */ + typedef void *(*vlc_thread_func_t)(void *p_data); /***************************************************************************** @@ -71,7 +101,12 @@ static __inline__ int vlc_thread_create( vlc_thread_t *p_thread, char *psz_name, vlc_thread_func_t func, void *p_data) { +#ifdef SYS_GNU + *p_thread = cthread_fork( (cthread_fn_t)func, (any_t)p_data ); + return( 0 ); +#else return pthread_create( p_thread, NULL, func, p_data ); +#endif } /***************************************************************************** @@ -79,7 +114,12 @@ static __inline__ int vlc_thread_create( vlc_thread_t *p_thread, *****************************************************************************/ static __inline__ void vlc_thread_exit( void ) { +#ifdef SYS_GNU + int result; + cthread_exit( &result ); +#else pthread_exit( 0 ); +#endif } /***************************************************************************** @@ -87,7 +127,11 @@ static __inline__ void vlc_thread_exit( void ) *****************************************************************************/ static __inline__ void vlc_thread_join( vlc_thread_t thread ) { +#ifdef SYS_GNU + cthread_join( thread ); +#else pthread_join( thread, NULL ); +#endif } /***************************************************************************** @@ -95,7 +139,12 @@ static __inline__ void vlc_thread_join( vlc_thread_t thread ) *****************************************************************************/ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex ) { +#ifdef SYS_GNU + mutex_init( p_mutex ); + return( 0 ); +#else return pthread_mutex_init( p_mutex, NULL ); +#endif } /***************************************************************************** @@ -103,7 +152,12 @@ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex ) *****************************************************************************/ static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex ) { +#ifdef SYS_GNU + mutex_lock( p_mutex ); + return( 0 ); +#else return pthread_mutex_lock( p_mutex ); +#endif } /***************************************************************************** @@ -111,7 +165,12 @@ static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex ) *****************************************************************************/ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex ) { +#ifdef SYS_GNU + mutex_unlock( p_mutex ); + return( 0 ); +#else return pthread_mutex_unlock( p_mutex ); +#endif } /***************************************************************************** @@ -119,7 +178,17 @@ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex ) *****************************************************************************/ static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar ) { +#ifdef SYS_GNU + /* condition_init() */ + spin_lock_init( &p_condvar->lock ); + cthread_queue_init( &p_condvar->queue ); + p_condvar->name = 0; + p_condvar->implications = 0; + + return( 0 ); +#else return pthread_cond_init( p_condvar, NULL ); +#endif } /***************************************************************************** @@ -127,7 +196,16 @@ static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar ) *****************************************************************************/ static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar ) { +#ifdef SYS_GNU + /* condition_signal() */ + if ( p_condvar->queue.head || p_condvar->implications ) + { + cond_signal( (condition_t)p_condvar ); + } + return( 0 ); +#else return pthread_cond_signal( p_condvar ); +#endif } /***************************************************************************** @@ -135,5 +213,11 @@ static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar ) *****************************************************************************/ static __inline__ int vlc_cond_wait( vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex ) { +#ifdef SYS_GNU + condition_wait( (condition_t)p_condvar, (mutex_t)p_mutex ); + return( 0 ); +#else return pthread_cond_wait( p_condvar, p_mutex ); +#endif } + diff --git a/src/ac3_decoder/ac3_decoder_thread.c b/src/ac3_decoder/ac3_decoder_thread.c index 52b0646f56..c2d6ff65d7 100644 --- a/src/ac3_decoder/ac3_decoder_thread.c +++ b/src/ac3_decoder/ac3_decoder_thread.c @@ -23,7 +23,6 @@ #include /* "intf_msg.h" */ #include /* malloc(), free() */ -#include /* "audio_output.h" */ #include /* "input.h" */ #include "common.h" diff --git a/src/audio_decoder/audio_decoder.c b/src/audio_decoder/audio_decoder.c index b6f1b60b83..acaf230e96 100644 --- a/src/audio_decoder/audio_decoder.c +++ b/src/audio_decoder/audio_decoder.c @@ -21,7 +21,6 @@ #include #include #include /* ntohl() */ -#include /* "audio_output.h" */ #include /* "input.h" */ #include "common.h" diff --git a/src/audio_decoder/audio_math.c b/src/audio_decoder/audio_math.c index 9f17a71216..02185a7ff3 100644 --- a/src/audio_decoder/audio_math.c +++ b/src/audio_decoder/audio_math.c @@ -11,7 +11,6 @@ #include #include #include /* ntohl() */ -#include /* "audio_output.h" */ #include #include "config.h" diff --git a/src/input/input.c b/src/input/input.c index 588995729e..8a67dea45e 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -9,15 +9,12 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include -#include +#include /* errno */ +#include /* required */ +#include /* strerror() */ -#include -#include -#include -#include -#include +#include /* free() */ +#include /* ntohs() */ #include "common.h" #include "config.h" @@ -34,22 +31,23 @@ #include "input_file.h" #include "input_network.h" -#include "audio_output.h" -#include "audio_decoder.h" - -#include "video.h" -#include "video_output.h" -#include "vdec_idct.h" -#include "vdec_motion.h" -#include "video_decoder.h" -#include "vpar_blocks.h" -#include "vpar_headers.h" -#include "vpar_synchro.h" -#include "video_parser.h" - -#include "ac3_decoder.h" -#include "ac3_decoder_thread.h" -#include "spu_decoder.h" +#include "audio_output.h" /* aout_thread_t */ +#include "audio_decoder.h" /* adec_thread_t */ + +#include "video.h" /* picture_t (for video_output.h) */ +#include "video_output.h" /* vout_thread_t */ + +#include "vdec_idct.h" /* dctelem_t (for video_parser.h) */ +#include "vdec_motion.h" /* f_motion_t (for video_parser.h) */ +#include "vpar_blocks.h" /* macroblock_t (for video_parser.h) */ +#include "vpar_headers.h" /* sequence_t (for video_parser.h) */ +#include "vpar_synchro.h" /* video_synchro_t (for video_parser.h) */ +#include "video_parser.h" /* vpar_thread_t */ + +#include "ac3_decoder.h" /* ac3dec_t (for ac3_decoder_thread.h) */ +#include "ac3_decoder_thread.h" /* ac3dec_thread_t */ + +#include "spu_decoder.h" /* spudec_thread_t */ #include "main.h" diff --git a/src/input/input_psi.c b/src/input/input_psi.c index e0b4d487ed..b597a640fd 100644 --- a/src/input/input_psi.c +++ b/src/input/input_psi.c @@ -9,15 +9,10 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include -#include -#include #include -#include -#include -#include -#include +#include /* free(), realloc() */ +#include /* bzero() */ +#include /* ntohs() */ #include "common.h" #include "config.h" @@ -29,12 +24,6 @@ #include "input.h" #include "input_ctrl.h" #include "input_psi.h" -#include "input_vlan.h" - -#include "audio_output.h" -#include "video.h" -#include "video_output.h" -#include "interface.h" #include "main.h" diff --git a/src/input/input_vlan.c b/src/input/input_vlan.c index 9c6101ce71..b59ddf729f 100644 --- a/src/input/input_vlan.c +++ b/src/input/input_vlan.c @@ -6,18 +6,18 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include /* ENOMEM */ +#include /* sprintf() */ +#include /* close() */ +#include /* strerror(), bzero() */ +#include /* free() */ + +#include /* inet_ntoa(), inet_aton() */ +#include /* ioctl() */ + +#ifdef SYS_LINUX +#include /* interface (arch-dependent) */ +#endif #include "config.h" #include "common.h" @@ -128,6 +128,7 @@ void input_VlanLeave( int i_vlan_id ) static int ZeTrucMucheFunction( int Channel) { +#ifdef SYS_LINUX int i_socket; char * ipaddr; struct ifreq interface; @@ -207,6 +208,7 @@ static int ZeTrucMucheFunction( int Channel) /*Close the socket */ close( i_socket ); +#endif return 0; } diff --git a/src/misc/netutils.c b/src/misc/netutils.c index 866757c4bf..56f830fdff 100644 --- a/src/misc/netutils.c +++ b/src/misc/netutils.c @@ -3,25 +3,21 @@ * (c)1999 VideoLAN ***************************************************************************** * XXX?? - ***************************************************************************** - * Required headers: - * *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include /* gethostbyname() */ +#include /* free(), realloc(), atoi() */ +#include /* errno() */ +#include /* bzero(), bcopy() */ +#include /* ioctl() */ +#include /* htons(), htonl() */ + +#ifdef SYS_LINUX +#include /* interface (arch-dependent) */ +#endif #include "config.h" #include "common.h" @@ -107,8 +103,9 @@ int ServerPort( char *psz_addr ) *****************************************************************************/ int ReadIfConf(int i_sockfd, if_descr_t* p_ifdescr, char* psz_name) { - struct ifreq ifr_config; int i_rc = 0; +#ifdef SYS_LINUX + struct ifreq ifr_config; ASSERT(p_ifdescr); ASSERT(psz_name); @@ -188,6 +185,7 @@ int ReadIfConf(int i_sockfd, if_descr_t* p_ifdescr, char* psz_name) psz_name, strerror(errno)); return -1; } +#endif /* SYS_LINUX */ return i_rc; } @@ -202,14 +200,17 @@ int ReadIfConf(int i_sockfd, if_descr_t* p_ifdescr, char* psz_name) *****************************************************************************/ int ReadNetConf(int i_sockfd, net_descr_t* p_net_descr) { +#ifdef SYS_LINUX struct ifreq* a_ifr_ifconf = NULL; struct ifreq* p_ifr_current_if; struct ifconf ifc_netconf; int i_if_number; int i_remaining; +#endif /* SYS_LINUX */ int i_rc = 0; +#ifdef SYS_LINUX ASSERT(p_net_descr); /* Start by assuming we have few than 3 interfaces (i_if_number will @@ -284,6 +285,8 @@ int ReadNetConf(int i_sockfd, net_descr_t* p_net_descr) /* Don't need the a_ifr_ifconf anymore */ free( a_ifr_ifconf ); +#endif /* SYS_LINUX */ + return i_rc; }