Index: ports/glibc-compat/src/timegm.c |
diff --git a/ports/glibc-compat/src/timegm.c b/ports/glibc-compat/src/timegm.c |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0e453ab5edc73196dceda036a93b0d069de3808b |
--- /dev/null |
+++ b/ports/glibc-compat/src/timegm.c |
@@ -0,0 +1,27 @@ |
+/* Copyright 2015 The Native Client Authors. All rights reserved. |
Sam Clegg
2015/07/28 00:14:13
nit: put /* and */ on lines be themselves to match
zhitingzhu
2015/07/28 02:05:41
Done.
|
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. */ |
+// pull from freebsd 10.1 ./contrib/ldns/compat/timegm.c |
+#include <stdio.h> |
+#include <stdlib.h> |
+#include <time.h> |
+ |
+time_t |
+timegm (struct tm *tm) { |
+ time_t ret; |
+ char *tz; |
+ |
+ tz = getenv("TZ"); |
+ putenv((char*)"TZ="); |
+ tzset(); |
+ ret = mktime(tm); |
+ if (tz) { |
+ char buf[256]; |
+ snprintf(buf, sizeof(buf), "TZ=%s", tz); |
+ putenv(tz); |
+ } |
+ else |
+ putenv((char*)"TZ"); |
+ tzset(); |
+ return ret; |
+} |