nlib
Config_linux.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_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
inline void InitPathMapperForSample() { \
40
char dir[1024]; \
41
ssize_t cnt = readlink("/proc/self/exe", dir, 1024); \
42
if (cnt == -1) { \
43
char* cwd = getcwd(dir, 1024); \
44
if (cwd) { \
45
g_PathMapper.AddMap(cwd, "nlibpath:
46
g_PathMapper.AddMap(cwd, "nlibpath:
47
} \
48
} else { \
49
dir[cnt] = '\0'; \
50
*const_cast<char*>(nlib_strrchr(dir, '/')) = '\0'; \
51
g_PathMapper.AddMap(dir, "nlibpath:
52
g_PathMapper.AddMap(dir, "nlibpath:
53
} \
54
}
55
56
#define NLIB_MAINFUNC int main(int argc, char** argv) { \
57
bool result = SampleMain(argc, argv); nlib_printf(result ? "OK\n" : "NG\n"); \
58
return result ? 0 : 1; }
59
60
#ifdef NLIB_ALPINE
61
#define NLIB_THREAD_EXIT_CPP_THROW_NLIB_EXCEPTION
62
#endif
63
64
#ifndef NLIB_THREAD_EXIT_CPP_THROW_NLIB_EXCEPTION
65
# define NLIB_RETHROW_UNWIND catch (abi::__forced_unwind&)
66
#else
67
#ifdef NLIB_EXCEPTION_ENABLED
68
#undef nlib_thread_cleanup_push
69
#undef nlib_thread_cleanup_pop
70
#define nlib_thread_cleanup_push(fn, arg) pthread_cleanup_push(fn, arg); try {
71
#define nlib_thread_cleanup_pop(exec) } catch(...) { { pthread_cleanup_pop(1) throw; } \
72
pthread_cleanup_pop(exec)
73
#endif
74
#endif
75
76
#endif // INCLUDE_NN_NLIB_CONFIG_LINUX_H_
© 2012-2016 Nintendo Co., Ltd. All rights reserved.