diff options
author | Eric Engestrom <[email protected]> | 2019-08-01 14:48:26 +0100 |
---|---|---|
committer | Eric Engestrom <[email protected]> | 2019-08-02 18:38:52 +0100 |
commit | 362e9d8682a5eb3808fd574d4a21982a58ecafa7 (patch) | |
tree | c88eea2084959d9eca3074cb3ace533c23d5e8f7 /src/util | |
parent | 9d5beab4414f483ad94372d36c2c6f23f6c1ca41 (diff) |
util: introduce detect_os.h
Mostly copied from src/gallium/include/pipe/p_config.h, so I kept its
copyright and authorship.
Other than the obvious rename, the big difference is that these are
always defined, to be used as `#if DETECT_OS_LINUX`.
Signed-off-by: Eric Engestrom <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/detect_os.h | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/src/util/detect_os.h b/src/util/detect_os.h new file mode 100644 index 00000000000..6506948e035 --- /dev/null +++ b/src/util/detect_os.h @@ -0,0 +1,131 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright 2008 VMware, Inc. */ + +/** + * Auto-detect the operating system family. + * + * See also: + * - http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html + * - echo | gcc -dM -E - | sort + * - http://msdn.microsoft.com/en-us/library/b0084kay.aspx + * + * @author José Fonseca <[email protected]> + */ + +#ifndef DETECT_OS_H +#define DETECT_OS_H + +#if defined(__linux__) +#define DETECT_OS_LINUX 1 +#define DETECT_OS_UNIX 1 +#endif + +/* + * Android defines __linux__, so DETECT_OS_LINUX and DETECT_OS_UNIX will + * also be defined. + */ +#if defined(ANDROID) +#define DETECT_OS_ANDROID 1 +#endif + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#define DETECT_OS_FREEBSD 1 +#define DETECT_OS_BSD 1 +#define DETECT_OS_UNIX 1 +#endif + +#if defined(__OpenBSD__) +#define DETECT_OS_OPENBSD 1 +#define DETECT_OS_BSD 1 +#define DETECT_OS_UNIX 1 +#endif + +#if defined(__NetBSD__) +#define DETECT_OS_NETBSD 1 +#define DETECT_OS_BSD 1 +#define DETECT_OS_UNIX 1 +#endif + +#if defined(__DragonFly__) +#define DETECT_OS_DRAGONFLY 1 +#define DETECT_OS_BSD 1 +#define DETECT_OS_UNIX 1 +#endif + +#if defined(__GNU__) +#define DETECT_OS_HURD 1 +#define DETECT_OS_UNIX 1 +#endif + +#if defined(__sun) +#define DETECT_OS_SOLARIS 1 +#define DETECT_OS_UNIX 1 +#endif + +#if defined(__APPLE__) +#define DETECT_OS_APPLE 1 +#define DETECT_OS_UNIX 1 +#endif + +#if defined(_WIN32) || defined(WIN32) +#define DETECT_OS_WINDOWS 1 +#endif + +#if defined(__HAIKU__) +#define DETECT_OS_HAIKU 1 +#define DETECT_OS_UNIX 1 +#endif + +#if defined(__CYGWIN__) +#define DETECT_OS_CYGWIN 1 +#define DETECT_OS_UNIX 1 +#endif + + +/* + * Make sure DETECT_OS_* are always defined, so that they can be used with #if + */ +#ifndef DETECT_OS_ANDROID +#define DETECT_OS_ANDROID 0 +#endif +#ifndef DETECT_OS_APPLE +#define DETECT_OS_APPLE 0 +#endif +#ifndef DETECT_OS_BSD +#define DETECT_OS_BSD 0 +#endif +#ifndef DETECT_OS_CYGWIN +#define DETECT_OS_CYGWIN 0 +#endif +#ifndef DETECT_OS_DRAGONFLY +#define DETECT_OS_DRAGONFLY 0 +#endif +#ifndef DETECT_OS_FREEBSD +#define DETECT_OS_FREEBSD 0 +#endif +#ifndef DETECT_OS_HAIKU +#define DETECT_OS_HAIKU 0 +#endif +#ifndef DETECT_OS_HURD +#define DETECT_OS_HURD 0 +#endif +#ifndef DETECT_OS_LINUX +#define DETECT_OS_LINUX 0 +#endif +#ifndef DETECT_OS_NETBSD +#define DETECT_OS_NETBSD 0 +#endif +#ifndef DETECT_OS_OPENBSD +#define DETECT_OS_OPENBSD 0 +#endif +#ifndef DETECT_OS_SOLARIS +#define DETECT_OS_SOLARIS 0 +#endif +#ifndef DETECT_OS_UNIX +#define DETECT_OS_UNIX 0 +#endif +#ifndef DETECT_OS_WINDOWS +#define DETECT_OS_WINDOWS 0 +#endif + +#endif /* DETECT_OS_H */ |