Bugzilla Bug 277514: added an environment variable NSPR_OS2_NO_HIRES_TIMER NSPRPUB_PRE_4_2_CLIENT_BRANCH
authorwtchang%redhat.com
Tue, 25 Jan 2005 22:26:04 +0000
branchNSPRPUB_PRE_4_2_CLIENT_BRANCH
changeset 3257 67d6d744c0fb559e36c3cd2ae357c85c8caf63b4
parent 3255 d277ae1be3ff6b6ca123c602af82006cfd1a609c
child 3259 387d8892364c2384be6193c713c8ba8bce22ac16
push idunknown
push userunknown
push dateunknown
bugs277514
Bugzilla Bug 277514: added an environment variable NSPR_OS2_NO_HIRES_TIMER that a user can set to disable the use of high-resolution timer DosTmrQueryTime(). The patch is contributed by Michael Kaply <mkaply@us.ibm.com>. r=wtc. Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
pr/src/md/os2/os2inrval.c
--- a/pr/src/md/os2/os2inrval.c
+++ b/pr/src/md/os2/os2inrval.c
@@ -45,18 +45,27 @@
 static PRBool useHighResTimer = PR_FALSE;
 PRIntervalTime _os2_ticksPerSec = -1;
 PRIntn _os2_bitShift = 0;
 PRInt32 _os2_highMask = 0;
    
 void
 _PR_MD_INTERVAL_INIT()
 {
-    ULONG timerFreq = 0; /* OS/2 high-resolution timer frequency in Hz */
-    APIRET rc = DosTmrQueryFreq(&timerFreq);
+    char *envp;
+    ULONG timerFreq;
+    APIRET rc;
+
+    if ((envp = getenv("NSPR_OS2_NO_HIRES_TIMER")) != NULL) {
+        if (atoi(envp) == 1)
+           return;
+    }
+
+    timerFreq = 0; /* OS/2 high-resolution timer frequency in Hz */
+    rc = DosTmrQueryFreq(&timerFreq);
     if (NO_ERROR == rc) {
         useHighResTimer = PR_TRUE;
         PR_ASSERT(timerFreq != 0);
         while (timerFreq > PR_INTERVAL_MAX) {
             timerFreq >>= 1;
             _os2_bitShift++;
             _os2_highMask = (_os2_highMask << 1)+1;
         }