OSDN Git Service

check for timegm(), tm.tm_gmtoff and tm.tm_zone during build
authorIvailo Monev <xakepa10@gmail.com>
Wed, 25 Nov 2020 15:38:59 +0000 (15:38 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Wed, 25 Nov 2020 15:45:57 +0000 (15:45 +0000)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
CMakeLists.txt
src/3rdparty/javascriptcore/runtime/JSArray.cpp
src/3rdparty/javascriptcore/wtf/DateMath.cpp
src/3rdparty/javascriptcore/wtf/DateMath.h
src/3rdparty/javascriptcore/wtf/Platform.h

index fbb1671..9fe15af 100644 (file)
@@ -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")
index 7aa2a6e..adc52b3 100644 (file)
@@ -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.
index 80b27ef..2fb6fd5 100644 (file)
@@ -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<time_t>(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
index 9599fa7..6e1fcf1 100644 (file)
@@ -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<long>(utcOffset);
 #endif
-#if HAVE(TM_ZONE)
+#if defined(QT_HAVE_TM_TM_ZONE)
         ret.tm_zone = timeZone;
 #endif
 
index e22eb2d..10ffb6d 100644 (file)
 
 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