VirtualBox

Changeset 101973 in vbox for trunk/src


Ignore:
Timestamp:
Nov 8, 2023 1:20:54 PM (16 months ago)
Author:
vboxsync
Message:

libs/xpcom: Remove some hopefully not used code (localtime_r should be available on the platforms we care about), bugref:10545 [revert]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prtime.c

    r101972 r101973  
    4545#include "prinit.h"
    4646#include "prtime.h"
     47#include "prlock.h"
    4748#include "prprf.h"
    4849#include "prlog.h"
     
    553554
    554555#else
    555 # error "VBox: Not supported"
     556
     557static PRLock *monitor = NULL;
     558
     559static struct tm *MT_safe_localtime(const time_t *clock, struct tm *result)
     560{
     561    struct tm *tmPtr;
     562    int needLock = PR_Initialized();  /* We need to use a lock to protect
     563                                       * against NSPR threads only when the
     564                                       * NSPR thread system is activated. */
     565
     566    if (needLock) {
     567        if (monitor == NULL) {
     568            monitor = PR_NewLock();
     569        }
     570        PR_Lock(monitor);
     571    }
     572
     573    /*
     574     * Microsoft (all flavors) localtime() returns a NULL pointer if 'clock'
     575     * represents a time before midnight January 1, 1970.  In
     576     * that case, we also return a NULL pointer and the struct tm
     577     * object pointed to by 'result' is not modified.
     578     *
     579     * Watcom C/C++ 11.0 localtime() treats time_t as unsigned long
     580     * hence, does not recognize negative values of clock as pre-1/1/70.
     581     * We have to manually check (WIN16 only) for negative value of
     582     * clock and return NULL.
     583     *
     584     * With negative values of clock, emx returns the struct tm for
     585     * clock plus ULONG_MAX. So we also have to check for the invalid
     586     * structs returned for timezones west of Greenwich when clock == 0.
     587     */
     588   
     589    tmPtr = localtime(clock);
     590    if (tmPtr) {
     591        *result = *tmPtr;
     592    } else {
     593        result = NULL;
     594    }
     595    if (needLock) PR_Unlock(monitor);
     596
     597    return result;
     598}
     599
    556600#endif  /* definition of MT_safe_localtime() */
    557601
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette