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