nlib
Config_osx.h
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_CONFIG_OSX_H_
4 #define INCLUDE_NN_NLIB_CONFIG_OSX_H_
5 #ifndef INCLUDE_NN_NLIB_CONFIG_H_
6 # error do not include directly
7 #endif
8 
9 #include <mach-o/dyld.h>
10 #include <TargetConditionals.h>
11 
12 #if defined(__clang__)
13 # include "nn/nlib/Config_clang.h"
14 #else
15 # error
16 #endif
17 
18 #define NLIB_HAS_VIRTUALMEMORY
19 
20 #define NLIB_PATHMAPPER_FORSAMPLE \
21  nlib_ns::NativePathMapper g_PathMapper; \
22  inline void InitPathMapperForSample() { \
23  g_PathMapper.AddMap(CMAKE_CURRENT_BINARY_DIR, "nlibpath:
24  g_PathMapper.AddMap(CMAKE_CURRENT_BINARY_DIR, "nlibpath:
25  }
26 
27 /*
28 #define NLIB_PATHMAPPER_FORSAMPLE \
29  nlib_ns::NativePathMapper g_PathMapper; \
30  inline void InitPathMapperForSample() { \
31  char dir[1024]; \
32  uint32_t size = sizeof(dir); \
33  _NSGetExecutablePath(dir, &size); \
34  *const_cast<char*>(nlib_strrchr(dir, '/')) = '\0'; \
35  g_PathMapper.AddMap(dir, "nlibpath:///readonly/"); \
36  g_PathMapper.AddMap(dir, "nlibpath:///readwrite/"); \
37  }
38 */
39 
40 #ifndef NLIB_OSX_MAINFUNC_NAME
41 # define NLIB_OSX_MAINFUNC_NAME main
42 #endif
43 
44 #define NLIB_MAINFUNC extern "C" int NLIB_OSX_MAINFUNC_NAME(int argc, char** argv) { \
45  bool result = SampleMain(argc, argv); nlib_printf(result ? "OK\n" : "NG\n"); \
46  return result ? 0 : 1; }
47 
48 #define NLIB_THREAD_EXIT_CPP_THROW_NLIB_EXCEPTION
49 #ifdef NLIB_EXCEPTION_ENABLED
50 #undef nlib_thread_cleanup_push
51 #undef nlib_thread_cleanup_pop
52 #define nlib_thread_cleanup_push(fn, arg) pthread_cleanup_push(fn, arg); try {
53 #define nlib_thread_cleanup_pop(exec) } catch(...) { { pthread_cleanup_pop(1) throw; } \
54  pthread_cleanup_pop(exec)
55 #endif
56 
57 #endif // INCLUDE_NN_NLIB_CONFIG_OSX_H_