Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
os2inrval.c File Reference
#include "primpl.h"

Go to the source code of this file.

Functions

void _PR_MD_INTERVAL_INIT ()
PRIntervalTime _PR_MD_GET_INTERVAL ()
PRIntervalTime _PR_MD_INTERVAL_PER_SEC ()

Variables

static PRBool useHighResTimer = PR_FALSE
PRIntervalTime _os2_ticksPerSec = -1
PRIntn _os2_bitShift = 0
PRInt32 _os2_highMask = 0

Function Documentation

Definition at line 79 of file os2inrval.c.

{
    if (useHighResTimer) {
        QWORD timestamp;
        PRInt32 top;
        APIRET rc = DosTmrQueryTime(&timestamp);
        if (NO_ERROR != rc) {
            return -1;
        }
        /* Sadly, nspr requires the interval to range from 1000 ticks per
         * second to only 100000 ticks per second. DosTmrQueryTime is too
         * high resolution...
         */
        top = timestamp.ulHi & _os2_highMask;
        top = top << (32 - _os2_bitShift);
        timestamp.ulLo = timestamp.ulLo >> _os2_bitShift;   
        timestamp.ulLo = timestamp.ulLo + top; 
        return (PRUint32)timestamp.ulLo;
    } else {
        ULONG msCount = -1;
        DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &msCount, sizeof(msCount));
        return msCount;
    }
}

Definition at line 51 of file os2inrval.c.

{
    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;
        }

        _os2_ticksPerSec = timerFreq;
        PR_ASSERT(_os2_ticksPerSec > PR_INTERVAL_MIN);
    }
}

Definition at line 105 of file os2inrval.c.

{
    if (useHighResTimer) {
        return _os2_ticksPerSec;
    } else {
        return 1000;
    }
}

Variable Documentation

PRIntn _os2_bitShift = 0

Definition at line 47 of file os2inrval.c.

Definition at line 48 of file os2inrval.c.

Definition at line 46 of file os2inrval.c.

Definition at line 45 of file os2inrval.c.