Diff
Not logged in

Differences From Artifact [2fddb22d7e]:

To Artifact [a396c93935]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* 
 * tclWinTime.c --
 *
 *	Contains Windows specific versions of Tcl functions that
 *	obtain time values from the operating system.
 *
 * Copyright 1995-1998 by Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinTime.c,v 1.18 2003/05/18 19:48:27 kennykb Exp $
 */

#include "tclWinInt.h"

#define SECSPERDAY (60L * 60L * 24L)
#define SECSPERYEAR (SECSPERDAY * 365L)
#define SECSPER4YEAR (SECSPERYEAR * 4L + SECSPERDAY)











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* 
 * tclWinTime.c --
 *
 *	Contains Windows specific versions of Tcl functions that
 *	obtain time values from the operating system.
 *
 * Copyright 1995-1998 by Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinTime.c,v 1.18.2.1 2003/06/18 19:48:04 dgp Exp $
 */

#include "tclWinInt.h"

#define SECSPERDAY (60L * 60L * 24L)
#define SECSPERYEAR (SECSPERDAY * 365L)
#define SECSPER4YEAR (SECSPERYEAR * 4L + SECSPERDAY)
344
345
346
347
348
349
350
351

352
353
354
355
356
357
358
		Tcl_CreateExitHandler( StopCalibration, (ClientData) NULL );
	    }
	    timeInfo.initialized = TRUE;
	}
	TclpInitUnlock();
    }

    if ( timeInfo.perfCounterAvailable ) {

	
	/*
	 * Query the performance counter and use it to calculate the
	 * current time.
	 */

	LARGE_INTEGER curCounter;







|
>







344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
		Tcl_CreateExitHandler( StopCalibration, (ClientData) NULL );
	    }
	    timeInfo.initialized = TRUE;
	}
	TclpInitUnlock();
    }

    if ( timeInfo.perfCounterAvailable 
		&& timeInfo.curCounterFreq.QuadPart!=0 ) {
	
	/*
	 * Query the performance counter and use it to calculate the
	 * current time.
	 */

	LARGE_INTEGER curCounter;
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
 *
 * TclpGetTZName --
 *
 *	Gets the current timezone string.
 *
 * Results:
 *	Returns a pointer to a static string, or NULL on failure.
 *	Return value is in UTF-8 encoding
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */








<







446
447
448
449
450
451
452

453
454
455
456
457
458
459
 *
 * TclpGetTZName --
 *
 *	Gets the current timezone string.
 *
 * Results:
 *	Returns a pointer to a static string, or NULL on failure.

 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
     * initialization lock.
     */

    SetEvent( timeInfo.readyEvent );

    /* Run the calibration once a second */

    for ( ; ; ) {

	/* If the exitEvent is set, break out of the loop. */

	waitResult = WaitForSingleObjectEx(timeInfo.exitEvent, 1000, FALSE);
	if ( waitResult == WAIT_OBJECT_0 ) {
	    break;
	}







|







781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
     * initialization lock.
     */

    SetEvent( timeInfo.readyEvent );

    /* Run the calibration once a second */

    while (timeInfo.perfCounterAvailable) {

	/* If the exitEvent is set, break out of the loop. */

	waitResult = WaitForSingleObjectEx(timeInfo.exitEvent, 1000, FALSE);
	if ( waitResult == WAIT_OBJECT_0 ) {
	    break;
	}
850
851
852
853
854
855
856
















857
858
859
860
861
862
863

    QueryPerformanceCounter( &curPerfCounter );
    GetSystemTimeAsFileTime( &curSysTime );
    curFileTime.LowPart = curSysTime.dwLowDateTime;
    curFileTime.HighPart = curSysTime.dwHighDateTime;

    EnterCriticalSection( &timeInfo.cs );

















    /*
     * Several things may have gone wrong here that have to
     * be checked for.
     * (1) The performance counter may have jumped.
     * (2) The system clock may have been reset.
     *







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879

    QueryPerformanceCounter( &curPerfCounter );
    GetSystemTimeAsFileTime( &curSysTime );
    curFileTime.LowPart = curSysTime.dwLowDateTime;
    curFileTime.HighPart = curSysTime.dwHighDateTime;

    EnterCriticalSection( &timeInfo.cs );

    /*
     * We devide by timeInfo.curCounterFreq.QuadPart in several places.
     * That value should always be positive on a correctly functioning
     * system.  But it is good to be defensive about such matters.
     * So if something goes wrong and the value does goes to zero, we
     * clear the timeInfo.perfCounterAvailable in order to cause the
     * calibration thread to shut itself down, then return without additional
     * processing.
     */

    if( timeInfo.curCounterFreq.QuadPart==0 ){
	LeaveCriticalSection( &timeInfo.cs );
	timeInfo.perfCounterAvailable = 0;
	return;
    }

    /*
     * Several things may have gone wrong here that have to
     * be checked for.
     * (1) The performance counter may have jumped.
     * (2) The system clock may have been reset.
     *