1 // Copyright 2013 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.
5 #include "mojo/public/system/core_private.h"
10 static mojo::Core
* g_core
= NULL
;
14 MojoTimeTicks
MojoGetTimeTicksNow() {
16 return g_core
->GetTimeTicksNow();
19 MojoResult
MojoClose(MojoHandle handle
) {
21 return g_core
->Close(handle
);
24 MojoResult
MojoWait(MojoHandle handle
,
26 MojoDeadline deadline
) {
28 return g_core
->Wait(handle
, flags
, deadline
);
31 MojoResult
MojoWaitMany(const MojoHandle
* handles
,
32 const MojoWaitFlags
* flags
,
34 MojoDeadline deadline
) {
36 return g_core
->WaitMany(handles
, flags
, num_handles
, deadline
);
39 MojoResult
MojoCreateMessagePipe(MojoHandle
* message_pipe_handle0
,
40 MojoHandle
* message_pipe_handle1
) {
42 return g_core
->CreateMessagePipe(message_pipe_handle0
, message_pipe_handle1
);
45 MojoResult
MojoWriteMessage(MojoHandle message_pipe_handle
,
48 const MojoHandle
* handles
,
50 MojoWriteMessageFlags flags
) {
52 return g_core
->WriteMessage(message_pipe_handle
, bytes
, num_bytes
, handles
,
56 MojoResult
MojoReadMessage(MojoHandle message_pipe_handle
,
60 uint32_t* num_handles
,
61 MojoReadMessageFlags flags
) {
63 return g_core
->ReadMessage(message_pipe_handle
, bytes
, num_bytes
, handles
,
67 MojoResult
MojoCreateDataPipe(const MojoCreateDataPipeOptions
* options
,
68 MojoHandle
* data_pipe_producer_handle
,
69 MojoHandle
* data_pipe_consumer_handle
) {
71 return g_core
->CreateDataPipe(options
, data_pipe_producer_handle
,
72 data_pipe_consumer_handle
);
75 MojoResult
MojoWriteData(MojoHandle data_pipe_producer_handle
,
77 uint32_t* num_elements
,
78 MojoWriteDataFlags flags
) {
80 return g_core
->WriteData(data_pipe_producer_handle
, elements
, num_elements
,
84 MojoResult
MojoBeginWriteData(MojoHandle data_pipe_producer_handle
,
86 uint32_t* buffer_num_elements
,
87 MojoWriteDataFlags flags
) {
89 return g_core
->BeginWriteData(data_pipe_producer_handle
, buffer
,
90 buffer_num_elements
, flags
);
93 MojoResult
MojoEndWriteData(MojoHandle data_pipe_producer_handle
,
94 uint32_t num_elements_written
) {
96 return g_core
->EndWriteData(data_pipe_producer_handle
, num_elements_written
);
99 MojoResult
MojoReadData(MojoHandle data_pipe_consumer_handle
,
101 uint32_t* num_elements
,
102 MojoReadDataFlags flags
) {
104 return g_core
->ReadData(data_pipe_consumer_handle
, elements
, num_elements
,
108 MojoResult
MojoBeginReadData(MojoHandle data_pipe_consumer_handle
,
110 uint32_t* buffer_num_elements
,
111 MojoReadDataFlags flags
) {
113 return g_core
->BeginReadData(data_pipe_consumer_handle
, buffer
,
114 buffer_num_elements
, flags
);
117 MojoResult
MojoEndReadData(MojoHandle data_pipe_consumer_handle
,
118 uint32_t num_elements_read
) {
120 return g_core
->EndReadData(data_pipe_consumer_handle
, num_elements_read
);
123 MojoResult
MojoCreateSharedBuffer(
124 const struct MojoCreateSharedBufferOptions
* options
,
126 MojoHandle
* shared_buffer_handle
) {
128 return g_core
->CreateSharedBuffer(options
, num_bytes
, shared_buffer_handle
);
131 MojoResult
MojoDuplicateBufferHandle(
132 MojoHandle buffer_handle
,
133 const struct MojoDuplicateBufferHandleOptions
* options
,
134 MojoHandle
* new_buffer_handle
) {
136 return g_core
->DuplicateBufferHandle(buffer_handle
, options
,
140 MojoResult
MojoMapBuffer(MojoHandle buffer_handle
,
144 MojoMapBufferFlags flags
) {
146 return g_core
->MapBuffer(buffer_handle
, offset
, num_bytes
, buffer
, flags
);
149 MojoResult
MojoUnmapBuffer(void* buffer
) {
151 return g_core
->UnmapBuffer(buffer
);
162 void Core::Init(Core
* core
) {