OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_OS_H_ | 5 #ifndef VM_OS_H_ |
6 #define VM_OS_H_ | 6 #define VM_OS_H_ |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 | 9 |
| 10 // Forward declarations. |
| 11 class tm; |
| 12 |
10 namespace dart { | 13 namespace dart { |
11 | 14 |
12 // Forward declarations. | 15 // Forward declarations. |
13 class Isolate; | 16 class Isolate; |
14 | 17 |
15 // Interface to the underlying OS platform. | 18 // Interface to the underlying OS platform. |
16 class OS { | 19 class OS { |
17 public: | 20 public: |
18 typedef struct BrokenDownDate { | 21 // Takes the seconds since epoch (midnight, January 1, 1970 UTC) and breaks it |
19 int year; // Offset by 1900. A value of 111 Represents the year 2011. | 22 // down into date and time in the UTC timezone. |
20 int month; // [0..11] | 23 // The returned year is offset by 1900. The returned month is 0-based. |
21 int day; // [1..31] | 24 // Returns true if the conversion succeeds, false otherwise. |
22 int hours; | 25 static bool GmTime(int64_t seconds_since_epoch, tm* tm_result); |
23 int minutes; | |
24 int seconds; | |
25 } BrokenDownDate; | |
26 | 26 |
27 // Takes the seconds since epoch (midnight, January 1, 1970 UTC) and breaks it | 27 // Takes the seconds since epoch (midnight, January 1, 1970 UTC) and breaks it |
28 // down into date and time. | 28 // down into date and time in the local time. |
29 // If 'inUtc', then the broken down date and time are in the UTC timezone, | |
30 // otherwise the local timezone is used. | |
31 // The returned year is offset by 1900. The returned month is 0-based. | 29 // The returned year is offset by 1900. The returned month is 0-based. |
32 // Returns true if the conversion succeeds, false otherwise. | 30 // Returns true if the conversion succeeds, false otherwise. |
33 static bool BreakDownSecondsSinceEpoch(time_t seconds_since_epoch, | 31 static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result); |
34 bool in_utc, | |
35 BrokenDownDate* result); | |
36 | 32 |
37 // Converts a broken down date into the seconds since epoch (midnight, | 33 // Takes the broken down date and time in UTC timezone and computes the |
38 // January 1, 1970 UTC). Returns true if the conversion succeeds, false | 34 // seconds since epoch (midnight, January 1, 1970 UTC). |
39 // otherwise. | 35 // The given year is offset by 1900. The given month is 0-based. |
40 static bool BrokenDownToSecondsSinceEpoch( | 36 // Returns true if the conversion succeeds, false otherwise. |
41 const BrokenDownDate& broken_down, bool in_utc, time_t* result); | 37 static bool MkGmTime(tm* tm, int64_t* seconds_result); |
| 38 |
| 39 // Takes the broken down date and time in local timezone and computes the |
| 40 // seconds since epoch (midnight, January 1, 1970 UTC). |
| 41 // The given year is offset by 1900. The given month is 0-based. |
| 42 // Returns true if the conversion succeeds, false otherwise. |
| 43 static bool MkTime(tm* tm, int64_t* seconds_result); |
42 | 44 |
43 // Returns the current time in milliseconds measured | 45 // Returns the current time in milliseconds measured |
44 // from midnight January 1, 1970 UTC. | 46 // from midnight January 1, 1970 UTC. |
45 static int64_t GetCurrentTimeMillis(); | 47 static int64_t GetCurrentTimeMillis(); |
46 | 48 |
47 // Returns the current time in microseconds measured | 49 // Returns the current time in microseconds measured |
48 // from midnight January 1, 1970 UTC. | 50 // from midnight January 1, 1970 UTC. |
49 static int64_t GetCurrentTimeMicros(); | 51 static int64_t GetCurrentTimeMicros(); |
50 | 52 |
51 // Returns the activation frame alignment constraint or zero if | 53 // Returns the activation frame alignment constraint or zero if |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 static void Shutdown(); | 97 static void Shutdown(); |
96 | 98 |
97 static void Abort(); | 99 static void Abort(); |
98 | 100 |
99 static void Exit(int code); | 101 static void Exit(int code); |
100 }; | 102 }; |
101 | 103 |
102 } // namespace dart | 104 } // namespace dart |
103 | 105 |
104 #endif // VM_OS_H_ | 106 #endif // VM_OS_H_ |
OLD | NEW |