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

Side by Side Diff: src/platform-posix.cc

Issue 160580: Add safe handling of NaN to Posix platform-dependent time functions. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/date-delay.js ('k') | test/mjsunit/regress/regress-416.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 int64_t OS::Ticks() { 80 int64_t OS::Ticks() {
81 // gettimeofday has microsecond resolution. 81 // gettimeofday has microsecond resolution.
82 struct timeval tv; 82 struct timeval tv;
83 if (gettimeofday(&tv, NULL) < 0) 83 if (gettimeofday(&tv, NULL) < 0)
84 return 0; 84 return 0;
85 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; 85 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec;
86 } 86 }
87 87
88 88
89 const char* OS::LocalTimezone(double time) { 89 const char* OS::LocalTimezone(double time) {
90 ASSERT(!isnan(time)); 90 if (isnan(time)) return "";
91 time_t tv = static_cast<time_t>(floor(time/msPerSecond)); 91 time_t tv = static_cast<time_t>(floor(time/msPerSecond));
92 struct tm* t = localtime(&tv); 92 struct tm* t = localtime(&tv);
93 if (NULL == t) return ""; 93 if (NULL == t) return "";
94 return t->tm_zone; 94 return t->tm_zone;
95 } 95 }
96 96
97 97
98 double OS::DaylightSavingsOffset(double time) { 98 double OS::DaylightSavingsOffset(double time) {
99 ASSERT(!isnan(time)); 99 if (isnan(time)) return nan_value();
100 time_t tv = static_cast<time_t>(floor(time/msPerSecond)); 100 time_t tv = static_cast<time_t>(floor(time/msPerSecond));
101 struct tm* t = localtime(&tv); 101 struct tm* t = localtime(&tv);
102 if (NULL == t) return nan_value(); 102 if (NULL == t) return nan_value();
103 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0; 103 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0;
104 } 104 }
105 105
106 106
107 double OS::LocalTimeOffset() { 107 double OS::LocalTimeOffset() {
108 time_t tv = time(NULL); 108 time_t tv = time(NULL);
109 struct tm* t = localtime(&tv); 109 struct tm* t = localtime(&tv);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 return ntohl(value); 358 return ntohl(value);
359 } 359 }
360 360
361 361
362 Socket* OS::CreateSocket() { 362 Socket* OS::CreateSocket() {
363 return new POSIXSocket(); 363 return new POSIXSocket();
364 } 364 }
365 365
366 366
367 } } // namespace v8::internal 367 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/date-delay.js ('k') | test/mjsunit/regress/regress-416.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698