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