Mercurial > hg > truffle
comparison src/share/vm/runtime/os.cpp @ 548:773234c55e8c
6800586: -XX:+PrintGCDateStamps is using mt-unsafe localtime function
Summary: replaced localtime() with localtime_r() on Solaris and Linux.
Reviewed-by: apetrusenko, dholmes, jmasa
author | ysr |
---|---|
date | Mon, 09 Feb 2009 12:26:05 -0800 |
parents | 24fda36852ce |
children | 0fbdb4381b99 98cb887364d3 c6c601a0f2d6 |
comparison
equal
deleted
inserted
replaced
547:1e458753107d | 548:773234c55e8c |
---|---|
72 const time_t seconds_since_19700101 = | 72 const time_t seconds_since_19700101 = |
73 milliseconds_since_19700101 / milliseconds_per_microsecond; | 73 milliseconds_since_19700101 / milliseconds_per_microsecond; |
74 const int milliseconds_after_second = | 74 const int milliseconds_after_second = |
75 milliseconds_since_19700101 % milliseconds_per_microsecond; | 75 milliseconds_since_19700101 % milliseconds_per_microsecond; |
76 // Convert the time value to a tm and timezone variable | 76 // Convert the time value to a tm and timezone variable |
77 const struct tm *time_struct_temp = localtime(&seconds_since_19700101); | 77 struct tm time_struct; |
78 if (time_struct_temp == NULL) { | 78 if (localtime_pd(&seconds_since_19700101, &time_struct) == NULL) { |
79 assert(false, "Failed localtime"); | 79 assert(false, "Failed localtime_pd"); |
80 return NULL; | 80 return NULL; |
81 } | 81 } |
82 // Save the results of localtime | |
83 const struct tm time_struct = *time_struct_temp; | |
84 const time_t zone = timezone; | 82 const time_t zone = timezone; |
85 | 83 |
86 // If daylight savings time is in effect, | 84 // If daylight savings time is in effect, |
87 // we are 1 hour East of our time zone | 85 // we are 1 hour East of our time zone |
88 const time_t seconds_per_minute = 60; | 86 const time_t seconds_per_minute = 60; |
91 time_t UTC_to_local = zone; | 89 time_t UTC_to_local = zone; |
92 if (time_struct.tm_isdst > 0) { | 90 if (time_struct.tm_isdst > 0) { |
93 UTC_to_local = UTC_to_local - seconds_per_hour; | 91 UTC_to_local = UTC_to_local - seconds_per_hour; |
94 } | 92 } |
95 // Compute the time zone offset. | 93 // Compute the time zone offset. |
96 // localtime(3C) sets timezone to the difference (in seconds) | 94 // localtime_pd() sets timezone to the difference (in seconds) |
97 // between UTC and and local time. | 95 // between UTC and and local time. |
98 // ISO 8601 says we need the difference between local time and UTC, | 96 // ISO 8601 says we need the difference between local time and UTC, |
99 // we change the sign of the localtime(3C) result. | 97 // we change the sign of the localtime_pd() result. |
100 const time_t local_to_UTC = -(UTC_to_local); | 98 const time_t local_to_UTC = -(UTC_to_local); |
101 // Then we have to figure out if if we are ahead (+) or behind (-) UTC. | 99 // Then we have to figure out if if we are ahead (+) or behind (-) UTC. |
102 char sign_local_to_UTC = '+'; | 100 char sign_local_to_UTC = '+'; |
103 time_t abs_local_to_UTC = local_to_UTC; | 101 time_t abs_local_to_UTC = local_to_UTC; |
104 if (local_to_UTC < 0) { | 102 if (local_to_UTC < 0) { |