File: nut_platform.h

package info (click to toggle)
nut 2.7.2-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 10,220 kB
  • ctags: 8,034
  • sloc: ansic: 66,197; sh: 12,738; python: 2,196; cpp: 1,710; makefile: 1,335; perl: 702; xml: 10
file content (125 lines) | stat: -rw-r--r-- 3,596 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef nut_platform_h
#define nut_platform_h

/**
 *  \brief  Platform-specific checks
 *
 *  The header performs checks to resolve the actual build platform.
 *  It defines macra that may be later used to produce platform-tailored
 *  code.
 *
 *  Be careful when writing platform-specific code; avoid that if possible.
 *
 *  References:
 *  http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system
 *
 *  \author  Vaclav Krpec  <VaclavKrpec@Eaton.com>
 *  \date    2012/10/12
 */

/*
 * In case doxygen source doc isn't generated
 * (which is the case at time of writing this),
 * just check the doxygen-documented (i.e. "**"
 * prefixed) NUT_PLATFORM_* macra, below.
 */

/* Apple Mac OS X, iOS and Darwin */
#if (defined __APPLE__ && defined __MACH__)
	/** Apple OS based on Mach ukernel */
	#define NUT_PLATFORM_APPLE_MACH

	#include <TargetConditionals.h>

	#if (defined TARGET_OS_EMBEDDED)
		/** iOS (implies \ref NUT_PLATFORM_APPLE_MACH) */
		#define NUT_PLATFORM_APPLE_IOS
	#endif
	#if (defined TARGET_IPHONE_SIMULATOR)
		/** iOS simulator (implies \ref NUT_PLATFORM_APPLE_MACH) */
		#define NUT_PLATFORM_APPLE_IOS_SIMULATOR
	#endif
	#if (defined TARGET_OS_IPHONE)
		/** iPhone (implies \ref NUT_PLATFORM_APPLE_MACH) */
		#define NUT_PLATFORM_APPLE_IPHONE
	#endif
	#if (defined TARGET_OS_MAC)
		/** Mac OS X (implies \ref NUT_PLATFORM_APPLE_MACH) */
		#define NUT_PLATFORM_APPLE_OSX
	#endif
#endif

/*
 * GCC AIX issue: __unix__ nor __unix are not defined in older GCC
 * Addressed in GCC 4.7.0, see
 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39950
 * Remove if no longer necessary
 */
#if (defined _AIX && !defined __unix__)
	#define __unix__
#endif

/* Microsoft Windows */
#if (defined _WIN32 || defined _WIN64)
	/** Windows */
	#define NUT_PLATFORM_MS_WINDOWS

	#if (defined NTDDI_WIN8 && NTDDI_VERSION >= NTDDI_WIN8)
		/** Windows 8 */
		#define NUT_PLATFORM_MS_WINDOWS8
	#endif

/* UNIX */
/* Note that Apple OSX doesn't define __unix__ nor __unix; are they ashamed or something? */
#elif (defined __unix__ || defined __unix || defined NUT_PLATFORM_APPLE_MACH)
	#include <sys/param.h>
	#include <unistd.h>

	/** UNIX */
	#define NUT_PLATFORM_UNIX

	#if (defined _POSIX_VERSION)
		/** POSIX (implies \ref NUT_PLATFORM_UNIX), expands to POSIX version */
		#define NUT_PLATFORM_POSIX _POSIX_VERSION
	#endif

	#if (defined __linux__)
		/** Linux (implies \ref NUT_PLATFORM_UNIX) */
		#define NUT_PLATFORM_LINUX
	#endif
	#if (defined __sun && defined __SVR4)
		/** Solaris (implies \ref NUT_PLATFORM_UNIX) */
		#define NUT_PLATFORM_SOLARIS
	#endif
	#if (defined __hpux)
		/** Hewlett-Packard HP-UX (implies \ref NUT_PLATFORM_UNIX) */
		#define NUT_PLATFORM_HPUX
	#endif
	#if (defined _AIX)
		/** AIX (implies \ref NUT_PLATFORM_UNIX) */
		#define NUT_PLATFORM_AIX
	#endif

	/* Note that BSD is defined in sys/param.h */
	#if (defined BSD)
		/** BSD (implies \ref NUT_PLATFORM_UNIX) */
		#define NUT_PLATFORM_BSD

		#if (defined __DragonFly__)
			/** DragonFly (implies \ref NUT_PLATFORM_UNIX, \ref NUT_PLATFORM_BSD) */
			#define NUT_PLATFORM_DRAGONFLY
		#elif (defined __FreeBSD__)
			/** FreeBSD (implies \ref NUT_PLATFORM_UNIX, \ref NUT_PLATFORM_BSD) */
			#define NUT_PLATFORM_FREEBSD
		#elif (defined __OpenBSD__)
			/** OpenBSD (implies \ref NUT_PLATFORM_UNIX, \ref NUT_PLATFORM_BSD) */
			#define NUT_PLATFORM_OPENBSD
		#elif (defined __NetBSD__)
			/** NetBSD (implies \ref NUT_PLATFORM_UNIX, \ref NUT_PLATFORM_BSD) */
			#define NUT_PLATFORM_NETBSD
		#endif
	#endif
#endif

#endif  /* end of #ifndef nut_platform_h */