From d98434208b241f79f83fdfce737520a5745990ba Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 7 Oct 2008 16:44:37 +0000 Subject: [PATCH] 2008-10-07 18:42 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * source/rtl/seconds.c * Some cleanup after latest change. Functionality shouldn't change. OS/2 users pls verify. --- harbour/ChangeLog | 35 +++++++++++++++----------- harbour/source/rtl/seconds.c | 48 ++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6fe7e5cdc9..eb131acbe2 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,11 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-10-07 18:42 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * source/rtl/seconds.c + * Some cleanup after latest change. + Functionality shouldn't change. OS/2 users pls verify. + 2008-10-07 18:36 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/vm/estack.c ! fixed typo in last commit @@ -23,23 +28,23 @@ some random CPU delay used to resolve the conflict. 2008-10-07 16:33 UTC+0200 Maurilio Longo (maurilio.longo@libero.it) - * harbour/source/rtl/seconds.c - + Added OS/2 section to secondsCPU(), but it does not work as expected :) - In particular, user and system times are kept per thread, but when a thread - dies the time it has spent in user and system-land gets lost, so the - overall running time of the program decreases. Not only, if I call - secondsCPU() before a thread starts and after it has ended I'll have - no idea of the time that was spent by that thread. + * harbour/source/rtl/seconds.c + + Added OS/2 section to secondsCPU(), but it does not work as expected :) + In particular, user and system times are kept per thread, but when a thread + dies the time it has spent in user and system-land gets lost, so the + overall running time of the program decreases. Not only, if I call + secondsCPU() before a thread starts and after it has ended I'll have + no idea of the time that was spent by that thread. 2008-10-07 14:24 UTC+0200 Viktor Szakats (harbour.01 syenar hu) - * include/hbapierr.h - * source/vm/extrap.c - * source/rtl/errorint.c - ! Fixed recent modification on Windows platform, where - GPF would generate an internal error. - It didn't launch the OS error handler. - ! Fixed hb_errInternal() being marked as HB_EXPORT - in the headers only. + * include/hbapierr.h + * source/vm/extrap.c + * source/rtl/errorint.c + ! Fixed recent modification on Windows platform, where + GPF would generate an internal error. + It didn't launch the OS error handler. + ! Fixed hb_errInternal() being marked as HB_EXPORT + in the headers only. 2008-10-07 09:33 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * include/hbextern.ch diff --git a/harbour/source/rtl/seconds.c b/harbour/source/rtl/seconds.c index a2b21b7c23..198e4b03c3 100644 --- a/harbour/source/rtl/seconds.c +++ b/harbour/source/rtl/seconds.c @@ -257,14 +257,9 @@ HB_EXPORT double hb_secondsCPU( int n ) #endif #if defined( HB_OS_OS2 ) - static ULONG timer_interval = 0; + static ULONG s_timer_interval = 0; - APIRET rc; QSGREC ** pBuf; - QSGREC * pGrec; - QSPREC * pPrec; - QSTREC * pTrec; - int i; #endif if( ( n < 1 || n > 3 ) && ( n < 11 || n > 13 ) ) @@ -313,48 +308,47 @@ HB_EXPORT double hb_secondsCPU( int n ) d /= 10000000.0; } else - #elif defined( HB_OS_OS2 ) - if ( timer_interval == 0 ) { - DosQuerySysInfo( QSV_TIMER_INTERVAL, QSV_TIMER_INTERVAL, (PVOID) &timer_interval, sizeof( ULONG ) ); - } + if( s_timer_interval == 0 ) + DosQuerySysInfo( QSV_TIMER_INTERVAL, QSV_TIMER_INTERVAL, ( PVOID ) &s_timer_interval, sizeof( ULONG ) ); - pBuf = malloc( BUFSIZE ); + QSGREC ** pBuf = hb_xalloc( BUFSIZE ); - if ( pBuf ) { + if( pBuff ) + { + APIRET rc = DosQuerySysState( QS_PROCESS, 0L, _getpid(), 0L, pBuf, BUFSIZE ); - rc = DosQuerySysState( QS_PROCESS, 0L, _getpid(), 0L, pBuf, BUFSIZE ); + if( rc == NO_ERROR ) + { + QSGREC * pGrec = * pBuf; + QSPREC * pPrec = ( ULONG ) pGrec + sizeof( QSGREC ); + QSTREC * pTrec = pPrec->pThrdRec; - if ( rc == NO_ERROR ) { - - pGrec = * pBuf; - pPrec = (ULONG) pGrec + sizeof( QSGREC ); - pTrec = pPrec->pThrdRec; - - for ( i = 0; i < pPrec->cTCB; i++, pTrec++ ) { + int i; + for( i = 0; i < pPrec->cTCB; i++, pTrec++ ) + { if( n & 1 ) d += pTrec->usertime; - + if( n & 2 ) d += pTrec->systime; } - d = d * 10.0 / timer_interval; + d = d * 10.0 / s_timer_interval; } - free( pBuf ); - - } else + hb_xfree( pBuf ); + } + else #endif { /* TODO: this code is only for DOS and other platforms which cannot calculate process time */ - printf( "non qui!\r\n"); if( n & 1 ) - d = hb_dateSeconds( ); + d = hb_dateSeconds(); } #endif return d;