Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1136)

Unified Diff: ports/glibc-compat/src/timegm.c

Issue 1260083004: Add needed functions to glibc-compat for pkg (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+}

Powered by Google App Engine
This is Rietveld 408576698