os_compat_nacl.cc 587 B

123456789101112131415161718192021222324252627282930
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "base/os_compat_nacl.h"
  5. #include <stdlib.h>
  6. #include <time.h>
  7. #if !defined (__GLIBC__)
  8. extern "C" {
  9. // Native Client has no timegm().
  10. time_t timegm(struct tm* tm) {
  11. time_t ret;
  12. char* tz;
  13. tz = getenv("TZ");
  14. setenv("TZ", "", 1);
  15. tzset();
  16. ret = mktime(tm);
  17. if (tz)
  18. setenv("TZ", tz, 1);
  19. else
  20. unsetenv("TZ");
  21. tzset();
  22. return ret;
  23. }
  24. } // extern "C"
  25. #endif // !defined (__GLIBC__)