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