2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
9 #include "native_client/src/shared/imc/nacl_imc_c.h"
11 #define MEMORY_SIZE (1 << 20)
13 /* Writes the last error message to the standard error. */
14 static void failWithErrno(const char* message) {
17 if (0 == NaClGetLastErrorString(buffer, sizeof(buffer))) {
18 fprintf(stderr, "%s: %s\n", message, buffer);
23 int main(int argc, char* argv[]) {
26 UNREFERENCED_PARAMETER(argc);
27 UNREFERENCED_PARAMETER(argv);
29 /* Check not executable shared memory. */
30 handle = NaClCreateMemoryObject(MEMORY_SIZE, 0);
31 if (NACL_INVALID_HANDLE == handle) {
32 failWithErrno("NaClCreateMemoryObject(size, 0)");
34 if (0 != NaClClose(handle)) {
35 failWithErrno("NaClClose(0)");
38 /* Check executable shared memory. */
39 handle = NaClCreateMemoryObject(MEMORY_SIZE, 1);
40 #ifdef __native_client__
41 if (NACL_INVALID_HANDLE != handle) {
42 fprintf(stderr, "NaClCreateMemoryObject(size, 1) returned a valid shm. "
43 "It must return -1\n");
47 if (NACL_INVALID_HANDLE == handle) {
48 failWithErrno("NaClCreateMemoryObject(size, 1)");
50 if (0 != NaClClose(handle)) {
51 failWithErrno("NaClClose(1)");