Commit e3b49dc7 authored by wtchang%redhat.com's avatar wtchang%redhat.com
Browse files

Bugzilla Bug 291724: removed the workaround for a very old Windows NT 4.0

bug. The workaround modified _tzset related global variables in Microsoft
CRT directly and relied on undocumented properties of the buffers that
_tzname[0] and _tzname[1] point to.  r=darin.
Modified files: ntmisc.c ntthread.c w95thred.c
parent 2b44c9a3
Loading
Loading
Loading
Loading
+1 −68
Original line number Diff line number Diff line
@@ -68,8 +68,6 @@ PRIntn _PR_MD_PUT_ENV(const char *name)
 **************************************************************************
 */

#include <sys/timeb.h>

/*
 *-----------------------------------------------------------------------
 *
@@ -95,71 +93,6 @@ PR_Now(void)
    return prt;       
}

/*
 * The following code works around a bug in NT (Netscape Bugsplat
 * Defect ID 47942).
 *
 * In Windows NT 3.51 and 4.0, if the local time zone does not practice
 * daylight savings time, e.g., Arizona, Taiwan, and Japan, the global
 * variables that _ftime() and localtime() depend on have the wrong
 * default values:
 *     _tzname[0]  "PST"
 *     _tzname[1]  "PDT"
 *     _daylight   1
 *     _timezone   28800
 *
 * So at startup time, we need to invoke _PR_Win32InitTimeZone(), which
 * on NT sets these global variables to the correct values (obtained by
 * calling GetTimeZoneInformation().
 */

#include <time.h>     /* for _tzname, _daylight, _timezone */

void
_PR_Win32InitTimeZone(void)
{
    OSVERSIONINFO version;
    TIME_ZONE_INFORMATION tzinfo;

    version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    if (GetVersionEx(&version) != FALSE) {
        /* Only Windows NT needs this hack */
        if (version.dwPlatformId != VER_PLATFORM_WIN32_NT) {
            return;
        }
    }

    if (GetTimeZoneInformation(&tzinfo) == 0xffffffff) {
        return;  /* not much we can do if this failed */
    }
 
    /* 
     * I feel nervous about modifying these globals.  I hope that no
     * other thread is reading or modifying these globals simultaneously
     * during nspr initialization.
     *
     * I am assuming that _tzname[0] and _tzname[1] point to static buffers
     * and that the buffers are at least 32 byte long.  My experiments show
     * this is true, but of course this is undocumented.  --wtc
     *
     * Convert time zone names from WCHAR to CHAR and copy them to
     * the static buffers pointed to by _tzname[0] and _tzname[1].
     * Ignore conversion errors, because it is _timezone and _daylight
     * that _ftime() and localtime() really depend on.
     */

    WideCharToMultiByte(CP_ACP, 0, tzinfo.StandardName, -1, _tzname[0],
            32, NULL, NULL);
    WideCharToMultiByte(CP_ACP, 0, tzinfo.DaylightName, -1, _tzname[1],
            32, NULL, NULL);

    /* _timezone is in seconds.  tzinfo.Bias is in minutes. */

    _timezone = tzinfo.Bias * 60;
    _daylight = tzinfo.DaylightBias ? 1 : 0;
    return;
}

/*
 ***********************************************************************
 ***********************************************************************
@@ -691,8 +624,8 @@ PRInt32 _MD_GetMemMapAlignment(void)
    return info.dwAllocationGranularity;
}

#include "prlog.h"
extern PRLogModuleInfo *_pr_shma_lm;

void * _MD_MemMap(
    PRFileMap *fmap,
    PROffset64 offset,
+0 −3
Original line number Diff line number Diff line
@@ -38,8 +38,6 @@
#include "primpl.h"
#include <process.h>  /* for _beginthreadex() */

extern void _PR_Win32InitTimeZone(void);  /* defined in ntmisc.c */

/* --- globals ------------------------------------------------ */
PRLock                       *_pr_schedLock = NULL;
_PRInterruptTable             _pr_interruptTable[] = { { 0 } };
@@ -116,7 +114,6 @@ _PR_MD_EARLY_INIT()
    _MD_NEW_LOCK( &_nt_idleLock );
    _nt_idleCount = 0;
    PR_INIT_CLIST(&_nt_idleList);
    _PR_Win32InitTimeZone();

#if 0
    /* Make the clock tick at least once per millisecond */
+0 −4
Original line number Diff line number Diff line
@@ -38,8 +38,6 @@
#include "primpl.h"
#include <process.h>  /* for _beginthreadex() */

extern void _PR_Win32InitTimeZone(void);  /* defined in ntmisc.c */

/* --- globals ------------------------------------------------ */
#ifdef _PR_USE_STATIC_TLS
__declspec(thread) struct PRThread  *_pr_thread_last_run;
@@ -56,8 +54,6 @@ _PRInterruptTable _pr_interruptTable[] = { { 0 } };
void
_PR_MD_EARLY_INIT()
{
    _PR_Win32InitTimeZone();

#ifndef _PR_USE_STATIC_TLS
    _pr_currentThreadIndex = TlsAlloc();
    _pr_lastThreadIndex = TlsAlloc();