• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: MIT */
2 /* Copyright 2008 VMware, Inc. */
3 
4 /**
5  * Auto-detect the operating system family.
6  *
7  * See also:
8  * - http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
9  * - echo | gcc -dM -E - | sort
10  * - http://msdn.microsoft.com/en-us/library/b0084kay.aspx
11  *
12  * @author José Fonseca <jfonseca@vmware.com>
13  */
14 
15 #ifndef DETECT_OS_H
16 #define DETECT_OS_H
17 
18 #if defined(__linux__)
19 #define DETECT_OS_LINUX 1
20 #define DETECT_OS_UNIX 1
21 #endif
22 
23 /*
24  * Android defines __linux__, so DETECT_OS_LINUX and DETECT_OS_UNIX will
25  * also be defined.
26  */
27 #if defined(ANDROID)
28 #define DETECT_OS_ANDROID 1
29 #endif
30 
31 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
32 #define DETECT_OS_FREEBSD 1
33 #define DETECT_OS_BSD 1
34 #define DETECT_OS_UNIX 1
35 #endif
36 
37 #if defined(__OpenBSD__)
38 #define DETECT_OS_OPENBSD 1
39 #define DETECT_OS_BSD 1
40 #define DETECT_OS_UNIX 1
41 #endif
42 
43 #if defined(__NetBSD__)
44 #define DETECT_OS_NETBSD 1
45 #define DETECT_OS_BSD 1
46 #define DETECT_OS_UNIX 1
47 #endif
48 
49 #if defined(__DragonFly__)
50 #define DETECT_OS_DRAGONFLY 1
51 #define DETECT_OS_BSD 1
52 #define DETECT_OS_UNIX 1
53 #endif
54 
55 #if defined(__GNU__)
56 #define DETECT_OS_HURD 1
57 #define DETECT_OS_UNIX 1
58 #endif
59 
60 #if defined(__sun)
61 #define DETECT_OS_SOLARIS 1
62 #define DETECT_OS_UNIX 1
63 #endif
64 
65 #if defined(__APPLE__)
66 #define DETECT_OS_APPLE 1
67 #define DETECT_OS_UNIX 1
68 #endif
69 
70 #if defined(_WIN32) || defined(WIN32)
71 #define DETECT_OS_WINDOWS 1
72 #endif
73 
74 #if defined(__HAIKU__)
75 #define DETECT_OS_HAIKU 1
76 #define DETECT_OS_UNIX 1
77 #endif
78 
79 #if defined(__CYGWIN__)
80 #define DETECT_OS_CYGWIN 1
81 #define DETECT_OS_UNIX 1
82 #endif
83 
84 
85 /*
86  * Make sure DETECT_OS_* are always defined, so that they can be used with #if
87  */
88 #ifndef DETECT_OS_ANDROID
89 #define DETECT_OS_ANDROID 0
90 #endif
91 #ifndef DETECT_OS_APPLE
92 #define DETECT_OS_APPLE 0
93 #endif
94 #ifndef DETECT_OS_BSD
95 #define DETECT_OS_BSD 0
96 #endif
97 #ifndef DETECT_OS_CYGWIN
98 #define DETECT_OS_CYGWIN 0
99 #endif
100 #ifndef DETECT_OS_DRAGONFLY
101 #define DETECT_OS_DRAGONFLY 0
102 #endif
103 #ifndef DETECT_OS_FREEBSD
104 #define DETECT_OS_FREEBSD 0
105 #endif
106 #ifndef DETECT_OS_HAIKU
107 #define DETECT_OS_HAIKU 0
108 #endif
109 #ifndef DETECT_OS_HURD
110 #define DETECT_OS_HURD 0
111 #endif
112 #ifndef DETECT_OS_LINUX
113 #define DETECT_OS_LINUX 0
114 #endif
115 #ifndef DETECT_OS_NETBSD
116 #define DETECT_OS_NETBSD 0
117 #endif
118 #ifndef DETECT_OS_OPENBSD
119 #define DETECT_OS_OPENBSD 0
120 #endif
121 #ifndef DETECT_OS_SOLARIS
122 #define DETECT_OS_SOLARIS 0
123 #endif
124 #ifndef DETECT_OS_UNIX
125 #define DETECT_OS_UNIX 0
126 #endif
127 #ifndef DETECT_OS_WINDOWS
128 #define DETECT_OS_WINDOWS 0
129 #endif
130 
131 #endif /* DETECT_OS_H */
132