OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #if defined(FLETCH_TARGET_OS_LK) || defined(FLETCH_TARGET_OS_CMSIS) | 5 #if defined(DARTINO_TARGET_OS_LK) || defined(DARTINO_TARGET_OS_CMSIS) |
6 | 6 |
7 #ifdef FLETCH_ENABLE_FFI | 7 #ifdef DARTINO_ENABLE_FFI |
8 | 8 |
9 #include "src/vm/ffi.h" | 9 #include "src/vm/ffi.h" |
10 #include "src/vm/natives.h" | 10 #include "src/vm/natives.h" |
11 #include "src/vm/process.h" | 11 #include "src/vm/process.h" |
12 #include "src/shared/assert.h" | 12 #include "src/shared/assert.h" |
13 | 13 |
14 #include "include/static_ffi.h" | 14 #include "include/static_ffi.h" |
15 | 15 |
16 extern "C" FletchStaticFFISymbol fletch_ffi_table; | 16 extern "C" DartinoStaticFFISymbol dartino_ffi_table; |
17 | 17 |
18 namespace fletch { | 18 namespace dartino { |
19 | 19 |
20 void ForeignFunctionInterface::Setup() {} | 20 void ForeignFunctionInterface::Setup() {} |
21 | 21 |
22 void ForeignFunctionInterface::TearDown() {} | 22 void ForeignFunctionInterface::TearDown() {} |
23 | 23 |
24 bool ForeignFunctionInterface::AddDefaultSharedLibrary(const char* library) { | 24 bool ForeignFunctionInterface::AddDefaultSharedLibrary(const char* library) { |
25 return false; | 25 return false; |
26 } | 26 } |
27 | 27 |
28 void* ForeignFunctionInterface::LookupInDefaultLibraries(const char* symbol) { | 28 void* ForeignFunctionInterface::LookupInDefaultLibraries(const char* symbol) { |
29 UNIMPLEMENTED(); | 29 UNIMPLEMENTED(); |
30 return NULL; | 30 return NULL; |
31 } | 31 } |
32 | 32 |
33 DefaultLibraryEntry* ForeignFunctionInterface::libraries_ = NULL; | 33 DefaultLibraryEntry* ForeignFunctionInterface::libraries_ = NULL; |
34 Mutex* ForeignFunctionInterface::mutex_ = NULL; | 34 Mutex* ForeignFunctionInterface::mutex_ = NULL; |
35 | 35 |
36 BEGIN_NATIVE(ForeignLibraryGetFunction) { | 36 BEGIN_NATIVE(ForeignLibraryGetFunction) { |
37 word address = AsForeignWord(arguments[0]); | 37 word address = AsForeignWord(arguments[0]); |
38 if (address != 0) return Failure::index_out_of_bounds(); | 38 if (address != 0) return Failure::index_out_of_bounds(); |
39 char* name = AsForeignString(arguments[1]); | 39 char* name = AsForeignString(arguments[1]); |
40 for (FletchStaticFFISymbol* entry = &fletch_ffi_table; entry->name != NULL; | 40 for (DartinoStaticFFISymbol* entry = &dartino_ffi_table; entry->name != NULL; |
41 entry++) { | 41 entry++) { |
42 if (strcmp(name, entry->name) == 0) { | 42 if (strcmp(name, entry->name) == 0) { |
43 free(name); | 43 free(name); |
44 return process->ToInteger(reinterpret_cast<intptr_t>(entry->ptr)); | 44 return process->ToInteger(reinterpret_cast<intptr_t>(entry->ptr)); |
45 } | 45 } |
46 } | 46 } |
47 free(name); | 47 free(name); |
48 return Failure::index_out_of_bounds(); | 48 return Failure::index_out_of_bounds(); |
49 } | 49 } |
50 END_NATIVE() | 50 END_NATIVE() |
(...skipping 13 matching lines...) Expand all Loading... |
64 return Smi::FromWord(0); | 64 return Smi::FromWord(0); |
65 } | 65 } |
66 END_NATIVE() | 66 END_NATIVE() |
67 | 67 |
68 BEGIN_NATIVE(ForeignErrno) { | 68 BEGIN_NATIVE(ForeignErrno) { |
69 UNIMPLEMENTED(); | 69 UNIMPLEMENTED(); |
70 return Smi::FromWord(0); | 70 return Smi::FromWord(0); |
71 } | 71 } |
72 END_NATIVE() | 72 END_NATIVE() |
73 | 73 |
74 } // namespace fletch | 74 } // namespace dartino |
75 | 75 |
76 #endif // FLETCH_ENABLE_FFI | 76 #endif // DARTINO_ENABLE_FFI |
77 | 77 |
78 #endif // defined(FLETCH_TARGET_OS_LK) || defined(FLETCH_TARGET_OS_CMSIS) | 78 #endif // defined(DARTINO_TARGET_OS_LK) || defined(DARTINO_TARGET_OS_CMSIS) |
OLD | NEW |