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#include "vm-state-inl.h"
39
40
41namespace v8 {
42namespace internal {
43
44// Give V8 the opportunity to override the default ceil behaviour.
45double ceiling(double x) {
46  UNIMPLEMENTED();
47  return 0;
48}
49
50
51// Give V8 the opportunity to override the default fmod behavior.
52double modulo(double x, double y) {
53  UNIMPLEMENTED();
54  return 0;
55}
56
57
58double fast_sin(double x) {
59  UNIMPLEMENTED();
60  return 0;
61}
62
63
64double fast_cos(double x) {
65  UNIMPLEMENTED();
66  return 0;
67}
68
69
70double fast_tan(double x) {
71  UNIMPLEMENTED();
72  return 0;
73}
74
75
76double fast_log(double x) {
77  UNIMPLEMENTED();
78  return 0;
79}
80
81
82// Initialize OS class early in the V8 startup.
83void OS::SetUp() {
84  // Seed the random number generator.
85  UNIMPLEMENTED();
86}
87
88
89void OS::PostSetUp() {
90  UNIMPLEMENTED();
91}
92
93
94// Returns the accumulated user time for thread.
95int OS::GetUserTime(uint32_t* secs,  uint32_t* usecs) {
96  UNIMPLEMENTED();
97  *secs = 0;
98  *usecs = 0;
99  return 0;
100}
101
102
103// Returns current time as the number of milliseconds since
104// 00:00:00 UTC, January 1, 1970.
105double OS::TimeCurrentMillis() {
106  UNIMPLEMENTED();
107  return 0;
108}
109
110
111// Returns ticks in microsecond resolution.
112int64_t OS::Ticks() {
113  UNIMPLEMENTED();
114  return 0;
115}
116
117
118// Returns a string identifying the current timezone taking into
119// account daylight saving.
120const char* OS::LocalTimezone(double time) {
121  UNIMPLEMENTED();
122  return "<none>";
123}
124
125
126// Returns the daylight savings offset in milliseconds for the given time.
127double OS::DaylightSavingsOffset(double time) {
128  UNIMPLEMENTED();
129  return 0;
130}
131
132
133int OS::GetLastError() {
134  UNIMPLEMENTED();
135  return 0;
136}
137
138
139// Returns the local time offset in milliseconds east of UTC without
140// taking daylight savings time into account.
141double OS::LocalTimeOffset() {
142  UNIMPLEMENTED();
143  return 0;
144}
145
146
147// Print (debug) message to console.
148void OS::Print(const char* format, ...) {
149  UNIMPLEMENTED();
150}
151
152
153// Print (debug) message to console.
154void OS::VPrint(const char* format, va_list args) {
155  // Minimalistic implementation for bootstrapping.
156  vfprintf(stdout, format, args);
157}
158
159
160void OS::FPrint(FILE* out, const char* format, ...) {
161  va_list args;
162  va_start(args, format);
163  VFPrint(out, format, args);
164  va_end(args);
165}
166
167
168void OS::VFPrint(FILE* out, const char* format, va_list args) {
169  vfprintf(out, format, args);
170}
171
172
173// Print error message to console.
174void OS::PrintError(const char* format, ...) {
175  // Minimalistic implementation for bootstrapping.
176  va_list args;
177  va_start(args, format);
178  VPrintError(format, args);
179  va_end(args);
180}
181
182
183// Print error message to console.
184void OS::VPrintError(const char* format, va_list args) {
185  // Minimalistic implementation for bootstrapping.
186  vfprintf(stderr, format, args);
187}
188
189
190int OS::SNPrintF(char* str, size_t size, const char* format, ...) {
191  UNIMPLEMENTED();
192  return 0;
193}
194
195
196int OS::VSNPrintF(char* str, size_t size, const char* format, va_list args) {
197  UNIMPLEMENTED();
198  return 0;
199}
200
201
202uint64_t OS::CpuFeaturesImpliedByPlatform() {
203  return 0;
204}
205
206
207double OS::nan_value() {
208  UNIMPLEMENTED();
209  return 0;
210}
211
212
213bool OS::ArmCpuHasFeature(CpuFeature feature) {
214  UNIMPLEMENTED();
215}
216
217
218bool OS::ArmUsingHardFloat() {
219  UNIMPLEMENTED();
220}
221
222
223bool OS::IsOutsideAllocatedSpace(void* address) {
224  UNIMPLEMENTED();
225  return false;
226}
227
228
229size_t OS::AllocateAlignment() {
230  UNIMPLEMENTED();
231  return 0;
232}
233
234
235void* OS::Allocate(const size_t requested,
236                   size_t* allocated,
237                   bool executable) {
238  UNIMPLEMENTED();
239  return NULL;
240}
241
242
243void OS::Free(void* buf, const size_t length) {
244  // TODO(1240712): potential system call return value which is ignored here.
245  UNIMPLEMENTED();
246}
247
248
249void OS::Guard(void* address, const size_t size) {
250  UNIMPLEMENTED();
251}
252
253
254void OS::Sleep(int milliseconds) {
255  UNIMPLEMENTED();
256}
257
258
259void OS::Abort() {
260  // Minimalistic implementation for bootstrapping.
261  abort();
262}
263
264
265void OS::DebugBreak() {
266  UNIMPLEMENTED();
267}
268
269
270OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
271  UNIMPLEMENTED();
272  return NULL;
273}
274
275
276OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size,
277    void* initial) {
278  UNIMPLEMENTED();
279  return NULL;
280}
281
282
283void OS::LogSharedLibraryAddresses() {
284  UNIMPLEMENTED();
285}
286
287
288void OS::SignalCodeMovingGC() {
289  UNIMPLEMENTED();
290}
291
292
293int OS::StackWalk(Vector<OS::StackFrame> frames) {
294  UNIMPLEMENTED();
295  return 0;
296}
297
298
299VirtualMemory::VirtualMemory(size_t size, void* address_hint) {
300  UNIMPLEMENTED();
301}
302
303
304VirtualMemory::~VirtualMemory() {
305  UNIMPLEMENTED();
306}
307
308
309bool VirtualMemory::IsReserved() {
310  UNIMPLEMENTED();
311  return false;
312}
313
314
315bool VirtualMemory::Commit(void* address, size_t size, bool executable) {
316  UNIMPLEMENTED();
317  return false;
318}
319
320
321bool VirtualMemory::Uncommit(void* address, size_t size) {
322  UNIMPLEMENTED();
323  return false;
324}
325
326
327bool VirtualMemory::Guard(void* address) {
328  UNIMPLEMENTED();
329  return false;
330}
331
332
333class Thread::PlatformData : public Malloced {
334 public:
335  PlatformData() {
336    UNIMPLEMENTED();
337  }
338
339  void* pd_data_;
340};
341
342
343Thread::Thread(const Options& options)
344    : data_(new PlatformData()),
345      stack_size_(options.stack_size) {
346  set_name(options.name);
347  UNIMPLEMENTED();
348}
349
350
351Thread::Thread(const char* name)
352    : data_(new PlatformData()),
353      stack_size_(0) {
354  set_name(name);
355  UNIMPLEMENTED();
356}
357
358
359Thread::~Thread() {
360  delete data_;
361  UNIMPLEMENTED();
362}
363
364
365void Thread::set_name(const char* name) {
366  strncpy(name_, name, sizeof(name_));
367  name_[sizeof(name_) - 1] = '\0';
368}
369
370
371void Thread::Start() {
372  UNIMPLEMENTED();
373}
374
375
376void Thread::Join() {
377  UNIMPLEMENTED();
378}
379
380
381Thread::LocalStorageKey Thread::CreateThreadLocalKey() {
382  UNIMPLEMENTED();
383  return static_cast<LocalStorageKey>(0);
384}
385
386
387void Thread::DeleteThreadLocalKey(LocalStorageKey key) {
388  UNIMPLEMENTED();
389}
390
391
392void* Thread::GetThreadLocal(LocalStorageKey key) {
393  UNIMPLEMENTED();
394  return NULL;
395}
396
397
398void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
399  UNIMPLEMENTED();
400}
401
402
403void Thread::YieldCPU() {
404  UNIMPLEMENTED();
405}
406
407
408class NullMutex : public Mutex {
409 public:
410  NullMutex() : data_(NULL) {
411    UNIMPLEMENTED();
412  }
413
414  virtual ~NullMutex() {
415    UNIMPLEMENTED();
416  }
417
418  virtual int Lock() {
419    UNIMPLEMENTED();
420    return 0;
421  }
422
423  virtual int Unlock() {
424    UNIMPLEMENTED();
425    return 0;
426  }
427
428 private:
429  void* data_;
430};
431
432
433Mutex* OS::CreateMutex() {
434  UNIMPLEMENTED();
435  return new NullMutex();
436}
437
438
439class NullSemaphore : public Semaphore {
440 public:
441  explicit NullSemaphore(int count) : data_(NULL) {
442    UNIMPLEMENTED();
443  }
444
445  virtual ~NullSemaphore() {
446    UNIMPLEMENTED();
447  }
448
449  virtual void Wait() {
450    UNIMPLEMENTED();
451  }
452
453  virtual void Signal() {
454    UNIMPLEMENTED();
455  }
456 private:
457  void* data_;
458};
459
460
461Semaphore* OS::CreateSemaphore(int count) {
462  UNIMPLEMENTED();
463  return new NullSemaphore(count);
464}
465
466
467class ProfileSampler::PlatformData  : public Malloced {
468 public:
469  PlatformData() {
470    UNIMPLEMENTED();
471  }
472};
473
474
475ProfileSampler::ProfileSampler(int interval) {
476  UNIMPLEMENTED();
477  // Shared setup follows.
478  data_ = new PlatformData();
479  interval_ = interval;
480  active_ = false;
481}
482
483
484ProfileSampler::~ProfileSampler() {
485  UNIMPLEMENTED();
486  // Shared tear down follows.
487  delete data_;
488}
489
490
491void ProfileSampler::Start() {
492  UNIMPLEMENTED();
493}
494
495
496void ProfileSampler::Stop() {
497  UNIMPLEMENTED();
498}
499
500
501} }  // namespace v8::internal
502