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