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