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. |
| 6 |
5 #ifndef MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_ | 7 #ifndef MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_ |
6 #define MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_ | 8 #define MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_ |
7 | 9 |
8 #include <stddef.h> | 10 #include <stddef.h> |
9 | 11 |
10 #include "mojo/public/c/system/core.h" | 12 #include "mojo/public/c/system/core.h" |
11 | 13 |
12 // The embedder needs to bind the basic Mojo Core functions of a DSO to those of | 14 // The embedder needs to bind the basic Mojo Core functions of a DSO to those of |
13 // the embedder when loading a DSO that is dependent on mojo_system. | 15 // the embedder when loading a DSO that is dependent on mojo_system. |
14 // The typical usage would look like: | 16 // The typical usage would look like: |
(...skipping 21 matching lines...) Expand all Loading... |
36 size_t size; // Should be set to sizeof(MojoSystemThunks). | 38 size_t size; // Should be set to sizeof(MojoSystemThunks). |
37 MojoTimeTicks (*GetTimeTicksNow)(); | 39 MojoTimeTicks (*GetTimeTicksNow)(); |
38 MojoResult (*Close)(MojoHandle handle); | 40 MojoResult (*Close)(MojoHandle handle); |
39 MojoResult (*Wait)(MojoHandle handle, | 41 MojoResult (*Wait)(MojoHandle handle, |
40 MojoHandleSignals signals, | 42 MojoHandleSignals signals, |
41 MojoDeadline deadline); | 43 MojoDeadline deadline); |
42 MojoResult (*WaitMany)(const MojoHandle* handles, | 44 MojoResult (*WaitMany)(const MojoHandle* handles, |
43 const MojoHandleSignals* signals, | 45 const MojoHandleSignals* signals, |
44 uint32_t num_handles, | 46 uint32_t num_handles, |
45 MojoDeadline deadline); | 47 MojoDeadline deadline); |
46 MojoResult (*CreateMessagePipe)(const MojoCreateMessagePipeOptions* options, | 48 MojoResult (*CreateMessagePipe)( |
47 MojoHandle* message_pipe_handle0, | 49 const struct MojoCreateMessagePipeOptions* options, |
48 MojoHandle* message_pipe_handle1); | 50 MojoHandle* message_pipe_handle0, |
| 51 MojoHandle* message_pipe_handle1); |
49 MojoResult (*WriteMessage)(MojoHandle message_pipe_handle, | 52 MojoResult (*WriteMessage)(MojoHandle message_pipe_handle, |
50 const void* bytes, | 53 const void* bytes, |
51 uint32_t num_bytes, | 54 uint32_t num_bytes, |
52 const MojoHandle* handles, | 55 const MojoHandle* handles, |
53 uint32_t num_handles, | 56 uint32_t num_handles, |
54 MojoWriteMessageFlags flags); | 57 MojoWriteMessageFlags flags); |
55 MojoResult (*ReadMessage)(MojoHandle message_pipe_handle, | 58 MojoResult (*ReadMessage)(MojoHandle message_pipe_handle, |
56 void* bytes, | 59 void* bytes, |
57 uint32_t* num_bytes, | 60 uint32_t* num_bytes, |
58 MojoHandle* handles, | 61 MojoHandle* handles, |
59 uint32_t* num_handles, | 62 uint32_t* num_handles, |
60 MojoReadMessageFlags flags); | 63 MojoReadMessageFlags flags); |
61 MojoResult (*CreateDataPipe)(const MojoCreateDataPipeOptions* options, | 64 MojoResult (*CreateDataPipe)(const struct MojoCreateDataPipeOptions* options, |
62 MojoHandle* data_pipe_producer_handle, | 65 MojoHandle* data_pipe_producer_handle, |
63 MojoHandle* data_pipe_consumer_handle); | 66 MojoHandle* data_pipe_consumer_handle); |
64 MojoResult (*WriteData)(MojoHandle data_pipe_producer_handle, | 67 MojoResult (*WriteData)(MojoHandle data_pipe_producer_handle, |
65 const void* elements, | 68 const void* elements, |
66 uint32_t* num_elements, | 69 uint32_t* num_elements, |
67 MojoWriteDataFlags flags); | 70 MojoWriteDataFlags flags); |
68 MojoResult (*BeginWriteData)(MojoHandle data_pipe_producer_handle, | 71 MojoResult (*BeginWriteData)(MojoHandle data_pipe_producer_handle, |
69 void** buffer, | 72 void** buffer, |
70 uint32_t* buffer_num_elements, | 73 uint32_t* buffer_num_elements, |
71 MojoWriteDataFlags flags); | 74 MojoWriteDataFlags flags); |
72 MojoResult (*EndWriteData)(MojoHandle data_pipe_producer_handle, | 75 MojoResult (*EndWriteData)(MojoHandle data_pipe_producer_handle, |
73 uint32_t num_elements_written); | 76 uint32_t num_elements_written); |
74 MojoResult (*ReadData)(MojoHandle data_pipe_consumer_handle, | 77 MojoResult (*ReadData)(MojoHandle data_pipe_consumer_handle, |
75 void* elements, | 78 void* elements, |
76 uint32_t* num_elements, | 79 uint32_t* num_elements, |
77 MojoReadDataFlags flags); | 80 MojoReadDataFlags flags); |
78 MojoResult (*BeginReadData)(MojoHandle data_pipe_consumer_handle, | 81 MojoResult (*BeginReadData)(MojoHandle data_pipe_consumer_handle, |
79 const void** buffer, | 82 const void** buffer, |
80 uint32_t* buffer_num_elements, | 83 uint32_t* buffer_num_elements, |
81 MojoReadDataFlags flags); | 84 MojoReadDataFlags flags); |
82 MojoResult (*EndReadData)(MojoHandle data_pipe_consumer_handle, | 85 MojoResult (*EndReadData)(MojoHandle data_pipe_consumer_handle, |
83 uint32_t num_elements_read); | 86 uint32_t num_elements_read); |
84 MojoResult (*CreateSharedBuffer)( | 87 MojoResult (*CreateSharedBuffer)( |
85 const MojoCreateSharedBufferOptions* options, | 88 const struct MojoCreateSharedBufferOptions* options, |
86 uint64_t num_bytes, | 89 uint64_t num_bytes, |
87 MojoHandle* shared_buffer_handle); | 90 MojoHandle* shared_buffer_handle); |
88 MojoResult (*DuplicateBufferHandle)( | 91 MojoResult (*DuplicateBufferHandle)( |
89 MojoHandle buffer_handle, | 92 MojoHandle buffer_handle, |
90 const MojoDuplicateBufferHandleOptions* options, | 93 const struct MojoDuplicateBufferHandleOptions* options, |
91 MojoHandle* new_buffer_handle); | 94 MojoHandle* new_buffer_handle); |
92 MojoResult (*MapBuffer)(MojoHandle buffer_handle, | 95 MojoResult (*MapBuffer)(MojoHandle buffer_handle, |
93 uint64_t offset, | 96 uint64_t offset, |
94 uint64_t num_bytes, | 97 uint64_t num_bytes, |
95 void** buffer, | 98 void** buffer, |
96 MojoMapBufferFlags flags); | 99 MojoMapBufferFlags flags); |
97 MojoResult (*UnmapBuffer)(void* buffer); | 100 MojoResult (*UnmapBuffer)(void* buffer); |
98 }; | 101 }; |
99 #pragma pack(pop) | 102 #pragma pack(pop) |
100 | 103 |
| 104 |
| 105 #ifdef __cplusplus |
101 // Intended to be called from the embedder. Returns a |MojoCore| initialized | 106 // Intended to be called from the embedder. Returns a |MojoCore| initialized |
102 // to contain pointers to each of the embedder's MojoCore functions. | 107 // to contain pointers to each of the embedder's MojoCore functions. |
103 inline MojoSystemThunks MojoMakeSystemThunks() { | 108 inline MojoSystemThunks MojoMakeSystemThunks() { |
104 MojoSystemThunks system_thunks = { | 109 MojoSystemThunks system_thunks = { |
105 sizeof(MojoSystemThunks), | 110 sizeof(MojoSystemThunks), |
106 MojoGetTimeTicksNow, | 111 MojoGetTimeTicksNow, |
107 MojoClose, | 112 MojoClose, |
108 MojoWait, | 113 MojoWait, |
109 MojoWaitMany, | 114 MojoWaitMany, |
110 MojoCreateMessagePipe, | 115 MojoCreateMessagePipe, |
111 MojoWriteMessage, | 116 MojoWriteMessage, |
112 MojoReadMessage, | 117 MojoReadMessage, |
113 MojoCreateDataPipe, | 118 MojoCreateDataPipe, |
114 MojoWriteData, | 119 MojoWriteData, |
115 MojoBeginWriteData, | 120 MojoBeginWriteData, |
116 MojoEndWriteData, | 121 MojoEndWriteData, |
117 MojoReadData, | 122 MojoReadData, |
118 MojoBeginReadData, | 123 MojoBeginReadData, |
119 MojoEndReadData, | 124 MojoEndReadData, |
120 MojoCreateSharedBuffer, | 125 MojoCreateSharedBuffer, |
121 MojoDuplicateBufferHandle, | 126 MojoDuplicateBufferHandle, |
122 MojoMapBuffer, | 127 MojoMapBuffer, |
123 MojoUnmapBuffer | 128 MojoUnmapBuffer |
124 }; | 129 }; |
125 return system_thunks; | 130 return system_thunks; |
126 } | 131 } |
| 132 #endif |
| 133 |
127 | 134 |
128 // Use this type for the function found by dynamically discovering it in | 135 // Use this type for the function found by dynamically discovering it in |
129 // a DSO linked with mojo_system. For example: | 136 // a DSO linked with mojo_system. For example: |
130 // MojoSetSystemThunksFn mojo_set_system_thunks_fn = | 137 // MojoSetSystemThunksFn mojo_set_system_thunks_fn = |
131 // reinterpret_cast<MojoSetSystemThunksFn>(app_library.GetFunctionPointer( | 138 // reinterpret_cast<MojoSetSystemThunksFn>(app_library.GetFunctionPointer( |
132 // "MojoSetSystemThunks")); | 139 // "MojoSetSystemThunks")); |
133 // The expected size of |system_thunks} is returned. | 140 // The expected size of |system_thunks} is returned. |
134 // The contents of |system_thunks| are copied. | 141 // The contents of |system_thunks| are copied. |
135 typedef size_t (*MojoSetSystemThunksFn)(const MojoSystemThunks* system_thunks); | 142 typedef size_t (*MojoSetSystemThunksFn)( |
| 143 const struct MojoSystemThunks* system_thunks); |
136 | 144 |
137 #endif // MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_ | 145 #endif // MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_ |
OLD | NEW |