| Index: mojo/monacl/libmojo.cc
|
| diff --git a/mojo/monacl/libmojo.cc b/mojo/monacl/libmojo.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7c6a4249569d2895e52889e18c83eceec531078a
|
| --- /dev/null
|
| +++ b/mojo/monacl/libmojo.cc
|
| @@ -0,0 +1,408 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +// WARNING this file was generated by generate_monacl_bindings.py
|
| +// Do not edit by hand.
|
| +
|
| +#include <errno.h>
|
| +
|
| +#include "mojo/public/c/system/core.h"
|
| +#include "native_client/src/public/imc_types.h"
|
| +#include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h"
|
| +
|
| +int imc_sendmsg(int desc, struct NaClAbiNaClImcMsgHdr const *nmhp, int flags) {
|
| + int retval = NACL_SYSCALL(imc_sendmsg)(desc, nmhp, flags);
|
| + if (retval < 0) {
|
| + errno = -retval;
|
| + }
|
| + return retval;
|
| +}
|
| +
|
| +#define NACL_MOJO_DESC 5
|
| +
|
| +MojoResult MojoCreateSharedBuffer(
|
| + const struct MojoCreateSharedBufferOptions* options,
|
| + uint64_t num_bytes,
|
| + MojoHandle* shared_buffer_handle){
|
| + uint32_t params[5];
|
| + MojoResult result;
|
| + params[0] = 0;
|
| + params[1] = reinterpret_cast<uint32_t>(options);
|
| + params[2] = reinterpret_cast<uint32_t>(&num_bytes);
|
| + params[3] = reinterpret_cast<uint32_t>(shared_buffer_handle);
|
| + params[4] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoDuplicateBufferHandle(
|
| + MojoHandle buffer_handle,
|
| + const struct MojoDuplicateBufferHandleOptions* options,
|
| + MojoHandle* new_buffer_handle){
|
| + uint32_t params[5];
|
| + MojoResult result;
|
| + params[0] = 1;
|
| + params[1] = reinterpret_cast<uint32_t>(&buffer_handle);
|
| + params[2] = reinterpret_cast<uint32_t>(options);
|
| + params[3] = reinterpret_cast<uint32_t>(new_buffer_handle);
|
| + params[4] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoMapBuffer(
|
| + MojoHandle buffer_handle,
|
| + uint64_t offset,
|
| + uint64_t num_bytes,
|
| + void** buffer,
|
| + MojoMapBufferFlags flags){
|
| + uint32_t params[7];
|
| + MojoResult result;
|
| + params[0] = 2;
|
| + params[1] = reinterpret_cast<uint32_t>(&buffer_handle);
|
| + params[2] = reinterpret_cast<uint32_t>(&offset);
|
| + params[3] = reinterpret_cast<uint32_t>(&num_bytes);
|
| + params[4] = reinterpret_cast<uint32_t>(buffer);
|
| + params[5] = reinterpret_cast<uint32_t>(&flags);
|
| + params[6] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoUnmapBuffer(void* buffer){
|
| + uint32_t params[3];
|
| + MojoResult result;
|
| + params[0] = 3;
|
| + params[1] = reinterpret_cast<uint32_t>(&buffer);
|
| + params[2] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoCreateDataPipe(
|
| + const struct MojoCreateDataPipeOptions* options,
|
| + MojoHandle* data_pipe_producer_handle,
|
| + MojoHandle* data_pipe_consumer_handle){
|
| + uint32_t params[5];
|
| + MojoResult result;
|
| + params[0] = 4;
|
| + params[1] = reinterpret_cast<uint32_t>(options);
|
| + params[2] = reinterpret_cast<uint32_t>(data_pipe_producer_handle);
|
| + params[3] = reinterpret_cast<uint32_t>(data_pipe_consumer_handle);
|
| + params[4] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoWriteData(
|
| + MojoHandle data_pipe_producer_handle,
|
| + const void* elements,
|
| + uint32_t* num_bytes,
|
| + MojoWriteDataFlags flags){
|
| + uint32_t params[6];
|
| + MojoResult result;
|
| + params[0] = 5;
|
| + params[1] = reinterpret_cast<uint32_t>(&data_pipe_producer_handle);
|
| + params[2] = reinterpret_cast<uint32_t>(elements);
|
| + params[3] = reinterpret_cast<uint32_t>(num_bytes);
|
| + params[4] = reinterpret_cast<uint32_t>(&flags);
|
| + params[5] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoBeginWriteData(
|
| + MojoHandle data_pipe_producer_handle,
|
| + void** buffer,
|
| + uint32_t* buffer_num_bytes,
|
| + MojoWriteDataFlags flags){
|
| + uint32_t params[6];
|
| + MojoResult result;
|
| + params[0] = 6;
|
| + params[1] = reinterpret_cast<uint32_t>(&data_pipe_producer_handle);
|
| + params[2] = reinterpret_cast<uint32_t>(buffer);
|
| + params[3] = reinterpret_cast<uint32_t>(buffer_num_bytes);
|
| + params[4] = reinterpret_cast<uint32_t>(&flags);
|
| + params[5] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoEndWriteData(
|
| + MojoHandle data_pipe_producer_handle,
|
| + uint32_t num_bytes_written){
|
| + uint32_t params[4];
|
| + MojoResult result;
|
| + params[0] = 7;
|
| + params[1] = reinterpret_cast<uint32_t>(&data_pipe_producer_handle);
|
| + params[2] = reinterpret_cast<uint32_t>(&num_bytes_written);
|
| + params[3] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoReadData(
|
| + MojoHandle data_pipe_consumer_handle,
|
| + void* elements,
|
| + uint32_t* num_bytes,
|
| + MojoReadDataFlags flags){
|
| + uint32_t params[6];
|
| + MojoResult result;
|
| + params[0] = 8;
|
| + params[1] = reinterpret_cast<uint32_t>(&data_pipe_consumer_handle);
|
| + params[2] = reinterpret_cast<uint32_t>(elements);
|
| + params[3] = reinterpret_cast<uint32_t>(num_bytes);
|
| + params[4] = reinterpret_cast<uint32_t>(&flags);
|
| + params[5] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoBeginReadData(
|
| + MojoHandle data_pipe_consumer_handle,
|
| + const void** buffer,
|
| + uint32_t* buffer_num_bytes,
|
| + MojoReadDataFlags flags){
|
| + uint32_t params[6];
|
| + MojoResult result;
|
| + params[0] = 9;
|
| + params[1] = reinterpret_cast<uint32_t>(&data_pipe_consumer_handle);
|
| + params[2] = reinterpret_cast<uint32_t>(buffer);
|
| + params[3] = reinterpret_cast<uint32_t>(buffer_num_bytes);
|
| + params[4] = reinterpret_cast<uint32_t>(&flags);
|
| + params[5] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoEndReadData(
|
| + MojoHandle data_pipe_consumer_handle,
|
| + uint32_t num_bytes_read){
|
| + uint32_t params[4];
|
| + MojoResult result;
|
| + params[0] = 10;
|
| + params[1] = reinterpret_cast<uint32_t>(&data_pipe_consumer_handle);
|
| + params[2] = reinterpret_cast<uint32_t>(&num_bytes_read);
|
| + params[3] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoTimeTicks MojoGetTimeTicksNow(){
|
| + uint32_t params[2];
|
| + MojoTimeTicks result;
|
| + params[0] = 11;
|
| + params[1] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoClose(MojoHandle handle){
|
| + uint32_t params[3];
|
| + MojoResult result;
|
| + params[0] = 12;
|
| + params[1] = reinterpret_cast<uint32_t>(&handle);
|
| + params[2] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoWait(
|
| + MojoHandle handle,
|
| + MojoHandleSignals signals,
|
| + MojoDeadline deadline){
|
| + uint32_t params[5];
|
| + MojoResult result;
|
| + params[0] = 13;
|
| + params[1] = reinterpret_cast<uint32_t>(&handle);
|
| + params[2] = reinterpret_cast<uint32_t>(&signals);
|
| + params[3] = reinterpret_cast<uint32_t>(&deadline);
|
| + params[4] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoWaitMany(
|
| + const MojoHandle* handles,
|
| + const MojoHandleSignals* signals,
|
| + uint32_t num_handles,
|
| + MojoDeadline deadline){
|
| + uint32_t params[6];
|
| + MojoResult result;
|
| + params[0] = 14;
|
| + params[1] = reinterpret_cast<uint32_t>(handles);
|
| + params[2] = reinterpret_cast<uint32_t>(signals);
|
| + params[3] = reinterpret_cast<uint32_t>(&num_handles);
|
| + params[4] = reinterpret_cast<uint32_t>(&deadline);
|
| + params[5] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoCreateMessagePipe(
|
| + const struct MojoCreateMessagePipeOptions* options,
|
| + MojoHandle* message_pipe_handle0,
|
| + MojoHandle* message_pipe_handle1){
|
| + uint32_t params[5];
|
| + MojoResult result;
|
| + params[0] = 15;
|
| + params[1] = reinterpret_cast<uint32_t>(options);
|
| + params[2] = reinterpret_cast<uint32_t>(message_pipe_handle0);
|
| + params[3] = reinterpret_cast<uint32_t>(message_pipe_handle1);
|
| + params[4] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoWriteMessage(
|
| + MojoHandle message_pipe_handle,
|
| + const void* bytes,
|
| + uint32_t num_bytes,
|
| + const MojoHandle* handles,
|
| + uint32_t num_handles,
|
| + MojoWriteMessageFlags flags){
|
| + uint32_t params[8];
|
| + MojoResult result;
|
| + params[0] = 16;
|
| + params[1] = reinterpret_cast<uint32_t>(&message_pipe_handle);
|
| + params[2] = reinterpret_cast<uint32_t>(bytes);
|
| + params[3] = reinterpret_cast<uint32_t>(&num_bytes);
|
| + params[4] = reinterpret_cast<uint32_t>(handles);
|
| + params[5] = reinterpret_cast<uint32_t>(&num_handles);
|
| + params[6] = reinterpret_cast<uint32_t>(&flags);
|
| + params[7] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +MojoResult MojoReadMessage(
|
| + MojoHandle message_pipe_handle,
|
| + void* bytes,
|
| + uint32_t* num_bytes,
|
| + MojoHandle* handles,
|
| + uint32_t* num_handles,
|
| + MojoReadMessageFlags flags){
|
| + uint32_t params[8];
|
| + MojoResult result;
|
| + params[0] = 17;
|
| + params[1] = reinterpret_cast<uint32_t>(&message_pipe_handle);
|
| + params[2] = reinterpret_cast<uint32_t>(bytes);
|
| + params[3] = reinterpret_cast<uint32_t>(num_bytes);
|
| + params[4] = reinterpret_cast<uint32_t>(handles);
|
| + params[5] = reinterpret_cast<uint32_t>(num_handles);
|
| + params[6] = reinterpret_cast<uint32_t>(&flags);
|
| + params[7] = reinterpret_cast<uint32_t>(&result);
|
| + NaClAbiNaClImcMsgIoVec iov[1] = {
|
| + {params, sizeof(params)}
|
| + };
|
| + NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
|
| + if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
|
| + result = MOJO_RESULT_INVALID_ARGUMENT;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +
|
|
|