Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: mojo/public/platform/native/system_thunks.h

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Note: This header should be compilable as C.
6
7 #ifndef MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_
8 #define MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_
9
10 #include <mojo/result.h>
11 #include <mojo/system/buffer.h>
12 #include <mojo/system/data_pipe.h>
13 #include <mojo/system/handle.h>
14 #include <mojo/system/message_pipe.h>
15 #include <mojo/system/time.h>
16 #include <mojo/system/wait.h>
17 #include <mojo/system/wait_set.h>
18 #include <stddef.h>
19
20 // The embedder needs to bind the basic Mojo Core functions of a DSO to those of
21 // the embedder when loading a DSO that is dependent on mojo_system.
22 // The typical usage would look like:
23 // base::ScopedNativeLibrary app_library(
24 // base::LoadNativeLibrary(app_path_, &error));
25 // typedef MojoResult (*MojoSetSystemThunksFn)(MojoSystemThunks*);
26 // MojoSetSystemThunksFn mojo_set_system_thunks_fn =
27 // reinterpret_cast<MojoSetSystemThunksFn>(app_library.GetFunctionPointer(
28 // "MojoSetSystemThunks"));
29 // MojoSystemThunks system_thunks = MojoMakeSystemThunks();
30 // size_t expected_size = mojo_set_system_thunks_fn(&system_thunks);
31 // if (expected_size > sizeof(MojoSystemThunks)) {
32 // LOG(ERROR)
33 // << "Invalid DSO. Expected MojoSystemThunks size: "
34 // << expected_size;
35 // break;
36 // }
37
38 // Structure used to bind the basic Mojo Core functions of a DSO to those of
39 // the embedder.
40 // This is the ABI between the embedder and the DSO. It can only have new
41 // functions added to the end. No other changes are supported.
42 #pragma pack(push, 8)
43 struct MojoSystemThunks {
44 size_t size; // Should be set to sizeof(MojoSystemThunks).
45 MojoTimeTicks (*GetTimeTicksNow)();
46 MojoResult (*Close)(MojoHandle handle);
47 MojoResult (*Wait)(MojoHandle handle,
48 MojoHandleSignals signals,
49 MojoDeadline deadline,
50 struct MojoHandleSignalsState* signals_state);
51 MojoResult (*WaitMany)(const MojoHandle* handles,
52 const MojoHandleSignals* signals,
53 uint32_t num_handles,
54 MojoDeadline deadline,
55 uint32_t* result_index,
56 struct MojoHandleSignalsState* signals_states);
57 MojoResult (*CreateMessagePipe)(
58 const struct MojoCreateMessagePipeOptions* options,
59 MojoHandle* message_pipe_handle0,
60 MojoHandle* message_pipe_handle1);
61 MojoResult (*WriteMessage)(MojoHandle message_pipe_handle,
62 const void* bytes,
63 uint32_t num_bytes,
64 const MojoHandle* handles,
65 uint32_t num_handles,
66 MojoWriteMessageFlags flags);
67 MojoResult (*ReadMessage)(MojoHandle message_pipe_handle,
68 void* bytes,
69 uint32_t* num_bytes,
70 MojoHandle* handles,
71 uint32_t* num_handles,
72 MojoReadMessageFlags flags);
73 MojoResult (*CreateDataPipe)(const struct MojoCreateDataPipeOptions* options,
74 MojoHandle* data_pipe_producer_handle,
75 MojoHandle* data_pipe_consumer_handle);
76 MojoResult (*WriteData)(MojoHandle data_pipe_producer_handle,
77 const void* elements,
78 uint32_t* num_elements,
79 MojoWriteDataFlags flags);
80 MojoResult (*BeginWriteData)(MojoHandle data_pipe_producer_handle,
81 void** buffer,
82 uint32_t* buffer_num_elements,
83 MojoWriteDataFlags flags);
84 MojoResult (*EndWriteData)(MojoHandle data_pipe_producer_handle,
85 uint32_t num_elements_written);
86 MojoResult (*ReadData)(MojoHandle data_pipe_consumer_handle,
87 void* elements,
88 uint32_t* num_elements,
89 MojoReadDataFlags flags);
90 MojoResult (*BeginReadData)(MojoHandle data_pipe_consumer_handle,
91 const void** buffer,
92 uint32_t* buffer_num_elements,
93 MojoReadDataFlags flags);
94 MojoResult (*EndReadData)(MojoHandle data_pipe_consumer_handle,
95 uint32_t num_elements_read);
96 MojoResult (*CreateSharedBuffer)(
97 const struct MojoCreateSharedBufferOptions* options,
98 uint64_t num_bytes,
99 MojoHandle* shared_buffer_handle);
100 MojoResult (*DuplicateBufferHandle)(
101 MojoHandle buffer_handle,
102 const struct MojoDuplicateBufferHandleOptions* options,
103 MojoHandle* new_buffer_handle);
104 MojoResult (*MapBuffer)(MojoHandle buffer_handle,
105 uint64_t offset,
106 uint64_t num_bytes,
107 void** buffer,
108 MojoMapBufferFlags flags);
109 MojoResult (*UnmapBuffer)(void* buffer);
110 // TODO(vtl): The next time an ABI-breaking change is made, re-order the
111 // following elements (to match the order in |Core|).
112 MojoResult (*GetBufferInformation)(MojoHandle buffer_handle,
113 struct MojoBufferInformation* info,
114 uint32_t info_num_bytes);
115 MojoResult (*SetDataPipeConsumerOptions)(
116 MojoHandle data_pipe_consumer_handle,
117 const struct MojoDataPipeConsumerOptions* options);
118 MojoResult (*GetDataPipeConsumerOptions)(
119 MojoHandle data_pipe_consumer_handle,
120 struct MojoDataPipeConsumerOptions* options,
121 uint32_t options_num_bytes);
122 MojoResult (*SetDataPipeProducerOptions)(
123 MojoHandle data_pipe_producer_handle,
124 const struct MojoDataPipeProducerOptions* options);
125 MojoResult (*GetDataPipeProducerOptions)(
126 MojoHandle data_pipe_producer_handle,
127 struct MojoDataPipeProducerOptions* options,
128 uint32_t options_num_bytes);
129 MojoResult (*GetRights)(MojoHandle handle, MojoHandleRights* rights);
130 MojoResult (*DuplicateHandleWithReducedRights)(
131 MojoHandle handle,
132 MojoHandleRights rights_to_remove,
133 MojoHandle* new_handle);
134 MojoResult (*DuplicateHandle)(MojoHandle handle, MojoHandle* new_handle);
135 MojoResult (*ReplaceHandleWithReducedRights)(
136 MojoHandle handle,
137 MojoHandleRights rights_to_remove,
138 MojoHandle* replacement_handle);
139 MojoResult (*CreateWaitSet)(const struct MojoCreateWaitSetOptions* options,
140 MojoHandle* handle);
141 MojoResult (*WaitSetAdd)(MojoHandle wait_set_handle,
142 MojoHandle handle,
143 MojoHandleSignals signals,
144 uint64_t cookie,
145 const struct MojoWaitSetAddOptions* options);
146 MojoResult (*WaitSetRemove)(MojoHandle wait_set_handle, uint64_t cookie);
147 MojoResult (*WaitSetWait)(MojoHandle wait_set_handle,
148 MojoDeadline deadline,
149 uint32_t* num_results,
150 struct MojoWaitSetResult* results,
151 uint32_t* max_results);
152 };
153 #pragma pack(pop)
154
155 #ifdef __cplusplus
156 // Intended to be called from the embedder. Returns a |MojoCore| initialized
157 // to contain pointers to each of the embedder's MojoCore functions.
158 inline MojoSystemThunks MojoMakeSystemThunks() {
159 MojoSystemThunks system_thunks = {
160 sizeof(MojoSystemThunks),
161 MojoGetTimeTicksNow,
162 MojoClose,
163 MojoWait,
164 MojoWaitMany,
165 MojoCreateMessagePipe,
166 MojoWriteMessage,
167 MojoReadMessage,
168 MojoCreateDataPipe,
169 MojoWriteData,
170 MojoBeginWriteData,
171 MojoEndWriteData,
172 MojoReadData,
173 MojoBeginReadData,
174 MojoEndReadData,
175 MojoCreateSharedBuffer,
176 MojoDuplicateBufferHandle,
177 MojoMapBuffer,
178 MojoUnmapBuffer,
179 MojoGetBufferInformation,
180 MojoSetDataPipeConsumerOptions,
181 MojoGetDataPipeConsumerOptions,
182 MojoSetDataPipeProducerOptions,
183 MojoGetDataPipeProducerOptions,
184 MojoGetRights,
185 MojoDuplicateHandleWithReducedRights,
186 MojoDuplicateHandle,
187 MojoReplaceHandleWithReducedRights,
188 MojoCreateWaitSet,
189 MojoWaitSetAdd,
190 MojoWaitSetRemove,
191 MojoWaitSetWait,
192 };
193 return system_thunks;
194 }
195 #endif
196
197
198 // Use this type for the function found by dynamically discovering it in
199 // a DSO linked with mojo_system. For example:
200 // MojoSetSystemThunksFn mojo_set_system_thunks_fn =
201 // reinterpret_cast<MojoSetSystemThunksFn>(app_library.GetFunctionPointer(
202 // "MojoSetSystemThunks"));
203 // The expected size of |system_thunks} is returned.
204 // The contents of |system_thunks| are copied.
205 typedef size_t (*MojoSetSystemThunksFn)(
206 const struct MojoSystemThunks* system_thunks);
207
208 #endif // MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_
OLDNEW
« no previous file with comments | « mojo/public/platform/native/platform_handle_private_thunks.c ('k') | mojo/public/platform/native/system_thunks.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698