From: Ivailo Monev Date: Wed, 25 Nov 2020 15:38:59 +0000 (+0000) Subject: check for timegm(), tm.tm_gmtoff and tm.tm_zone during build X-Git-Tag: 4.12.0~3286 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=57c9842eba3f95ea90acc63cc5df9572314ec9fd;p=kde%2FKatie.git check for timegm(), tm.tm_gmtoff and tm.tm_zone during build Signed-off-by: Ivailo Monev --- diff --git a/CMakeLists.txt b/CMakeLists.txt index fbb16718a..9fe15af64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -379,6 +379,9 @@ katie_check_function(pthread_attr_get_np "pthread_np.h") katie_check_function(get_current_dir_name "unistd.h") katie_check_function(prctl "sys/prctl.h") katie_check_function(pthread_setname_np "pthread.h" "${CMAKE_THREAD_LIBS_INIT}") +katie_check_function(timegm "time.h") +katie_check_struct(tm tm_gmtoff "time.h") +katie_check_struct(tm tm_zone "time.h") # ISO/IEC 9899:1999 katie_check_function(fegetenv "fenv.h") katie_check_function(fesetenv "fenv.h") diff --git a/src/3rdparty/javascriptcore/runtime/JSArray.cpp b/src/3rdparty/javascriptcore/runtime/JSArray.cpp index 7aa2a6e32..adc52b3d5 100644 --- a/src/3rdparty/javascriptcore/runtime/JSArray.cpp +++ b/src/3rdparty/javascriptcore/runtime/JSArray.cpp @@ -728,13 +728,9 @@ void JSArray::sort(ExecState* exec) // FIXME: Since we sort by string value, a fast algorithm might be to use a radix sort. That would be O(N) rather // than O(N log N). -#if HAVE(MERGESORT) - mergesort(values.begin(), values.size(), sizeof(ValueStringPair), compareByStringPairForQSort); -#else // FIXME: The qsort library function is likely to not be a stable sort. // ECMAScript-262 does not specify a stable sort, but in practice, browsers perform a stable sort. qsort(values.begin(), values.size(), sizeof(ValueStringPair), compareByStringPairForQSort); -#endif // FIXME: If the toString function changed the length of the array, this might be // modifying the vector incorrectly. diff --git a/src/3rdparty/javascriptcore/wtf/DateMath.cpp b/src/3rdparty/javascriptcore/wtf/DateMath.cpp index 80b27ef8c..2fb6fd528 100644 --- a/src/3rdparty/javascriptcore/wtf/DateMath.cpp +++ b/src/3rdparty/javascriptcore/wtf/DateMath.cpp @@ -349,12 +349,11 @@ int equivalentYearForDST(int year) return year; } -#if !HAVE(TM_GMTOFF) - +#if !defined(QT_HAVE_TM_TM_GMTOFF) static int32_t calculateUTCOffset() { time_t localTime = ::time(0); - tm localt; + struct tm localt; getLocalTime(&localTime, &localt); // Get the difference between this time zone and UTC on the 1st of January of this year. @@ -367,14 +366,14 @@ static int32_t calculateUTCOffset() localt.tm_wday = 0; localt.tm_yday = 0; localt.tm_isdst = 0; -#if HAVE(TM_GMTOFF) +#if defined(QT_HAVE_TM_TM_GMTOFF) localt.tm_gmtoff = 0; #endif -#if HAVE(TM_ZONE) +#if defined(QT_HAVE_TM_TM_ZONE) localt.tm_zone = 0; #endif -#if HAVE(TIMEGM) +#if defined(QT_HAVE_TIMEGM) time_t utcOffset = ::timegm(&localt) - ::mktime(&localt); #else // Using a canned date of 01/01/2009 on platforms with weaker date-handling foo. @@ -397,7 +396,7 @@ static double calculateDSTOffset(time_t localTime, double utcOffset) int offsetHour = msToHours(offsetTime); int offsetMinute = msToMinutes(offsetTime); - tm localTM; + struct tm localTM; getLocalTime(&localTime, &localTM); double diff = ((localTM.tm_hour - offsetHour) * secondsPerHour) + ((localTM.tm_min - offsetMinute) * 60); @@ -407,8 +406,7 @@ static double calculateDSTOffset(time_t localTime, double utcOffset) return (diff * msPerSecond); } - -#endif +#endif // !QT_HAVE_TM_TM_GMTOFF // Returns combined offset in millisecond (UTC + DST). LocalTimeOffset calculateLocalTimeOffset(double ms) @@ -437,8 +435,8 @@ LocalTimeOffset calculateLocalTimeOffset(double ms) // FIXME: time_t has a potential problem in 2038. time_t localTime = static_cast(localTimeSeconds); -#if HAVE(TM_GMTOFF) - tm localTM; +#if defined(QT_HAVE_TM_TM_GMTOFF) + struct tm localTM; getLocalTime(&localTime, &localTM); return LocalTimeOffset(localTM.tm_isdst, localTM.tm_gmtoff * msPerSecond); #else diff --git a/src/3rdparty/javascriptcore/wtf/DateMath.h b/src/3rdparty/javascriptcore/wtf/DateMath.h index 9599fa75c..6e1fcf1c1 100644 --- a/src/3rdparty/javascriptcore/wtf/DateMath.h +++ b/src/3rdparty/javascriptcore/wtf/DateMath.h @@ -161,8 +161,8 @@ struct GregorianDateTime : Noncopyable { operator tm() const { - tm ret; - memset(&ret, 0, sizeof(ret)); + struct tm ret; + ::memset(&ret, 0, sizeof(ret)); ret.tm_sec = second; ret.tm_min = minute; @@ -174,10 +174,10 @@ struct GregorianDateTime : Noncopyable { ret.tm_year = year; ret.tm_isdst = isDST; -#if HAVE(TM_GMTOFF) +#if defined(QT_HAVE_TM_TM_GMTOFF) ret.tm_gmtoff = static_cast(utcOffset); #endif -#if HAVE(TM_ZONE) +#if defined(QT_HAVE_TM_TM_ZONE) ret.tm_zone = timeZone; #endif diff --git a/src/3rdparty/javascriptcore/wtf/Platform.h b/src/3rdparty/javascriptcore/wtf/Platform.h index e22eb2dfa..10ffb6d4b 100644 --- a/src/3rdparty/javascriptcore/wtf/Platform.h +++ b/src/3rdparty/javascriptcore/wtf/Platform.h @@ -31,11 +31,6 @@ QT_USE_NAMESPACE -/* ==== Platform adaptation macros: these describe properties of the target environment. ==== */ - -/* HAVE() - specific system features (headers, functions or similar) that are present or not */ -#define HAVE(WTF_FEATURE) (defined HAVE_##WTF_FEATURE && HAVE_##WTF_FEATURE) - /* ==== Policy decision macros: these define policy choices for a particular port. ==== */ /* USE() - use a particular third-party library or optional OS service */ @@ -43,14 +38,6 @@ QT_USE_NAMESPACE /* ENABLE() - turn on a specific feature of WebKit */ #define ENABLE(WTF_FEATURE) (defined ENABLE_##WTF_FEATURE && ENABLE_##WTF_FEATURE) -/* Operating environments */ - -#if !defined(Q_OS_SOLARIS) -#define HAVE_TM_GMTOFF 1 -#define HAVE_TM_ZONE 1 -#define HAVE_TIMEGM 1 -#endif - /* ENABLE macro defaults */ #define ENABLE_OPCODE_STATS 0