1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Platform-specific code for Solaris 10 goes here. For the POSIX-compatible
6 // parts, the implementation is in platform-posix.cc.
7
8 #ifdef __sparc
9 # error "V8 does not support the SPARC CPU architecture."
10 #endif
11
12 #include <dlfcn.h> // dladdr
13 #include <errno.h>
14 #include <ieeefp.h> // finite()
15 #include <pthread.h>
16 #include <semaphore.h>
17 #include <signal.h> // sigemptyset(), etc
18 #include <sys/mman.h> // mmap()
19 #include <sys/regset.h>
20 #include <sys/stack.h> // for stack alignment
21 #include <sys/time.h> // gettimeofday(), timeradd()
22 #include <time.h>
23 #include <ucontext.h> // walkstack(), getcontext()
24 #include <unistd.h> // getpagesize(), usleep()
25
26 #include <cmath>
27
28 #undef MAP_TYPE
29
30 #include "src/base/macros.h"
31 #include "src/base/platform/platform-posix.h"
32 #include "src/base/platform/platform.h"
33
34 namespace v8 {
35 namespace base {
36
37 class SolarisTimezoneCache : public PosixTimezoneCache {
38 const char* LocalTimezone(double time) override;
39
40 double LocalTimeOffset(double time, bool is_utc) override;
41 ~SolarisTimezoneCache() override {}
42 };
43
LocalTimezone(double time)44 const char* SolarisTimezoneCache::LocalTimezone(double time) {
45 if (std::isnan(time)) return "";
46 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
47 struct tm tm;
48 struct tm* t = localtime_r(&tv, &tm);
49 if (nullptr == t) return "";
50 return tzname[0]; // The location of the timezone string on Solaris.
51 }
52
LocalTimeOffset(double time, bool is_utc)53 double SolarisTimezoneCache::LocalTimeOffset(double time, bool is_utc) {
54 tzset();
55 return -static_cast<double>(timezone * msPerSecond);
56 }
57
CreateTimezoneCache()58 TimezoneCache* OS::CreateTimezoneCache() { return new SolarisTimezoneCache(); }
59
GetSharedLibraryAddresses()60 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
61 return std::vector<SharedLibraryAddress>();
62 }
63
SignalCodeMovingGC()64 void OS::SignalCodeMovingGC() {}
65
AdjustSchedulingParams()66 void OS::AdjustSchedulingParams() {}
67
GetFreeMemoryRangesWithin( OS::Address boundary_start, OS::Address boundary_end, size_t minimum_size, size_t alignment)68 std::vector<OS::MemoryRange> OS::GetFreeMemoryRangesWithin(
69 OS::Address boundary_start, OS::Address boundary_end, size_t minimum_size,
70 size_t alignment) {
71 return {};
72 }
73
74 // static
GetStackStart()75 Stack::StackSlot Stack::GetStackStart() {
76 pthread_attr_t attr;
77 int error;
78 pthread_attr_init(&attr);
79 error = pthread_attr_get_np(pthread_self(), &attr);
80 if (!error) {
81 void* base;
82 size_t size;
83 error = pthread_attr_getstack(&attr, &base, &size);
84 CHECK(!error);
85 pthread_attr_destroy(&attr);
86 return reinterpret_cast<uint8_t*>(base) + size;
87 }
88 pthread_attr_destroy(&attr);
89 return nullptr;
90 }
91
92 } // namespace base
93 } // namespace v8
94