Home | History | Annotate | Download | only in src
      1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
      2 // Redistribution and use in source and binary forms, with or without
      3 // modification, are permitted provided that the following conditions are
      4 // met:
      5 //
      6 //     * Redistributions of source code must retain the above copyright
      7 //       notice, this list of conditions and the following disclaimer.
      8 //     * Redistributions in binary form must reproduce the above
      9 //       copyright notice, this list of conditions and the following
     10 //       disclaimer in the documentation and/or other materials provided
     11 //       with the distribution.
     12 //     * Neither the name of Google Inc. nor the names of its
     13 //       contributors may be used to endorse or promote products derived
     14 //       from this software without specific prior written permission.
     15 //
     16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 
     28 // Platform specific code for NULLOS goes here
     29 
     30 // Minimal include to get access to abort, fprintf and friends for bootstrapping
     31 // messages.
     32 #include <stdio.h>
     33 #include <stdlib.h>
     34 
     35 #include "v8.h"
     36 
     37 #include "platform.h"
     38 
     39 
     40 namespace v8 {
     41 namespace internal {
     42 
     43 // Give V8 the opportunity to override the default ceil behaviour.
     44 double ceiling(double x) {
     45   UNIMPLEMENTED();
     46   return 0;
     47 }
     48 
     49 
     50 // Give V8 the opportunity to override the default fmod behavior.
     51 double modulo(double x, double y) {
     52   UNIMPLEMENTED();
     53   return 0;
     54 }
     55 
     56 
     57 // Initialize OS class early in the V8 startup.
     58 void OS::Setup() {
     59   // Seed the random number generator.
     60   UNIMPLEMENTED();
     61 }
     62 
     63 
     64 // Returns the accumulated user time for thread.
     65 int OS::GetUserTime(uint32_t* secs,  uint32_t* usecs) {
     66   UNIMPLEMENTED();
     67   *secs = 0;
     68   *usecs = 0;
     69   return 0;
     70 }
     71 
     72 
     73 // Returns current time as the number of milliseconds since
     74 // 00:00:00 UTC, January 1, 1970.
     75 double OS::TimeCurrentMillis() {
     76   UNIMPLEMENTED();
     77   return 0;
     78 }
     79 
     80 
     81 // Returns ticks in microsecond resolution.
     82 int64_t OS::Ticks() {
     83   UNIMPLEMENTED();
     84   return 0;
     85 }
     86 
     87 
     88 // Returns a string identifying the current timezone taking into
     89 // account daylight saving.
     90 const char* OS::LocalTimezone(double time) {
     91   UNIMPLEMENTED();
     92   return "<none>";
     93 }
     94 
     95 
     96 // Returns the daylight savings offset in milliseconds for the given time.
     97 double OS::DaylightSavingsOffset(double time) {
     98   UNIMPLEMENTED();
     99   return 0;
    100 }
    101 
    102 
    103 // Returns the local time offset in milliseconds east of UTC without
    104 // taking daylight savings time into account.
    105 double OS::LocalTimeOffset() {
    106   UNIMPLEMENTED();
    107   return 0;
    108 }
    109 
    110 
    111 // Print (debug) message to console.
    112 void OS::Print(const char* format, ...) {
    113   UNIMPLEMENTED();
    114 }
    115 
    116 
    117 // Print (debug) message to console.
    118 void OS::VPrint(const char* format, va_list args) {
    119   // Minimalistic implementation for bootstrapping.
    120   vfprintf(stdout, format, args);
    121 }
    122 
    123 
    124 // Print error message to console.
    125 void OS::PrintError(const char* format, ...) {
    126   // Minimalistic implementation for bootstrapping.
    127   va_list args;
    128   va_start(args, format);
    129   VPrintError(format, args);
    130   va_end(args);
    131 }
    132 
    133 
    134 // Print error message to console.
    135 void OS::VPrintError(const char* format, va_list args) {
    136   // Minimalistic implementation for bootstrapping.
    137   vfprintf(stderr, format, args);
    138 }
    139 
    140 
    141 int OS::SNPrintF(char* str, size_t size, const char* format, ...) {
    142   UNIMPLEMENTED();
    143   return 0;
    144 }
    145 
    146 
    147 int OS::VSNPrintF(char* str, size_t size, const char* format, va_list args) {
    148   UNIMPLEMENTED();
    149   return 0;
    150 }
    151 
    152 
    153 uint64_t OS::CpuFeaturesImpliedByPlatform() {
    154   return 0;
    155 }
    156 
    157 
    158 double OS::nan_value() {
    159   UNIMPLEMENTED();
    160   return 0;
    161 }
    162 
    163 
    164 bool OS::ArmCpuHasFeature(CpuFeature feature) {
    165   UNIMPLEMENTED();
    166 }
    167 
    168 
    169 bool OS::IsOutsideAllocatedSpace(void* address) {
    170   UNIMPLEMENTED();
    171   return false;
    172 }
    173 
    174 
    175 size_t OS::AllocateAlignment() {
    176   UNIMPLEMENTED();
    177   return 0;
    178 }
    179 
    180 
    181 void* OS::Allocate(const size_t requested,
    182                    size_t* allocated,
    183                    bool executable) {
    184   UNIMPLEMENTED();
    185   return NULL;
    186 }
    187 
    188 
    189 void OS::Free(void* buf, const size_t length) {
    190   // TODO(1240712): potential system call return value which is ignored here.
    191   UNIMPLEMENTED();
    192 }
    193 
    194 
    195 #ifdef ENABLE_HEAP_PROTECTION
    196 
    197 void OS::Protect(void* address, size_t size) {
    198   UNIMPLEMENTED();
    199 }
    200 
    201 
    202 void OS::Unprotect(void* address, size_t size, bool is_executable) {
    203   UNIMPLEMENTED();
    204 }
    205 
    206 #endif
    207 
    208 
    209 void OS::Sleep(int milliseconds) {
    210   UNIMPLEMENTED();
    211 }
    212 
    213 
    214 void OS::Abort() {
    215   // Minimalistic implementation for bootstrapping.
    216   abort();
    217 }
    218 
    219 
    220 void OS::DebugBreak() {
    221   UNIMPLEMENTED();
    222 }
    223 
    224 
    225 OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size,
    226     void* initial) {
    227   UNIMPLEMENTED();
    228   return NULL;
    229 }
    230 
    231 
    232 void OS::LogSharedLibraryAddresses() {
    233   UNIMPLEMENTED();
    234 }
    235 
    236 
    237 int OS::StackWalk(Vector<OS::StackFrame> frames) {
    238   UNIMPLEMENTED();
    239   return 0;
    240 }
    241 
    242 
    243 VirtualMemory::VirtualMemory(size_t size, void* address_hint) {
    244   UNIMPLEMENTED();
    245 }
    246 
    247 
    248 VirtualMemory::~VirtualMemory() {
    249   UNIMPLEMENTED();
    250 }
    251 
    252 
    253 bool VirtualMemory::IsReserved() {
    254   UNIMPLEMENTED();
    255   return false;
    256 }
    257 
    258 
    259 bool VirtualMemory::Commit(void* address, size_t size, bool executable) {
    260   UNIMPLEMENTED();
    261   return false;
    262 }
    263 
    264 
    265 bool VirtualMemory::Uncommit(void* address, size_t size) {
    266   UNIMPLEMENTED();
    267   return false;
    268 }
    269 
    270 
    271 class ThreadHandle::PlatformData : public Malloced {
    272  public:
    273   explicit PlatformData(ThreadHandle::Kind kind) {
    274     UNIMPLEMENTED();
    275   }
    276 
    277   void* pd_data_;
    278 };
    279 
    280 
    281 ThreadHandle::ThreadHandle(Kind kind) {
    282   UNIMPLEMENTED();
    283   // Shared setup follows.
    284   data_ = new PlatformData(kind);
    285 }
    286 
    287 
    288 void ThreadHandle::Initialize(ThreadHandle::Kind kind) {
    289   UNIMPLEMENTED();
    290 }
    291 
    292 
    293 ThreadHandle::~ThreadHandle() {
    294   UNIMPLEMENTED();
    295   // Shared tear down follows.
    296   delete data_;
    297 }
    298 
    299 
    300 bool ThreadHandle::IsSelf() const {
    301   UNIMPLEMENTED();
    302   return false;
    303 }
    304 
    305 
    306 bool ThreadHandle::IsValid() const {
    307   UNIMPLEMENTED();
    308   return false;
    309 }
    310 
    311 
    312 Thread::Thread() : ThreadHandle(ThreadHandle::INVALID) {
    313   UNIMPLEMENTED();
    314 }
    315 
    316 
    317 Thread::~Thread() {
    318   UNIMPLEMENTED();
    319 }
    320 
    321 
    322 void Thread::Start() {
    323   UNIMPLEMENTED();
    324 }
    325 
    326 
    327 void Thread::Join() {
    328   UNIMPLEMENTED();
    329 }
    330 
    331 
    332 Thread::LocalStorageKey Thread::CreateThreadLocalKey() {
    333   UNIMPLEMENTED();
    334   return static_cast<LocalStorageKey>(0);
    335 }
    336 
    337 
    338 void Thread::DeleteThreadLocalKey(LocalStorageKey key) {
    339   UNIMPLEMENTED();
    340 }
    341 
    342 
    343 void* Thread::GetThreadLocal(LocalStorageKey key) {
    344   UNIMPLEMENTED();
    345   return NULL;
    346 }
    347 
    348 
    349 void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
    350   UNIMPLEMENTED();
    351 }
    352 
    353 
    354 void Thread::YieldCPU() {
    355   UNIMPLEMENTED();
    356 }
    357 
    358 
    359 class NullMutex : public Mutex {
    360  public:
    361   NullMutex() : data_(NULL) {
    362     UNIMPLEMENTED();
    363   }
    364 
    365   virtual ~NullMutex() {
    366     UNIMPLEMENTED();
    367   }
    368 
    369   virtual int Lock() {
    370     UNIMPLEMENTED();
    371     return 0;
    372   }
    373 
    374   virtual int Unlock() {
    375     UNIMPLEMENTED();
    376     return 0;
    377   }
    378 
    379  private:
    380   void* data_;
    381 };
    382 
    383 
    384 Mutex* OS::CreateMutex() {
    385   UNIMPLEMENTED();
    386   return new NullMutex();
    387 }
    388 
    389 
    390 class NullSemaphore : public Semaphore {
    391  public:
    392   explicit NullSemaphore(int count) : data_(NULL) {
    393     UNIMPLEMENTED();
    394   }
    395 
    396   virtual ~NullSemaphore() {
    397     UNIMPLEMENTED();
    398   }
    399 
    400   virtual void Wait() {
    401     UNIMPLEMENTED();
    402   }
    403 
    404   virtual void Signal() {
    405     UNIMPLEMENTED();
    406   }
    407  private:
    408   void* data_;
    409 };
    410 
    411 
    412 Semaphore* OS::CreateSemaphore(int count) {
    413   UNIMPLEMENTED();
    414   return new NullSemaphore(count);
    415 }
    416 
    417 #ifdef ENABLE_LOGGING_AND_PROFILING
    418 
    419 class ProfileSampler::PlatformData  : public Malloced {
    420  public:
    421   PlatformData() {
    422     UNIMPLEMENTED();
    423   }
    424 };
    425 
    426 
    427 ProfileSampler::ProfileSampler(int interval) {
    428   UNIMPLEMENTED();
    429   // Shared setup follows.
    430   data_ = new PlatformData();
    431   interval_ = interval;
    432   active_ = false;
    433 }
    434 
    435 
    436 ProfileSampler::~ProfileSampler() {
    437   UNIMPLEMENTED();
    438   // Shared tear down follows.
    439   delete data_;
    440 }
    441 
    442 
    443 void ProfileSampler::Start() {
    444   UNIMPLEMENTED();
    445 }
    446 
    447 
    448 void ProfileSampler::Stop() {
    449   UNIMPLEMENTED();
    450 }
    451 
    452 #endif  // ENABLE_LOGGING_AND_PROFILING
    453 
    454 } }  // namespace v8::internal
    455