OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/public/platform/native/system_thunks.h" | 5 #include "mojo/public/platform/native/system_thunks.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 | 8 |
9 #include "mojo/public/platform/native/thunk_export.h" | |
10 | |
11 extern "C" { | 9 extern "C" { |
12 | 10 |
13 static MojoSystemThunks g_thunks = {0}; | 11 static MojoSystemThunks g_thunks = {0}; |
14 | 12 |
15 MojoTimeTicks MojoGetTimeTicksNow() { | 13 MojoTimeTicks MojoGetTimeTicksNow() { |
16 assert(g_thunks.GetTimeTicksNow); | 14 assert(g_thunks.GetTimeTicksNow); |
17 return g_thunks.GetTimeTicksNow(); | 15 return g_thunks.GetTimeTicksNow(); |
18 } | 16 } |
19 | 17 |
20 MojoResult MojoClose(MojoHandle handle) { | 18 MojoResult MojoClose(MojoHandle handle) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 MojoMapBufferFlags flags) { | 145 MojoMapBufferFlags flags) { |
148 assert(g_thunks.MapBuffer); | 146 assert(g_thunks.MapBuffer); |
149 return g_thunks.MapBuffer(buffer_handle, offset, num_bytes, buffer, flags); | 147 return g_thunks.MapBuffer(buffer_handle, offset, num_bytes, buffer, flags); |
150 } | 148 } |
151 | 149 |
152 MojoResult MojoUnmapBuffer(void* buffer) { | 150 MojoResult MojoUnmapBuffer(void* buffer) { |
153 assert(g_thunks.UnmapBuffer); | 151 assert(g_thunks.UnmapBuffer); |
154 return g_thunks.UnmapBuffer(buffer); | 152 return g_thunks.UnmapBuffer(buffer); |
155 } | 153 } |
156 | 154 |
| 155 // Call this function by looking |
| 156 // Always export this api. |
| 157 #if defined(WIN32) |
| 158 #define THUNK_EXPORT __declspec(dllexport) |
| 159 #else |
| 160 #define THUNK_EXPORT __attribute__((visibility("default"))) |
| 161 #endif |
| 162 |
157 extern "C" THUNK_EXPORT size_t MojoSetSystemThunks( | 163 extern "C" THUNK_EXPORT size_t MojoSetSystemThunks( |
158 const MojoSystemThunks* system_thunks) { | 164 const MojoSystemThunks* system_thunks) { |
159 if (system_thunks->size >= sizeof(g_thunks)) | 165 if (system_thunks->size >= sizeof(g_thunks)) |
160 g_thunks = *system_thunks; | 166 g_thunks = *system_thunks; |
161 return sizeof(g_thunks); | 167 return sizeof(g_thunks); |
162 } | 168 } |
163 | 169 |
164 } // extern "C" | 170 } // extern "C" |
OLD | NEW |