13 #include <sys/resource.h> 15 #include <sys/ucontext.h> 24 #include <sys/types.h> 31 #include "src/base/macros.h" 32 #include "src/base/platform/platform-posix.h" 33 #include "src/base/platform/platform.h" 40 const char* LocalTimezone(
double time)
override;
42 double LocalTimeOffset(
double time_ms,
bool is_utc)
override;
47 const char* AIXTimezoneCache::LocalTimezone(
double time_ms) {
48 if (std::isnan(time_ms))
return "";
49 time_t tv =
static_cast<time_t
>(floor(time_ms / msPerSecond));
51 struct tm* t = localtime_r(&tv, &tm);
52 if (
nullptr == t)
return "";
56 double AIXTimezoneCache::LocalTimeOffset(
double time_ms,
bool is_utc) {
58 time_t utc = time(
nullptr);
61 struct tm* loc = localtime_r(&utc, &tm);
63 return static_cast<double>((mktime(loc) - utc) * msPerSecond);
66 TimezoneCache* OS::CreateTimezoneCache() {
return new AIXTimezoneCache(); }
68 static unsigned StringToLong(
char* buffer) {
69 return static_cast<unsigned>(strtol(buffer,
nullptr, 16));
72 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
73 std::vector<SharedLibraryAddress> result;
74 static const int MAP_LENGTH = 1024;
75 int fd = open(
"/proc/self/maps", O_RDONLY);
76 if (fd < 0)
return result;
82 ssize_t rc = read(fd, addr_buffer + 2, 8);
84 unsigned start = StringToLong(addr_buffer);
85 rc = read(fd, addr_buffer + 2, 1);
87 if (addr_buffer[2] !=
'-')
break;
88 rc = read(fd, addr_buffer + 2, 8);
90 unsigned end = StringToLong(addr_buffer);
91 char buffer[MAP_LENGTH];
95 if (bytes_read >= MAP_LENGTH - 1)
break;
96 rc = read(fd, buffer + bytes_read, 1);
98 }
while (buffer[bytes_read] !=
'\n');
99 buffer[bytes_read] = 0;
101 if (buffer[3] !=
'x')
continue;
102 char* start_of_path = index(buffer,
'/');
104 if (start_of_path ==
nullptr)
continue;
105 buffer[bytes_read] = 0;
106 result.push_back(SharedLibraryAddress(start_of_path, start, end));
112 void OS::SignalCodeMovingGC() {}