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 extern "C" int NLIB_OSX_MAINFUNC_NAME(int argc, char** argv) { \
59  bool result = SampleMain(argc, argv); nlib_printf(result ? "OK\n" : "NG\n"); \
60  return result ? 0 : 1; }
61 
62 #define NLIB_THREAD_EXIT_CPP_THROW_NLIB_EXCEPTION
63 #ifdef __cpp_exceptions
64 #undef nlib_thread_cleanup_push
65 #undef nlib_thread_cleanup_pop
66 #define nlib_thread_cleanup_push(fn, arg) pthread_cleanup_push(fn, arg); try {
67 #define nlib_thread_cleanup_pop(exec) } catch(...) { { pthread_cleanup_pop(1) throw; } \
68  pthread_cleanup_pop(exec)
69 #endif
70 
71 #endif // INCLUDE_NN_NLIB_CONFIG_OSX_H_