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 |
9 extern "C" { | 11 extern "C" { |
10 | 12 |
11 static MojoSystemThunks g_thunks = {0}; | 13 static MojoSystemThunks g_thunks = {0}; |
12 | 14 |
13 MojoTimeTicks MojoGetTimeTicksNow() { | 15 MojoTimeTicks MojoGetTimeTicksNow() { |
14 assert(g_thunks.GetTimeTicksNow); | 16 assert(g_thunks.GetTimeTicksNow); |
15 return g_thunks.GetTimeTicksNow(); | 17 return g_thunks.GetTimeTicksNow(); |
16 } | 18 } |
17 | 19 |
18 MojoResult MojoClose(MojoHandle handle) { | 20 MojoResult MojoClose(MojoHandle handle) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 MojoMapBufferFlags flags) { | 147 MojoMapBufferFlags flags) { |
146 assert(g_thunks.MapBuffer); | 148 assert(g_thunks.MapBuffer); |
147 return g_thunks.MapBuffer(buffer_handle, offset, num_bytes, buffer, flags); | 149 return g_thunks.MapBuffer(buffer_handle, offset, num_bytes, buffer, flags); |
148 } | 150 } |
149 | 151 |
150 MojoResult MojoUnmapBuffer(void* buffer) { | 152 MojoResult MojoUnmapBuffer(void* buffer) { |
151 assert(g_thunks.UnmapBuffer); | 153 assert(g_thunks.UnmapBuffer); |
152 return g_thunks.UnmapBuffer(buffer); | 154 return g_thunks.UnmapBuffer(buffer); |
153 } | 155 } |
154 | 156 |
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 | |
163 extern "C" THUNK_EXPORT size_t MojoSetSystemThunks( | 157 extern "C" THUNK_EXPORT size_t MojoSetSystemThunks( |
164 const MojoSystemThunks* system_thunks) { | 158 const MojoSystemThunks* system_thunks) { |
165 if (system_thunks->size >= sizeof(g_thunks)) | 159 if (system_thunks->size >= sizeof(g_thunks)) |
166 g_thunks = *system_thunks; | 160 g_thunks = *system_thunks; |
167 return sizeof(g_thunks); | 161 return sizeof(g_thunks); |
168 } | 162 } |
169 | 163 |
170 } // extern "C" | 164 } // extern "C" |
OLD | NEW |