Fix Alpine 3.13 ARM build (#50105)
authorJan Vorlicek <jan.vorlicek@volny.cz>
Wed, 24 Mar 2021 14:31:24 +0000 (15:31 +0100)
committerGitHub <noreply@github.com>
Wed, 24 Mar 2021 14:31:24 +0000 (15:31 +0100)
* Fix Alpine 3.13 ARM build

Alpine 3.13 is the first version of Alpine Linux that uses 64 bit time_t
on both 64 and 32 bit platforms. That breaks the build as we assumed
that 32 bit platforms use always 32 bit time_t.

This change fixes it by making the PAL time_t type always 64 bit.
Everything still works fine on non-Alpine ARM / x86 Linuxes, since
it only changes the time_t type size outside of PAL.

* Fix case when time function gets NULL argument

src/coreclr/pal/inc/pal.h
src/coreclr/pal/src/cruntime/misc.cpp
src/libraries/Native/Unix/System.Native/pal_random.c

index 05e1deb..2f42a2c 100644 (file)
@@ -324,11 +324,7 @@ PAL_IsDebuggerPresent();
 
 #ifndef PAL_STDCPP_COMPAT
 
-#if HOST_64BIT || _MSC_VER >= 1400
 typedef __int64 time_t;
-#else
-typedef long time_t;
-#endif
 #define _TIME_T_DEFINED
 #endif // !PAL_STDCPP_COMPAT
 
index 4ba36c6..7a2690f 100644 (file)
@@ -172,7 +172,12 @@ PAL_time(PAL_time_t *tloc)
     PERF_ENTRY(time);
     ENTRY( "time( tloc=%p )\n",tloc );
 
-    result = time(tloc);
+    time_t t;
+    result = time(&t);
+    if (tloc != NULL)
+    {
+        *tloc = t;
+    }
 
     LOGEXIT( "time returning %#lx\n",result );
     PERF_EXIT(time);
index b824b29..700435a 100644 (file)
@@ -35,7 +35,7 @@ void SystemNative_GetNonCryptographicallySecureRandomBytes(uint8_t* buffer, int3
 
     if (!sInitializedMRand)
     {
-        srand48(time(NULL));
+        srand48((long int)time(NULL));
         sInitializedMRand = true;
     }