1 : /*
2 : * Copyright 2008 The Native Client Authors. All rights reserved.
3 : * Use of this source code is governed by a BSD-style license that can
4 : * be found in the LICENSE file.
5 : */
6 :
7 :
8 : // NaCl inter-module communication primitives.
9 :
10 : #include "native_client/src/shared/imc/nacl_imc.h"
11 : #include "native_client/src/shared/imc/nacl_imc_c.h"
12 :
13 : //
14 : // "C" bindings
15 : //
16 :
17 0 : int NaClGetLastErrorString(char* buffer, size_t length) {
18 0 : return nacl::GetLastErrorString(buffer, length);
19 : }
20 :
21 0 : NaClHandle NaClBoundSocket(const NaClSocketAddress* address) {
22 : return nacl::BoundSocket(
23 0 : reinterpret_cast<const nacl::SocketAddress*>(address));
24 : }
25 :
26 88 : int NaClSocketPair(NaClHandle pair[2]) {
27 88 : return nacl::SocketPair(pair);
28 : }
29 :
30 172 : int NaClClose(NaClHandle handle) {
31 172 : return nacl::Close(handle);
32 : }
33 :
34 0 : int NaClWouldBlock() {
35 0 : return nacl::WouldBlock();
36 : }
37 :
38 : int NaClSendDatagram(NaClHandle socket, const NaClMessageHeader* message,
39 9327 : int flags) {
40 : return nacl::SendDatagram(
41 : socket,
42 : reinterpret_cast<const nacl::MessageHeader*>(message),
43 9327 : flags);
44 : }
45 :
46 : int NaClSendDatagramTo(const NaClMessageHeader* message,
47 0 : int flags, const NaClSocketAddress* name) {
48 : return nacl::SendDatagramTo(
49 : reinterpret_cast<const nacl::MessageHeader*>(message),
50 : flags,
51 0 : reinterpret_cast<const nacl::SocketAddress*>(name));
52 : }
53 :
54 : int NaClReceiveDatagram(NaClHandle socket, NaClMessageHeader* message,
55 9346 : int flags) {
56 : return nacl::ReceiveDatagram(socket,
57 : reinterpret_cast<nacl::MessageHeader*>(message),
58 9346 : flags);
59 : }
60 :
61 11 : NaClHandle NaClCreateMemoryObject(size_t length, int executable) {
62 11 : return nacl::CreateMemoryObject(length, executable ? true : false);
63 : }
64 :
65 : void* NaClMap(void* start, size_t length, int prot, int flags,
66 12318 : NaClHandle memory, off_t offset) {
67 12318 : return nacl::Map(start, length, prot, flags, memory, offset);
68 : }
69 :
70 8 : int NaClUnmap(void* start, size_t length) {
71 8 : return nacl::Unmap(start, length);
72 : }
|