nlib
Config_linux.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_LINUX_H_
17
#define INCLUDE_NN_NLIB_CONFIG_LINUX_H_
18
#ifndef INCLUDE_NN_NLIB_CONFIG_H_
19
# error do not include directly
20
#endif
21
22
#include <cxxabi.h>
23
24
#if defined(__linux__)
25
# if defined(__clang__)
26
# include "nn/nlib/Config_clang.h"
27
# elif defined(__GNUC__)
28
# include "nn/nlib/Config_gcc.h"
29
# else
30
# error
31
# endif
32
# define NLIB_HAS_VIRTUALMEMORY
33
#endif
34
35
#define NLIB_PATHMAPPER_FORSAMPLE \
36
extern "C" ssize_t readlink(const char *path, char *buf, size_t bufsiz); \
37
extern "C" char *getcwd(char *buf, size_t size); \
38
nlib_ns::NativePathMapper g_pathmapper; \
39
nlib_ns::NativePathMapper& g_PathMapper = g_pathmapper; \
40
inline void InitPathMapperForSample() { \
41
char dir[1024]; \
42
ssize_t cnt = readlink("/proc/self/exe", dir, 1024); \
43
if (cnt == -1) { \
44
char* cwd = getcwd(dir, 1024); \
45
if (cwd) { \
46
g_pathmapper.AddMap(cwd, "nlibpath:
47
g_pathmapper.AddMap(cwd, "nlibpath:
48
} \
49
} else { \
50
dir[cnt] = '\0'; \
51
*const_cast<char*>(nlib_strrchr(dir, '/')) = '\0'; \
52
g_pathmapper.AddMap(dir, "nlibpath:
53
g_pathmapper.AddMap(dir, "nlibpath:
54
} \
55
}
56
57
#define NLIB_MAINFUNC int main(int argc, char** argv) { \
58
bool result = SampleMain(argc, argv); nlib_printf(result ? "OK\n" : "NG\n"); \
59
return result ? 0 : 1; }
60
61
#ifdef NLIB_ALPINE
62
#define NLIB_THREAD_EXIT_CPP_THROW_NLIB_EXCEPTION
63
#endif
64
65
#ifndef NLIB_THREAD_EXIT_CPP_THROW_NLIB_EXCEPTION
66
# define NLIB_RETHROW_UNWIND catch (abi::__forced_unwind&)
67
#else
68
#ifdef __cpp_exceptions
69
#undef nlib_thread_cleanup_push
70
#undef nlib_thread_cleanup_pop
71
#define nlib_thread_cleanup_push(fn, arg) pthread_cleanup_push(fn, arg); try {
72
#define nlib_thread_cleanup_pop(exec) } catch(...) { { pthread_cleanup_pop(1) throw; } \
73
pthread_cleanup_pop(exec)
74
#endif
75
#endif
76
77
#endif // INCLUDE_NN_NLIB_CONFIG_LINUX_H_
© 2012-2017 Nintendo Co., Ltd. All rights reserved.