Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / btls / btls-util.c
index 824b101f34c50ed68b88fd0e804a050ed7add745..57fa0fa7813138b5db9ff7422763aa48ac8810d7 100644 (file)
@@ -8,32 +8,39 @@
 
 #include <btls-util.h>
 #include <assert.h>
-#include <time.h>
-
-#if defined(__ANDROID__) && !defined(__LP64__)
-#include <time64.h>
-extern time_t timegm (struct tm* const t);
-#endif
+// #include <time.h>
 
 extern int asn1_generalizedtime_to_tm (struct tm *tm, const ASN1_GENERALIZEDTIME *d);
 
+extern int64_t btls_timegm64 (const struct tm *date);
+
+
 MONO_API void
 mono_btls_free (void *data)
 {
        OPENSSL_free (data);
 }
 
-long
+int64_t
 mono_btls_util_asn1_time_to_ticks (ASN1_TIME *time)
 {
        ASN1_GENERALIZEDTIME *gtime;
        struct tm tm;
-       time_t epoch;
+       int64_t epoch;
+       int ret;
+       
+       memset (&tm, 0, sizeof (tm));
 
        gtime = ASN1_TIME_to_generalizedtime (time, NULL);
-       asn1_generalizedtime_to_tm (&tm, gtime);
+       ret = asn1_generalizedtime_to_tm (&tm, gtime);
        ASN1_GENERALIZEDTIME_free (gtime);
-       epoch = timegm(&tm);
+
+       /* FIXME: check the return value in managed code */
+       if (ret == 0) {
+               return 0;
+       }
+
+       epoch = btls_timegm64 (&tm);
 
        return epoch;
 }