[FFmpeg-devel] [PATCH] pthread detection on mingw + static pthread
Gianluigi Tiesi
mplayer
Wed Apr 23 14:16:43 CEST 2008
On Tue, Apr 22, 2008 at 10:16:35PM +0100, M?ns Rullg?rd wrote:
> > + elif check_func pthread_create -DPTW32_STATIC_LIB -lpthreadGC2 -lws2_32; then
>
> The -D flag in that line has no effect, and can thus be removed.
>
> > + add_cflags -DPTW32_STATIC_LIB
hmm I've seen the compile options in config.err and it's used
anyway is needed to work when static linking
$ grep -l PTW32_STATIC_LIB *
dll.c
need_errno.h
pthread.h
ptw32_threadStart.c
ptw32_throw.c
sched.h
semaphore.h
>
> Is this preprocessor define required by the library, or was it
> something you invented for use in ffmpeg.c?
>
> > + add_extralibs -lpthreadGC2 -lws2_32
> > elif ! check_lib pthread.h pthread_create -lpthread; then
> > die "ERROR: can't find pthreads library"
> > fi
> > @@ -1629,7 +1634,7 @@
> > enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
> > enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
> > enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
> > -enabled libx264 && require x264 x264.h x264_encoder_open -lx264 -lm
> > +enabled libx264 && require2 x264 "stdint.h x264.h" x264_encoder_open -lx264 -lm
>
> Not necessary.
libx264 requires stdint.h
#if !defined(_STDINT_H) && !defined(_STDINT_H_) && \
!defined(_INTTYPES_H) && !defined(_INTTYPES_H_)
# ifdef _MSC_VER
# pragma message("You must include stdint.h or inttypes.h before
# x264.h")
# else
# warning You must include stdint.h or inttypes.h before x264.h
# endif
#endif
also if compiled with pthreads static it requires -lpthreadGC2 -lws2_32
or detection will fail
>
> > enabled libxvid && require Xvid xvid.h xvid_global -lxvidcore
> > enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
> >
> > Index: ffmpeg.c
> > ===================================================================
> > --- ffmpeg.c (revision 12924)
> > +++ ffmpeg.c (working copy)
> > @@ -3894,11 +3894,25 @@
> > { NULL, },
> > };
> >
> > +#ifdef PTW32_STATIC_LIB
> > +void detach_ptw32(void)
>
> Should be static.
yes
>
> > +{
> > + pthread_win32_process_attach_np();
> > + pthread_win32_thread_attach_np();
>
> Wrong indentation. The function is called detach_ptw32(), and calls
> *_attach_np(). Is it attach or detach? I'm confused.
typo -> detach
>
> > +}
> > +#endif
> > +
> > int main(int argc, char **argv)
> > {
> > int i;
> > int64_t ti;
> >
> > +#ifdef PTW32_STATIC_LIB
> > + pthread_win32_process_attach_np();
> > + pthread_win32_thread_attach_np();
> > + atexit(detach_ptw32);
> > +#endif
>
> What if the process is terminated without calling exit()? I also
> don't like the ifdef mess. Systems that require this don't deserve
> threads, IMNSHO.
if a process does not call exit it's because is crashed or called
abort(), I don't think calling detach is needed here
the ifdef is the only way, x264.c does the same thing without
atexit, that perhaps can be avoided if the code does not calls exit()
the problem with abnormal termination will stay
attached modified patch,
feel free to modify, apply or send to /dev/null
Regards
--
Gianluigi Tiesi <sherpya at netfarm.it>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/
-------------- next part --------------
Index: configure
===================================================================
--- configure (revision 12931)
+++ configure (working copy)
@@ -1593,6 +1593,11 @@
elif check_func pthread_create -pthreads; then
add_cflags -pthreads
add_extralibs -pthreads
+ elif check_func pthread_create -lpthreadGC2; then
+ add_extralibs -lpthreadGC2
+ elif check_func pthread_create -DPTW32_STATIC_LIB -lpthreadGC2 -lws2_32; then
+ add_cflags -DPTW32_STATIC_LIB
+ add_extralibs -lpthreadGC2 -lws2_32
elif ! check_lib pthread.h pthread_create -lpthread; then
die "ERROR: can't find pthreads library"
fi
@@ -1629,7 +1634,7 @@
enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
-enabled libx264 && require x264 x264.h x264_encoder_open -lx264 -lm
+enabled libx264 && require2 x264 "stdint.h x264.h" x264_encoder_open -lx264 -lm
enabled libxvid && require Xvid xvid.h xvid_global -lxvidcore
enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
Index: ffmpeg.c
===================================================================
--- ffmpeg.c (revision 12931)
+++ ffmpeg.c (working copy)
@@ -3898,11 +3898,25 @@
{ NULL, },
};
+#ifdef PTW32_STATIC_LIB
+static void detach_ptw32(void)
+{
+ pthread_win32_thread_detach_np();
+ pthread_win32_process_detach_np();
+}
+#endif
+
int main(int argc, char **argv)
{
int i;
int64_t ti;
+#ifdef PTW32_STATIC_LIB
+ pthread_win32_process_attach_np();
+ pthread_win32_thread_attach_np();
+ atexit(detach_ptw32);
+#endif
+
avcodec_register_all();
avdevice_register_all();
av_register_all();
Index: version.sh
===================================================================
--- version.sh (revision 12931)
+++ version.sh (working copy)
@@ -4,7 +4,7 @@
revision=`cd "$1" && LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2`
test $revision || revision=`cd "$1" && grep revision .svn/entries 2>/dev/null | cut -d '"' -f2`
test $revision || revision=`cd "$1" && sed -n -e '/^dir$/{n;p;q}' .svn/entries 2>/dev/null`
-test $revision && revision=SVN-r$revision
+test $revision && revision=Sherpya-r$revision
# check for git short hash
if ! test $revision; then
More information about the ffmpeg-devel
mailing list