| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Note: This header should be compilable as C. | 5 // Note: This header should be compilable as C. |
| 6 | 6 |
| 7 #ifndef MOJO_PUBLIC_C_SYSTEM_THUNKS_H_ | 7 #ifndef MOJO_PUBLIC_C_SYSTEM_THUNKS_H_ |
| 8 #define MOJO_PUBLIC_C_SYSTEM_THUNKS_H_ | 8 #define MOJO_PUBLIC_C_SYSTEM_THUNKS_H_ |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 #include "mojo/public/c/system/core.h" | 13 #include "mojo/public/c/system/core.h" |
| 14 #include "mojo/public/c/system/system_export.h" | 14 #include "mojo/public/c/system/system_export.h" |
| 15 | 15 |
| 16 // The embedder needs to bind the basic Mojo Core functions of a DSO to those of | 16 // Structure used to bind the basic Mojo Core functions to an embedder |
| 17 // the embedder when loading a DSO that is dependent on mojo_system. | 17 // implementation. This is intended to eventually be used as a stable ABI |
| 18 // The typical usage would look like: | 18 // between a Mojo embedder and some loaded application code, but for now it is |
| 19 // base::ScopedNativeLibrary app_library( | 19 // still effectively safe to rearrange entries as needed. |
| 20 // base::LoadNativeLibrary(app_path_, &error)); | |
| 21 // typedef MojoResult (*MojoSetSystemThunksFn)(MojoSystemThunks*); | |
| 22 // MojoSetSystemThunksFn mojo_set_system_thunks_fn = | |
| 23 // reinterpret_cast<MojoSetSystemThunksFn>(app_library.GetFunctionPointer( | |
| 24 // "MojoSetSystemThunks")); | |
| 25 // MojoSystemThunks system_thunks = MojoMakeSystemThunks(); | |
| 26 // size_t expected_size = mojo_set_system_thunks_fn(&system_thunks); | |
| 27 // if (expected_size > sizeof(MojoSystemThunks)) { | |
| 28 // LOG(ERROR) | |
| 29 // << "Invalid DSO. Expected MojoSystemThunks size: " | |
| 30 // << expected_size; | |
| 31 // break; | |
| 32 // } | |
| 33 | |
| 34 // Structure used to bind the basic Mojo Core functions of a DSO to those of | |
| 35 // the embedder. | |
| 36 // This is the ABI between the embedder and the DSO. It can only have new | |
| 37 // functions added to the end. No other changes are supported. | |
| 38 #pragma pack(push, 8) | 20 #pragma pack(push, 8) |
| 39 struct MojoSystemThunks { | 21 struct MojoSystemThunks { |
| 40 size_t size; // Should be set to sizeof(MojoSystemThunks). | 22 size_t size; // Should be set to sizeof(MojoSystemThunks). |
| 41 MojoTimeTicks (*GetTimeTicksNow)(); | 23 MojoTimeTicks (*GetTimeTicksNow)(); |
| 42 MojoResult (*Close)(MojoHandle handle); | 24 MojoResult (*Close)(MojoHandle handle); |
| 43 MojoResult (*Wait)(MojoHandle handle, | 25 MojoResult (*Wait)(MojoHandle handle, |
| 44 MojoHandleSignals signals, | 26 MojoHandleSignals signals, |
| 45 MojoDeadline deadline, | 27 MojoDeadline deadline, |
| 46 struct MojoHandleSignalsState* signals_state); | 28 struct MojoHandleSignalsState* signals_state); |
| 47 MojoResult (*WaitMany)(const MojoHandle* handles, | 29 MojoResult (*WaitMany)(const MojoHandle* handles, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 MojoResult (*AddHandle)(MojoHandle wait_set, | 90 MojoResult (*AddHandle)(MojoHandle wait_set, |
| 109 MojoHandle handle, | 91 MojoHandle handle, |
| 110 MojoHandleSignals signals); | 92 MojoHandleSignals signals); |
| 111 MojoResult (*RemoveHandle)(MojoHandle wait_set, | 93 MojoResult (*RemoveHandle)(MojoHandle wait_set, |
| 112 MojoHandle handle); | 94 MojoHandle handle); |
| 113 MojoResult (*GetReadyHandles)(MojoHandle wait_set, | 95 MojoResult (*GetReadyHandles)(MojoHandle wait_set, |
| 114 uint32_t* count, | 96 uint32_t* count, |
| 115 MojoHandle* handles, | 97 MojoHandle* handles, |
| 116 MojoResult* results, | 98 MojoResult* results, |
| 117 struct MojoHandleSignalsState* signals_states); | 99 struct MojoHandleSignalsState* signals_states); |
| 118 MojoResult (*Watch)(MojoHandle handle, | 100 MojoResult (*CreateWatcher)(MojoWatcherCallback callback, |
| 101 MojoHandle* watcher_handle); |
| 102 MojoResult (*Watch)(MojoHandle watcher_handle, |
| 103 MojoHandle handle, |
| 119 MojoHandleSignals signals, | 104 MojoHandleSignals signals, |
| 120 MojoWatchCallback callback, | |
| 121 uintptr_t context); | 105 uintptr_t context); |
| 122 MojoResult (*CancelWatch)(MojoHandle handle, uintptr_t context); | 106 MojoResult (*CancelWatch)(MojoHandle watcher_handle, uintptr_t context); |
| 107 MojoResult (*ArmWatcher)(MojoHandle watcher_handle, |
| 108 uint32_t* num_ready_contexts, |
| 109 uintptr_t* ready_contexts, |
| 110 MojoResult* ready_results, |
| 111 MojoHandleSignalsState* ready_signals_states); |
| 123 MojoResult (*FuseMessagePipes)(MojoHandle handle0, MojoHandle handle1); | 112 MojoResult (*FuseMessagePipes)(MojoHandle handle0, MojoHandle handle1); |
| 124 MojoResult (*WriteMessageNew)(MojoHandle message_pipe_handle, | 113 MojoResult (*WriteMessageNew)(MojoHandle message_pipe_handle, |
| 125 MojoMessageHandle message, | 114 MojoMessageHandle message, |
| 126 MojoWriteMessageFlags flags); | 115 MojoWriteMessageFlags flags); |
| 127 MojoResult (*ReadMessageNew)(MojoHandle message_pipe_handle, | 116 MojoResult (*ReadMessageNew)(MojoHandle message_pipe_handle, |
| 128 MojoMessageHandle* message, | 117 MojoMessageHandle* message, |
| 129 uint32_t* num_bytes, | 118 uint32_t* num_bytes, |
| 130 MojoHandle* handles, | 119 MojoHandle* handles, |
| 131 uint32_t* num_handles, | 120 uint32_t* num_handles, |
| 132 MojoReadMessageFlags flags); | 121 MojoReadMessageFlags flags); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // The contents of |system_thunks| are copied. | 158 // The contents of |system_thunks| are copied. |
| 170 typedef size_t (*MojoSetSystemThunksFn)( | 159 typedef size_t (*MojoSetSystemThunksFn)( |
| 171 const struct MojoSystemThunks* system_thunks); | 160 const struct MojoSystemThunks* system_thunks); |
| 172 | 161 |
| 173 // A function for setting up the embedder's own system thunks. This should only | 162 // A function for setting up the embedder's own system thunks. This should only |
| 174 // be called by Mojo embedder code. | 163 // be called by Mojo embedder code. |
| 175 MOJO_SYSTEM_EXPORT size_t MojoEmbedderSetSystemThunks( | 164 MOJO_SYSTEM_EXPORT size_t MojoEmbedderSetSystemThunks( |
| 176 const struct MojoSystemThunks* system_thunks); | 165 const struct MojoSystemThunks* system_thunks); |
| 177 | 166 |
| 178 #endif // MOJO_PUBLIC_C_SYSTEM_THUNKS_H_ | 167 #endif // MOJO_PUBLIC_C_SYSTEM_THUNKS_H_ |
| OLD | NEW |