nlib
Config_osx.h
1 
2 /*--------------------------------------------------------------------------------*
3  Project: CrossRoad
4  Copyright (C)Nintendo All rights reserved.
5 
6  These coded instructions, statements, and computer programs contain proprietary
7  information of Nintendo and/or its licensed developers and are protected by
8  national and international copyright laws. They may not be disclosed to third
9  parties or copied or duplicated in any form, in whole or in part, without the
10  prior written consent of Nintendo.
11 
12  The content herein is highly confidential and should be handled accordingly.
13  *--------------------------------------------------------------------------------*/
14 
15 #pragma once
16 #ifndef INCLUDE_NN_NLIB_CONFIG_OSX_H_
17 #define INCLUDE_NN_NLIB_CONFIG_OSX_H_
18 #ifndef INCLUDE_NN_NLIB_CONFIG_H_
19 #error do not include directly
20 #endif
21 
22 #include <mach-o/dyld.h>
23 #include <TargetConditionals.h>
24 
25 #if defined(__clang__)
26 #include "nn/nlib/Config_clang.h"
27 #else
28 #error
29 #endif
30 
31 #define NLIB_HAS_VIRTUALMEMORY
32 
33 #define NLIB_PATHMAPPER_FORSAMPLE \
34  nlib_ns::NativePathMapper g_pathmapper; \
35  nlib_ns::NativePathMapper& g_PathMapper = g_pathmapper; \
36  inline void InitPathMapperForSample() { \
37  g_pathmapper.AddMap(CMAKE_CURRENT_BINARY_DIR, "nlibpath:
38  g_pathmapper.AddMap(CMAKE_CURRENT_BINARY_DIR, "nlibpath:
39  }
40 
41 /*
42 #define NLIB_PATHMAPPER_FORSAMPLE \
43  nlib_ns::NativePathMapper g_pathmapper; \
44  inline void InitPathMapperForSample() { \
45  char dir[1024]; \
46  uint32_t size = sizeof(dir); \
47  _NSGetExecutablePath(dir, &size); \
48  *const_cast<char*>(nlib_strrchr(dir, '/')) = '\0'; \
49  g_pathmapper.AddMap(dir, "nlibpath:///readonly/"); \
50  g_pathmapper.AddMap(dir, "nlibpath:///readwrite/"); \
51  }
52 */
53 
54 #ifndef NLIB_OSX_MAINFUNC_NAME
55 #define NLIB_OSX_MAINFUNC_NAME main
56 #endif
57 
58 #define NLIB_MAINFUNC \
59  extern "C" int NLIB_OSX_MAINFUNC_NAME(int argc, char** argv) { \
60  bool result = SampleMain(argc, argv); \
61  nlib_printf(result ? "OK\n" : "NG\n"); \
62  return result ? 0 : 1; \
63  }
64 
65 #ifdef __cpp_exceptions
66 #define NLIB_THREAD_EXIT_CPP_THROW_NLIB_EXCEPTION
67 #undef nlib_thread_cleanup_push
68 #undef nlib_thread_cleanup_pop
69 #define nlib_thread_cleanup_push(fn, arg) \
70  pthread_cleanup_push(fn, arg); \
71  try {
72 #define nlib_thread_cleanup_pop(exec) \
73  } \
74  catch (...) { \
75  { pthread_cleanup_pop(1) throw; } \
76  pthread_cleanup_pop(exec)
77 #endif
78 
79 #endif // INCLUDE_NN_NLIB_CONFIG_OSX_H_