diff options
author | handbrake <[email protected]> | 2007-01-03 01:11:09 +0000 |
---|---|---|
committer | handbrake <[email protected]> | 2007-01-03 01:11:09 +0000 |
commit | 79de879241d42814c3db4f897ad6a632ebe42a7f (patch) | |
tree | 44ac1a61c3b493e5cc2f99322a4ade200a6c29e3 | |
parent | 4a04f3ecd4d15ad7a47bc797e991f412c426b05f (diff) |
Changes to make HandBrake build on Windows using the Cygwin environment:
root configure file:
I added this to the "case $SYSTEM in" switch statement: CYGWIN_NT*) DEFINES="$DEFINES SYS_CYGWIN USE_PTHREAD" LINKLIBS="$LINKLIBS -lpthread" ;;
Also, for each existing OS type that is using -lpthread, I added USE_PTHREAD to their DEFINES. Then libhb/ports.c was changed to use pthread code based on the value of USE_PTHREAD, instead of checking each different OS value that used pthreading, so it's a bit easier to read and maintain.
root Jamfile:
Jam doesn't seem to understand CYGWIN, so $(OS) is defined as UNKNOWN. Check for this, and if this it true then set $(OS) to CYGWIN. Since CSS doesn't work (yet) on CYGWIN/Windows, I also changed Jamfile to not include libdvdcss.a in the library list for CYGWIN.
contrib/Jamfile:
For CYGWIN, don't build libdvdcss, and don't specify it's path for libdvdread. There are also a few changes to use new patchfiles for Cygwin for a few of the libraries.
x264:
Change configure script so that it doesn't include -mno-cygwin flags for CYGWIN platform. Created patchfile patch-x264-cygwin.patch for this, which is used by Jamfile. The -mno-cygwin flags cause the library not to link correctly with HBTest.exe. The -mno-cygwin flag is used to create an object file or library that doesn't depend on cygwin1.dll if you're using MinGW, but I'm not (yet).
libxvidcore:
Change configure script so that it doesn't include -mno-cygwin flags for CYGWIN platform. Change configure script so that it uses libxvidcore.a as the lib name instead of xvidcore.a for CYGWIN. Created patchfile patch-xvidcore-cygwin.patch that contains the 2 above changes and is used by Jamfile. Renamed patch-xvidcore.patch to patch-xvidcore-macosx.patch and updated Jamfile as appropriate -- an attempt to keep the patches being applied only when needed for a particular platform.
ffmpeg:
libavcodec/mpegaudiodec.c uses llrint(), which apparently isn't availble with Cygwin, so I changed the file to use lrint() which is available. llrint() returns a long long, lrint() returns a long. In the places where llrint() was being called, the return value of llrint() was being assigned to an element in an array of unsigned ints, so llrint() (long long) shouldn't be needed, and lrint() (long) should be fine. Created patchfile patch-ffmpeg-cygwin.patch that contains this change, and is used by Jamfile.
libhb/ports.c:
Commented out a number of things that were broken with the current SYS_CYGWIN code. The most notable change was to not use Windows threading for CYGWIN, and instead use pthreading. All the places where the OS type was being checked to determine whether or not to use pthreading were changed so that the USE_PTHREAD define is checked instead. There seems to be some problem with the Windows threading code in ports.c, because if I enable it then x264 encodes will either crash or lock-up HBTest.exe. Perhaps this is related to mixing threading models, since x264 is compiled with pthread support, and so maybe mixing pthread with Windows threading in the same process is a bad thing.
test/test.c:
Need to #include sys/time.h, time.h, unistd.h to compile.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@84 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | BUILD | 21 | ||||
-rw-r--r-- | Jamfile | 12 | ||||
-rwxr-xr-x | configure | 13 | ||||
-rw-r--r-- | contrib/Jamfile | 81 | ||||
-rw-r--r-- | contrib/patch-ffmpeg-cygwin.patch | 15 | ||||
-rw-r--r-- | contrib/patch-x264-cygwin.patch | 14 | ||||
-rw-r--r-- | contrib/patch-xvidcore-cygwin.patch | 34 | ||||
-rw-r--r-- | contrib/patch-xvidcore-macosx.patch (renamed from contrib/patch-xvidcore.patch) | 0 | ||||
-rw-r--r-- | libhb/ports.c | 116 | ||||
-rw-r--r-- | test/test.c | 3 |
10 files changed, 224 insertions, 85 deletions
@@ -5,8 +5,8 @@ BUILD file for HandBrake <http://handbrake.m0k.org/> Building HandBrake ================== -You can build HandBrake on BeOS, MacOS X and Linux. If you'd like to -port it to another OS, email me ([email protected]). +You can build HandBrake on BeOS, MacOS X, Linux, and on Windows using Cygwin. +If you'd like to port it to another OS, email me ([email protected]). Step 1: get needed tools ======================== @@ -20,8 +20,25 @@ Step 1: get needed tools On OS X, you cannot use the modified jam shipped with the developer tools, use this one instead: <http://download.m0k.org/handbrake/jam-2.5rc3-OSX.zip>. + On Cygwin, get the jam source from + http://public.perforce.com/public/jam/index.html, + compile it with gcc in Cygwin, and put the jam executable somewhere on + your path. + nasm (Only for x86. On Mac OS X Intel, Nasm CVS is required) +Cygwin setup: + There are a couple extra things required to make the code build for Cygwin. + Make sure you have /bin and /usr/bin on your path *first*, before + the Windows paths. Otherwise the Cygwin find.exe won't be used, and + lame won't build. + Also, I have not tried to build this with MinGW, I've only built it with + the Cygwin environment, so you should build with Cygwin gcc and dev tools. + Unfortunately this means you need to have cygwin1.dll around to run the + HBTest.exe program, but that's the way it is for now, until I get time + to try building it with MinGW. If you want to try making it work with + MinGW, then go for it! + + Step 2: build ============= @@ -10,13 +10,23 @@ SubDir TOP ; HB_LIBS = libhb.a contrib/lib/liba52.a contrib/lib/libavformat.a contrib/lib/libavcodec.a contrib/lib/libavutil.a - contrib/lib/libdvdread.a contrib/lib/libdvdcss.a + contrib/lib/libdvdread.a contrib/lib/libfaac.a contrib/lib/libmp3lame.a contrib/lib/libmpeg2.a contrib/lib/libvorbis.a contrib/lib/libvorbisenc.a contrib/lib/libogg.a contrib/lib/libsamplerate.a contrib/lib/libx264.a contrib/lib/libxvidcore.a ; +if $(OS) = UNKNOWN +{ + OS = CYGWIN ; +} + +if $(OS) != CYGWIN +{ + HB_LIBS = $(HB_LIBS) contrib/lib/libdvdcss.a ; +} + # Interfaces TEST_BIN = HBTest ; TEST_SRC = test/test.c ; @@ -32,22 +32,27 @@ case $SYSTEM in ;; Darwin) - DEFINES="$DEFINES SYS_DARWIN" + DEFINES="$DEFINES SYS_DARWIN USE_PTHREAD" LINKLIBS="$LINKLIBS -lpthread" ;; FreeBSD) - DEFINES="$DEFINES SYS_FREEBSD" + DEFINES="$DEFINES SYS_FREEBSD USE_PTHREAD" LINKLIBS="$LINKLIBS -pthread" ;; NetBSD) - DEFINES="$DEFINES SYS_NETBSD" + DEFINES="$DEFINES SYS_NETBSD USE_PTHREAD" LINKLIBS="$LINKLIBS -lpthread" ;; Linux) - DEFINES="$DEFINES SYS_LINUX" + DEFINES="$DEFINES SYS_LINUX USE_PTHREAD" + LINKLIBS="$LINKLIBS -lpthread" + ;; + + CYGWIN*) + DEFINES="$DEFINES SYS_CYGWIN USE_PTHREAD" LINKLIBS="$LINKLIBS -lpthread" ;; diff --git a/contrib/Jamfile b/contrib/Jamfile index 92666a903..1cdc3793d 100644 --- a/contrib/Jamfile +++ b/contrib/Jamfile @@ -48,6 +48,10 @@ rule LibAvCodec FFMPEG_OPTIONS = --enable-memalign-hack ; FFMPEG_PATCH += " && patch -p1 < ../patch-ffmpeg-macintel.patch" ; } + else if $(OS) = CYGWIN + { + FFMPEG_PATCH += " && patch -p1 < ../patch-ffmpeg-cygwin.patch " ; + } Depends $(<) : $(>) ; Depends lib : $(<) ; } @@ -75,22 +79,26 @@ actions LibAvUtil LibAvUtil $(SUBDIR)/lib/libavutil.a : $(SUBDIR)/lib/libavcodec.a ; LibAvUtil $(SUBDIR)/lib/libavformat.a : $(SUBDIR)/lib/libavcodec.a ; -# libdvdcss -# We need libdvdcss.so for libdvdread's configure to work... -rule LibDvdCss +# CSS doesn't work on Cygwin/Windows as of now, so don't use it. +if $(OS) != CYGWIN { - Depends $(<) : $(>) ; - Depends lib : $(<) ; -} -actions LibDvdCss -{ - cd `dirname $(>)` && CONTRIB=`pwd` && - rm -rf libdvdcss && tar xzf libdvdcss.tar.gz && cd libdvdcss && - ./configure --prefix=$CONTRIB && make && make install && - strip -S $CONTRIB/lib/libdvdcss.a + # libdvdcss + # We need libdvdcss.so for libdvdread's configure to work... + rule LibDvdCss + { + Depends $(<) : $(>) ; + Depends lib : $(<) ; + } + actions LibDvdCss + { + cd `dirname $(>)` && CONTRIB=`pwd` && + rm -rf libdvdcss && tar xzf libdvdcss.tar.gz && cd libdvdcss && + ./configure --prefix=$CONTRIB && make && make install && + strip -S $CONTRIB/lib/libdvdcss.a + } + Wget $(SUBDIR)/libdvdcss.tar.gz : $(SUBDIR)/version_libdvdcss.txt ; + LibDvdCss $(SUBDIR)/lib/libdvdcss.a : $(SUBDIR)/libdvdcss.tar.gz ; } -Wget $(SUBDIR)/libdvdcss.tar.gz : $(SUBDIR)/version_libdvdcss.txt ; -LibDvdCss $(SUBDIR)/lib/libdvdcss.a : $(SUBDIR)/libdvdcss.tar.gz ; # libdvdread rule LibDvdRead @@ -99,14 +107,30 @@ rule LibDvdRead Depends $(<) : $(>) ; Depends lib : $(<) ; } -actions LibDvdRead +if $(OS) != CYGWIN { - cd `dirname $(>)` && CONTRIB=`pwd` && - rm -rf libdvdread && tar xzf libdvdread.tar.gz && cd libdvdread && - $(LIBDVDREAD_PATCH) && - ./configure --prefix=$CONTRIB --disable-shared --with-libdvdcss=$CONTRIB && - make && make install && - strip -S $CONTRIB/lib/libdvdread.a + actions LibDvdRead + { + cd `dirname $(>)` && CONTRIB=`pwd` && + rm -rf libdvdread && tar xzf libdvdread.tar.gz && cd libdvdread && + $(LIBDVDREAD_PATCH) && + ./configure --prefix=$CONTRIB --disable-shared --with-libdvdcss=$CONTRIB && + make && make install && + strip -S $CONTRIB/lib/libdvdread.a + } +} +else { + # Cygwin/Windows doesn't use CSS as of now, so don't include it on the + # configure line. + actions LibDvdRead + { + cd `dirname $(>)` && CONTRIB=`pwd` && + rm -rf libdvdread && tar xzf libdvdread.tar.gz && cd libdvdread && + $(LIBDVDREAD_PATCH) && + ./configure --prefix=$CONTRIB --disable-shared && + make && make install && + strip -S $CONTRIB/lib/libdvdread.a + } } Wget $(SUBDIR)/libdvdread.tar.gz : $(SUBDIR)/version_libdvdread.txt ; LibDvdRead $(SUBDIR)/lib/libdvdread.a : $(SUBDIR)/libdvdread.tar.gz ; @@ -232,6 +256,10 @@ rule LibX264 { LIBX264_PATCH = " patch -p1 < ../patch-x264-macintel.patch && " ; } + else if $(OS) = CYGWIN + { + LIBX264_PATCH = " patch -p1 < ../patch-x264-cygwin.patch && " ; + } Depends $(<) : $(>) ; Depends lib : $(<) ; } @@ -249,6 +277,15 @@ LibX264 $(SUBDIR)/lib/libx264.a : $(SUBDIR)/x264.tar.gz ; # libxvidcore rule LibXvidCore { + LIBXVIDCORE_PATCH = "" ; + if $(OS) = MACOSX + { + LIBXVIDCORE_PATCH = " patch -p1 < ../patch-xvidcore-macosx.patch && " ; + } + else if $(OS) = CYGWIN + { + LIBXVIDCORE_PATCH = " patch -p1 < ../patch-xvidcore-cygwin.patch && " ; + } Depends $(<) : $(>) ; Depends lib : $(<) ; } @@ -256,7 +293,7 @@ actions LibXvidCore { cd `dirname $(>)` && CONTRIB=`pwd` && rm -rf xvidcore && tar xzf xvidcore.tar.gz && - cd xvidcore && patch -p1 < ../patch-xvidcore.patch && + cd xvidcore && $(LIBXVIDCORE_PATCH) cd build/generic/ && ./configure && make libxvidcore.a && cp ./=build/libxvidcore.a $CONTRIB/lib/ && cp ../../src/xvid.h $CONTRIB/include/ && diff --git a/contrib/patch-ffmpeg-cygwin.patch b/contrib/patch-ffmpeg-cygwin.patch new file mode 100644 index 000000000..b6ca99f26 --- /dev/null +++ b/contrib/patch-ffmpeg-cygwin.patch @@ -0,0 +1,15 @@ +diff -Naur ffmpeg/libavcodec/mpegaudiodec.c ffmpeg-patched/libavcodec/mpegaudiodec.c +--- ffmpeg/libavcodec/mpegaudiodec.c 2006-09-23 14:22:06.000000000 -0400 ++++ ffmpeg-patched/libavcodec/mpegaudiodec.c 2007-01-01 18:31:51.156250000 -0500 +@@ -401,9 +401,9 @@ + for(i=0; i<512*16; i++){ + int exponent= (i>>4); + double f= pow(i&15, 4.0 / 3.0) * pow(2, (exponent-400)*0.25 + FRAC_BITS + 5); +- expval_table[exponent][i&15]= llrint(f); ++ expval_table[exponent][i&15]= lrint(f); + if((i&15)==1) +- exp_table[exponent]= llrint(f); ++ exp_table[exponent]= lrint(f); + } + + for(i=0;i<7;i++) { diff --git a/contrib/patch-x264-cygwin.patch b/contrib/patch-x264-cygwin.patch new file mode 100644 index 000000000..40a14fa44 --- /dev/null +++ b/contrib/patch-x264-cygwin.patch @@ -0,0 +1,14 @@ +diff -Naur x264/configure x264-patched/configure +--- x264/configure 2007-01-01 17:01:36.609375000 -0500 ++++ x264-patched/configure 2007-01-01 17:02:36.468750000 -0500 +@@ -96,8 +96,8 @@ + ;; + cygwin*) + SYS="CYGWIN" +- CFLAGS="$CFLAGS -mno-cygwin" +- LDFLAGS="$LDFLAGS -mno-cygwin" ++ #CFLAGS="$CFLAGS -mno-cygwin" ++ #LDFLAGS="$LDFLAGS -mno-cygwin" + EXE=".exe" + DEVNULL="NUL" + ;; diff --git a/contrib/patch-xvidcore-cygwin.patch b/contrib/patch-xvidcore-cygwin.patch new file mode 100644 index 000000000..7b60510d0 --- /dev/null +++ b/contrib/patch-xvidcore-cygwin.patch @@ -0,0 +1,34 @@ +diff -Naur xvidcore/build/generic/configure xvidcore-patched/build/generic/configure +--- xvidcore/build/generic/configure 2005-12-30 09:45:30.000000000 -0500 ++++ xvidcore-patched/build/generic/configure 2007-01-01 18:43:27.953125000 -0500 +@@ -3844,10 +3844,9 @@ + [cC][yY][gG][wW][iI][nN]*|mingw32*|mks*) + echo "$as_me:$LINENO: result: ok" >&5 + echo "${ECHO_T}ok" >&6 +- STATIC_LIB="xvidcore.\$(STATIC_EXTENSION)" +- SHARED_LIB="xvidcore.\$(SHARED_EXTENSION)" +- SPECIFIC_LDFLAGS="-mno-cygwin -shared -Wl,--dll,--out-implib,\[email protected] libxvidcore.def" +- SPECIFIC_CFLAGS="-mno-cygwin" ++ STATIC_LIB="libxvidcore.\$(STATIC_EXTENSION)" ++ SHARED_LIB="libxvidcore.\$(SHARED_EXTENSION)" ++ SPECIFIC_LDFLAGS="-shared -Wl,--dll,--out-implib,\[email protected] libxvidcore.def" + ;; + darwin*|raphsody*) + STATIC_LIB="libxvidcore.\$(STATIC_EXTENSION)" +diff -Naur xvidcore/build/generic/configure.in xvidcore-patched/build/generic/configure.in +--- xvidcore/build/generic/configure.in 2005-12-30 09:45:30.000000000 -0500 ++++ xvidcore-patched/build/generic/configure.in 2007-01-01 18:43:11.453125000 -0500 +@@ -281,10 +281,9 @@ + ;; + [[cC]][[yY]][[gG]][[wW]][[iI]][[nN]]*|mingw32*|mks*) + AC_MSG_RESULT([ok]) +- STATIC_LIB="xvidcore.\$(STATIC_EXTENSION)" +- SHARED_LIB="xvidcore.\$(SHARED_EXTENSION)" +- SPECIFIC_LDFLAGS="-mno-cygwin -shared -Wl,--dll,--out-implib,\[email protected] libxvidcore.def" +- SPECIFIC_CFLAGS="-mno-cygwin" ++ STATIC_LIB="libxvidcore.\$(STATIC_EXTENSION)" ++ SHARED_LIB="libxvidcore.\$(SHARED_EXTENSION)" ++ SPECIFIC_LDFLAGS="-shared -Wl,--dll,--out-implib,\[email protected] libxvidcore.def" + ;; + darwin*|raphsody*) + STATIC_LIB="libxvidcore.\$(STATIC_EXTENSION)" diff --git a/contrib/patch-xvidcore.patch b/contrib/patch-xvidcore-macosx.patch index 51cb94c6d..51cb94c6d 100644 --- a/contrib/patch-xvidcore.patch +++ b/contrib/patch-xvidcore-macosx.patch diff --git a/libhb/ports.c b/libhb/ports.c index 20c2cae94..bdeadc1f8 100644 --- a/libhb/ports.c +++ b/libhb/ports.c @@ -10,21 +10,23 @@ #if defined( SYS_BEOS ) #include <OS.h> #include <signal.h> -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) -#include <pthread.h> #elif defined( SYS_CYGWIN ) #include <windows.h> #endif -#ifdef SYS_CYGWIN -#include <winsock2.h> -#include <ws2tcpip.h> -#else +#if USE_PTHREAD +#include <pthread.h> +#endif + +//#ifdef SYS_CYGWIN +//#include <winsock2.h> +//#include <ws2tcpip.h> +//#else #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> -#endif +//#endif #include "hb.h" @@ -35,6 +37,7 @@ * On Win32, we implement a gettimeofday emulation here because * libdvdread and libmp4v2 use it without checking. ************************************************************************/ +/* #ifdef SYS_CYGWIN struct timezone { @@ -49,6 +52,7 @@ int gettimeofday( struct timeval * tv, struct timezone * tz ) return 0; } #endif +*/ uint64_t hb_get_date() { @@ -204,11 +208,11 @@ void hb_get_tempory_filename( hb_handle_t * h, char name[1024], ***********************************************************************/ void hb_mkdir( char * name ) { -#ifdef SYS_CYGWIN - mkdir( name ); -#else +//#ifdef SYS_CYGWIN +// mkdir( name ); +//#else mkdir( name, 0755 ); -#endif +//#endif } /************************************************************************ @@ -226,10 +230,10 @@ struct hb_thread_s #if defined( SYS_BEOS ) thread_id thread; -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_t thread; -#elif defined( SYS_CYGWIN ) - HANDLE thread; +//#elif defined( SYS_CYGWIN ) +// HANDLE thread; #endif }; @@ -295,17 +299,17 @@ hb_thread_t * hb_thread_init( char * name, void (* function)(void *), name, priority, t ); resume_thread( t->thread ); -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_create( &t->thread, NULL, (void * (*)( void * )) hb_thread_func, t ); -#elif defined( SYS_CYGWIN ) - t->thread = CreateThread( NULL, 0, - (LPTHREAD_START_ROUTINE) hb_thread_func, t, 0, NULL ); - - /* Maybe use THREAD_PRIORITY_LOWEST instead */ - if( priority == HB_LOW_PRIORITY ) - SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL ); +//#elif defined( SYS_CYGWIN ) +// t->thread = CreateThread( NULL, 0, +// (LPTHREAD_START_ROUTINE) hb_thread_func, t, 0, NULL ); +// +// /* Maybe use THREAD_PRIORITY_LOWEST instead */ +// if( priority == HB_LOW_PRIORITY ) +// SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL ); #endif hb_log( "thread %d started (\"%s\")", t->thread, t->name ); @@ -326,11 +330,11 @@ void hb_thread_close( hb_thread_t ** _t ) long exit_value; wait_for_thread( t->thread, &exit_value ); -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_join( t->thread, NULL ); -#elif defined( SYS_CYGWIN ) - WaitForSingleObject( t->thread, INFINITE ); +//#elif defined( SYS_CYGWIN ) +// WaitForSingleObject( t->thread, INFINITE ); #endif hb_log( "thread %d joined (\"%s\")", @@ -365,10 +369,10 @@ struct hb_lock_s { #if defined( SYS_BEOS ) sem_id sem; -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_mutex_t mutex; -#elif defined( SYS_CYGWIN ) - HANDLE mutex; +//#elif defined( SYS_CYGWIN ) +// HANDLE mutex; #endif }; @@ -386,10 +390,10 @@ hb_lock_t * hb_lock_init() #if defined( SYS_BEOS ) l->sem = create_sem( 1, "sem" ); -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_mutex_init( &l->mutex, NULL ); -#elif defined( SYS_CYGWIN ) - l->mutex = CreateMutex( 0, FALSE, 0 ); +//#elif defined( SYS_CYGWIN ) +// l->mutex = CreateMutex( 0, FALSE, 0 ); #endif return l; @@ -401,10 +405,10 @@ void hb_lock_close( hb_lock_t ** _l ) #if defined( SYS_BEOS ) delete_sem( l->sem ); -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_mutex_destroy( &l->mutex ); -#elif defined( SYS_CYGWIN ) - CloseHandle( l->mutex ); +//#elif defined( SYS_CYGWIN ) +// CloseHandle( l->mutex ); #endif free( l ); @@ -415,10 +419,10 @@ void hb_lock( hb_lock_t * l ) { #if defined( SYS_BEOS ) acquire_sem( l->sem ); -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_mutex_lock( &l->mutex ); -#elif defined( SYS_CYGWIN ) - WaitForSingleObject( l->mutex, INFINITE ); +//#elif defined( SYS_CYGWIN ) +// WaitForSingleObject( l->mutex, INFINITE ); #endif } @@ -426,10 +430,10 @@ void hb_unlock( hb_lock_t * l ) { #if defined( SYS_BEOS ) release_sem( l->sem ); -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_mutex_unlock( &l->mutex ); -#elif defined( SYS_CYGWIN ) - ReleaseMutex( l->mutex ); +//#elif defined( SYS_CYGWIN ) +// ReleaseMutex( l->mutex ); #endif } @@ -440,10 +444,10 @@ struct hb_cond_s { #if defined( SYS_BEOS ) int thread; -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_cond_t cond; -#elif defined( SYS_CYGWIN ) - HANDLE event; +//#elif defined( SYS_CYGWIN ) +// HANDLE event; #endif }; @@ -462,10 +466,10 @@ hb_cond_t * hb_cond_init() #if defined( SYS_BEOS ) c->thread = -1; -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_cond_init( &c->cond, NULL ); -#elif defined( SYS_CYGWIN ) - c->event = CreateEvent( NULL, FALSE, FALSE, NULL ); +//#elif defined( SYS_CYGWIN ) +// c->event = CreateEvent( NULL, FALSE, FALSE, NULL ); #endif return c; @@ -476,10 +480,10 @@ void hb_cond_close( hb_cond_t ** _c ) hb_cond_t * c = *_c; #if defined( SYS_BEOS ) -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_cond_destroy( &c->cond ); -#elif defined( SYS_CYGWIN ) - CloseHandle( c->event ); +//#elif defined( SYS_CYGWIN ) +// CloseHandle( c->event ); #endif free( c ); @@ -494,11 +498,11 @@ void hb_cond_wait( hb_cond_t * c, hb_lock_t * lock ) suspend_thread( c->thread ); acquire_sem( lock->sem ); c->thread = -1; -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_cond_wait( &c->cond, &lock->mutex ); -#elif defined( SYS_CYGWIN ) - SignalObjectAndWait( lock->mutex, c->event, INFINITE, FALSE ); - WaitForSingleObject( lock->mutex, INFINITE ); +//#elif defined( SYS_CYGWIN ) +// SignalObjectAndWait( lock->mutex, c->event, INFINITE, FALSE ); +// WaitForSingleObject( lock->mutex, INFINITE ); #endif } @@ -519,10 +523,10 @@ void hb_cond_signal( hb_cond_t * c ) thread is actually suspended before we resume it */ snooze( 5000 ); } -#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD ) +#elif USE_PTHREAD pthread_cond_signal( &c->cond ); -#elif defined( SYS_CYGWIN ) - PulseEvent( c->event ); +//#elif defined( SYS_CYGWIN ) +// PulseEvent( c->event ); #endif } diff --git a/test/test.c b/test/test.c index 0f43a7f16..de499f4fd 100644 --- a/test/test.c +++ b/test/test.c @@ -6,6 +6,9 @@ #include <signal.h> #include <getopt.h> +#include <sys/time.h> +#include <time.h> +#include <unistd.h> #include "hb.h" |