diff options
author | konablend <[email protected]> | 2009-06-25 03:36:26 +0000 |
---|---|---|
committer | konablend <[email protected]> | 2009-06-25 03:36:26 +0000 |
commit | eef252057e08aeffc4a8b43d6eba838012debc28 (patch) | |
tree | 711122c860cc6fa878a0681046da0e0f20ed7ed4 /libhb/ports.c | |
parent | 1f5936650ac23cec965a8934b36a21b4f4bcfa16 (diff) |
Format cleanup.
- fixed ports.c to use a more portable method of getting integral pthread_t representation; resolves mingw crash.
- added GCC attribute to generate compiler warnings for invalid usage of hb_log, hb_deep_log and hb_errror;
see new macro HB_WPRINTF(s,v) in common.h.
- fixed various invalid usage of above functions on osx i386/x86_64, and mingw.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2618 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/ports.c')
-rw-r--r-- | libhb/ports.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/libhb/ports.c b/libhb/ports.c index 2e6b65329..40183015f 100644 --- a/libhb/ports.c +++ b/libhb/ports.c @@ -54,6 +54,8 @@ #include <netinet/in.h> #endif +#include <stddef.h> + #include "hb.h" /************************************************************************ @@ -261,6 +263,25 @@ struct hb_thread_s #endif }; +/* Get a unique identifier to thread and represent as 64-bit unsigned. + * If unsupported, the value 0 is be returned. + * Caller should use result only for display/log purposes. + */ +static uint64_t hb_thread_to_integer( const hb_thread_t* t ) +{ +#if defined( USE_PTHREAD ) + #if defined( _WIN32 ) || defined( __MINGW32__ ) + return (uint64_t)(ptrdiff_t)t->thread.p; + #elif defined( SYS_DARWIN ) + return (uint64_t)(ptrdiff_t)t->thread; + #else + return (uint64_t)t->thread; + #endif +#else + return 0; +#endif +} + /************************************************************************ * hb_thread_func() ************************************************************************ @@ -291,7 +312,7 @@ static void hb_thread_func( void * _t ) t->function( t->arg ); /* Inform that the thread can be joined now */ - hb_deep_log( 2, "thread %x exited (\"%s\")", t->thread, t->name ); + hb_deep_log( 2, "thread %"PRIx64" exited (\"%s\")", hb_thread_to_integer( t ), t->name ); hb_lock( t->lock ); t->exited = 1; hb_unlock( t->lock ); @@ -336,7 +357,7 @@ hb_thread_t * hb_thread_init( char * name, void (* function)(void *), // SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL ); #endif - hb_deep_log( 2, "thread %x started (\"%s\")", t->thread, t->name ); + hb_deep_log( 2, "thread %"PRIx64" started (\"%s\")", hb_thread_to_integer( t ), t->name ); return t; } @@ -361,8 +382,7 @@ void hb_thread_close( hb_thread_t ** _t ) // WaitForSingleObject( t->thread, INFINITE ); #endif - hb_deep_log( 2, "thread %x joined (\"%s\")", - t->thread, t->name ); + hb_deep_log( 2, "thread %"PRIx64" joined (\"%s\")", hb_thread_to_integer( t ), t->name ); hb_lock_close( &t->lock ); free( t->name ); |