From 3fba5f0231bbe98fcd3ae0377529b840928f0990 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 3 Nov 2008 13:08:04 +0000 Subject: [PATCH] 2008-11-03 14:08 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbthread.h * harbour/source/vm/thread.c + added ULONG _hb_gettid( void ) to OS2 builds - thanks to Maurilio * harbour/source/rtl/hbinet.c * changed a little bit the order of including header files in OS2 builds (blink fix for OpenWatcom OS2 builds). --- harbour/ChangeLog | 9 +++++++++ harbour/include/hbthread.h | 8 +++++++- harbour/source/rtl/hbinet.c | 17 +++++++++++------ harbour/source/vm/thread.c | 18 +++++++++++++----- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4ea4bc3b56..12ecaee490 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,15 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-11-03 14:08 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbthread.h + * harbour/source/vm/thread.c + + added ULONG _hb_gettid( void ) to OS2 builds - thanks to Maurilio + + * harbour/source/rtl/hbinet.c + * changed a little bit the order of including header files in OS2 builds + (blink fix for OpenWatcom OS2 builds). + 2008-11-03 12:13 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * include/hbextern.ch ! Synced codepage list with recent changes. diff --git a/harbour/include/hbthread.h b/harbour/include/hbthread.h index c02fdac5d8..c246f7d4e4 100644 --- a/harbour/include/hbthread.h +++ b/harbour/include/hbthread.h @@ -167,13 +167,19 @@ HB_EXTERN_BEGIN typedef HMTX HB_RAWCRITICAL_T; typedef HEV HB_RAWCOND_T; + extern ULONG _hb_gettid( void ); + # define HB_THREAD_STARTFUNC( func ) void func( void * Cargo ) # define HB_THREAD_END _endthread(); return; # define HB_THREAD_RAWEND return; # define HB_CRITICAL_INITVAL ( ( HMTX ) 0 ) # define HB_COND_INITVAL ( ( HEV ) 0 ) -# define HB_THREAD_SELF() ( ( TID ) _gettid() ) +# if defined( __GNUC__ ) +# define HB_THREAD_SELF() ( ( TID ) _gettid() ) +# else +# define HB_THREAD_SELF() ( ( TID ) _hb_gettid() ) +# endif # define HB_CRITICAL_INIT(v) DosCreateMutexSem( NULL, &(v), 0L, FALSE ) # define HB_CRITICAL_DESTROY(v) DosCloseMutexSem( v ) diff --git a/harbour/source/rtl/hbinet.c b/harbour/source/rtl/hbinet.c index 63ab9ede44..2835945c9c 100644 --- a/harbour/source/rtl/hbinet.c +++ b/harbour/source/rtl/hbinet.c @@ -96,8 +96,18 @@ #define HB_SOCKET_T int #include +#if defined( HB_OS_OS2 ) + #if defined( __WATCOMC__ ) + #include + #endif #include #include + #include + #include +#else + #include + #include +#endif #include #include #include @@ -206,15 +216,10 @@ #include #endif -#if defined( HB_OS_UNIX ) || defined( HB_OS_UNIX_COMPATIBLE ) || defined( HB_OS_BSD ) || defined( HB_OS_OS2 ) +#if defined( HB_OS_UNIX ) || defined( HB_OS_UNIX_COMPATIBLE ) || defined( HB_OS_OS2 ) #include #endif -#if defined( HB_OS_OS2 ) - #include - #include - #include -#endif #if defined( HB_OS_OS2 ) || defined( HB_OS_WIN_32 ) /* NET_SIZE_T exists because of shortsightedness on the POSIX committee. BSD diff --git a/harbour/source/vm/thread.c b/harbour/source/vm/thread.c index c9f87b9991..7ae993726c 100644 --- a/harbour/source/vm/thread.c +++ b/harbour/source/vm/thread.c @@ -74,11 +74,6 @@ # include #endif -/* temporary workaround for non GCC ST builds */ -#if !defined( HB_MT_VM ) && defined( HB_OS_OS2 ) && !defined( __GNUC__ ) -# define _gettid() 0 -#endif - static volatile BOOL s_fThreadInit = FALSE; static PHB_ITEM s_pOnceMutex = NULL; @@ -188,6 +183,19 @@ void hb_threadExit( void ) } } +#if defined( HB_OS_OS2 ) +ULONG _hb_gettid( void ) +{ + ULONG tid = 0; + PTIB ptib = NULL; + + if( DosGetInfoBlocks( &ptib, NULL ) == NO_ERROR ) + tid = ptib->tib_ptib2->tib2_ultid; + + return tid; +} +#endif + void hb_threadEnterCriticalSection( HB_CRITICAL_T * critical ) { #if !defined( HB_MT_VM )