nlib
Config_osx.h
1 
2 /*---------------------------------------------------------------------------*
3 
4  Project: CrossRoad
5  Copyright (C)2012-2016 Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12 
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  inline void InitPathMapperForSample() { \
36  g_PathMapper.AddMap(CMAKE_CURRENT_BINARY_DIR, "nlibpath:
37  g_PathMapper.AddMap(CMAKE_CURRENT_BINARY_DIR, "nlibpath:
38  }
39 
40 /*
41 #define NLIB_PATHMAPPER_FORSAMPLE \
42  nlib_ns::NativePathMapper g_PathMapper; \
43  inline void InitPathMapperForSample() { \
44  char dir[1024]; \
45  uint32_t size = sizeof(dir); \
46  _NSGetExecutablePath(dir, &size); \
47  *const_cast<char*>(nlib_strrchr(dir, '/')) = '\0'; \
48  g_PathMapper.AddMap(dir, "nlibpath:///readonly/"); \
49  g_PathMapper.AddMap(dir, "nlibpath:///readwrite/"); \
50  }
51 */
52 
53 #ifndef NLIB_OSX_MAINFUNC_NAME
54 # define NLIB_OSX_MAINFUNC_NAME main
55 #endif
56 
57 #define NLIB_MAINFUNC extern "C" int NLIB_OSX_MAINFUNC_NAME(int argc, char** argv) { \
58  bool result = SampleMain(argc, argv); nlib_printf(result ? "OK\n" : "NG\n"); \
59  return result ? 0 : 1; }
60 
61 #define NLIB_THREAD_EXIT_CPP_THROW_NLIB_EXCEPTION
62 #ifdef NLIB_EXCEPTION_ENABLED
63 #undef nlib_thread_cleanup_push
64 #undef nlib_thread_cleanup_pop
65 #define nlib_thread_cleanup_push(fn, arg) pthread_cleanup_push(fn, arg); try {
66 #define nlib_thread_cleanup_pop(exec) } catch(...) { { pthread_cleanup_pop(1) throw; } \
67  pthread_cleanup_pop(exec)
68 #endif
69 
70 #endif // INCLUDE_NN_NLIB_CONFIG_OSX_H_