nlib
Config_freebsd.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_FREEBSD_H_
17
#define INCLUDE_NN_NLIB_CONFIG_FREEBSD_H_
18
#ifndef INCLUDE_NN_NLIB_CONFIG_H_
19
# error do not include directly
20
#endif
21
22
#if defined(__FreeBSD__)
23
#include <sys/param.h>
24
# if __FreeBSD_version < 1000000
25
# error nlib requires FreeBSD 10.0 or higher.
26
# endif
27
#endif
28
29
#if defined(__clang__)
30
# include "nn/nlib/Config_clang.h"
31
# elif defined(__GNUC__)
32
# include "nn/nlib/Config_gcc.h"
33
#else
34
# error
35
#endif
36
37
#define NLIB_HAS_VIRTUALMEMORY
38
39
#include <sys/types.h>
40
#include <sys/sysctl.h>
41
#include <cxxabi.h>
42
43
#define NLIB_PATHMAPPER_FORSAMPLE \
44
extern "C" char *getcwd(char *buf, size_t size); \
45
nlib_ns::NativePathMapper g_pathmapper; \
46
nlib_ns::NativePathMapper& g_PathMapper = g_pathmapper; \
47
inline void InitPathMapperForSample() { \
48
int mib[4]; \
49
mib[0] = CTL_KERN; \
50
mib[1] = KERN_PROC; \
51
mib[2] = KERN_PROC_PATHNAME; \
52
mib[3] = -1; \
53
char dir[1024]; \
54
size_t cb = sizeof(dir); \
55
int err = sysctl(mib, 4, dir, &cb, nullptr, 0); \
56
if (err != 0 || cb == 0 || nlib_strlen(dir) == 0) { \
57
char* cwd = getcwd(dir, 1024); \
58
if (cwd) { \
59
g_pathmapper.AddMap(cwd, "nlibpath:
60
g_pathmapper.AddMap(cwd, "nlibpath:
61
} \
62
} else { \
63
*const_cast<char*>(nlib_strrchr(dir, '/')) = '\0'; \
64
g_pathmapper.AddMap(dir, "nlibpath:
65
g_pathmapper.AddMap(dir, "nlibpath:
66
} \
67
}
68
69
#define NLIB_MAINFUNC int main(int argc, char** argv) { \
70
bool result = SampleMain(argc, argv); nlib_printf(result ? "OK\n" : "NG\n"); \
71
return result ? 0 : 1; }
72
73
#define NLIB_RETHROW_UNWIND catch (struct _Unwind_Exception&)
74
75
#endif // INCLUDE_NN_NLIB_CONFIG_FREEBSD_H_
© 2012-2017 Nintendo Co., Ltd. All rights reserved.