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

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

Issue 545125: Initial Solaris support (Closed)
Patch Set: Fixed comments, simplified platform-solaris Created 10 years, 11 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
« no previous file with comments | « src/platform-openbsd.cc ('k') | src/platform-solaris.cc » ('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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 int64_t OS::Ticks() { 93 int64_t OS::Ticks() {
94 // gettimeofday has microsecond resolution. 94 // gettimeofday has microsecond resolution.
95 struct timeval tv; 95 struct timeval tv;
96 if (gettimeofday(&tv, NULL) < 0) 96 if (gettimeofday(&tv, NULL) < 0)
97 return 0; 97 return 0;
98 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; 98 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec;
99 } 99 }
100 100
101 101
102 const char* OS::LocalTimezone(double time) {
103 if (isnan(time)) return "";
104 time_t tv = static_cast<time_t>(floor(time/msPerSecond));
105 struct tm* t = localtime(&tv);
106 if (NULL == t) return "";
107 return t->tm_zone;
108 }
109
110
111 double OS::DaylightSavingsOffset(double time) { 102 double OS::DaylightSavingsOffset(double time) {
112 if (isnan(time)) return nan_value(); 103 if (isnan(time)) return nan_value();
113 time_t tv = static_cast<time_t>(floor(time/msPerSecond)); 104 time_t tv = static_cast<time_t>(floor(time/msPerSecond));
114 struct tm* t = localtime(&tv); 105 struct tm* t = localtime(&tv);
115 if (NULL == t) return nan_value(); 106 if (NULL == t) return nan_value();
116 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0; 107 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0;
117 } 108 }
118 109
119 110
120 double OS::LocalTimeOffset() {
121 time_t tv = time(NULL);
122 struct tm* t = localtime(&tv);
123 // tm_gmtoff includes any daylight savings offset, so subtract it.
124 return static_cast<double>(t->tm_gmtoff * msPerSecond -
125 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0));
126 }
127
128
129 // ---------------------------------------------------------------------------- 111 // ----------------------------------------------------------------------------
130 // POSIX stdio support. 112 // POSIX stdio support.
131 // 113 //
132 114
133 FILE* OS::FOpen(const char* path, const char* mode) { 115 FILE* OS::FOpen(const char* path, const char* mode) {
134 return fopen(path, mode); 116 return fopen(path, mode);
135 } 117 }
136 118
137 119
138 const char* OS::LogFileOpenMode = "w"; 120 const char* OS::LogFileOpenMode = "w";
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 return ntohl(value); 353 return ntohl(value);
372 } 354 }
373 355
374 356
375 Socket* OS::CreateSocket() { 357 Socket* OS::CreateSocket() {
376 return new POSIXSocket(); 358 return new POSIXSocket();
377 } 359 }
378 360
379 361
380 } } // namespace v8::internal 362 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-openbsd.cc ('k') | src/platform-solaris.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698