nlib
Config_cygwin.h
1
2
#pragma once
3
#ifndef INCLUDE_NN_NLIB_CONFIG_CYGWIN_H_
4
#define INCLUDE_NN_NLIB_CONFIG_CYGWIN_H_
5
#ifndef INCLUDE_NN_NLIB_CONFIG_H_
6
# error do not include directly
7
#endif
8
9
#if defined(__CYGWIN__)
10
# if defined(__clang__)
11
# include "nn/nlib/Config_clang.h"
12
# elif defined(__GNUC__)
13
# include "nn/nlib/Config_gcc.h"
14
# else
15
# error
16
# endif
17
# define NLIB_HAS_VIRTUALMEMORY
18
#endif
19
20
#define NLIB_PATHMAPPER_FORSAMPLE \
21
extern "C" ssize_t readlink(const char *path, char *buf, size_t bufsiz); \
22
extern "C" char *getcwd(char *buf, size_t size); \
23
nlib_ns::NativePathMapper g_PathMapper; \
24
inline void InitPathMapperForSample() { \
25
char dir[1024]; \
26
ssize_t cnt = readlink("/proc/self/exe", dir, 1024); \
27
if (cnt == -1) { \
28
char* cwd = getcwd(dir, 1024); \
29
if (cwd) { \
30
g_PathMapper.AddMap(cwd, "nlibpath:
31
g_PathMapper.AddMap(cwd, "nlibpath:
32
} \
33
} else { \
34
dir[cnt] = '\0'; \
35
*const_cast<char*>(nlib_strrchr(dir, '/')) = '\0'; \
36
g_PathMapper.AddMap(dir, "nlibpath:
37
g_PathMapper.AddMap(dir, "nlibpath:
38
} \
39
}
40
41
#define NLIB_MAINFUNC int main(int argc, char** argv) { \
42
bool result = SampleMain(argc, argv); nlib_printf(result ? "OK\n" : "NG\n"); \
43
return result ? 0 : 1; }
44
45
#define NLIB_THREAD_EXIT_CPP_THROW_NLIB_EXCEPTION
46
#ifdef NLIB_EXCEPTION_ENABLED
47
#undef nlib_thread_cleanup_push
48
#undef nlib_thread_cleanup_pop
49
#define nlib_thread_cleanup_push(fn, arg) pthread_cleanup_push(fn, arg); try {
50
#define nlib_thread_cleanup_pop(exec) } catch(...) { { pthread_cleanup_pop(1) throw; } \
51
pthread_cleanup_pop(exec)
52
#endif
53
54
#endif // INCLUDE_NN_NLIB_CONFIG_CYGWIN_H_
© 2012-2016 Nintendo Co., Ltd. All rights reserved.