aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2020-04-24 12:29:49 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2020-04-24 12:29:49 -0400
commit436ce68ecd41ad66e7a0605b47b5814582db8538 (patch)
tree4c54676d3ef16f3cae4244f94bdb1cb23a514926 /include
parentd570692d29d5dade7882ee19ca8d992a8960201d (diff)
downloadspmc-436ce68ecd41ad66e7a0605b47b5814582db8538.tar.gz
Consolidate platform detection preprocessor checks
Diffstat (limited to 'include')
-rw-r--r--include/spm.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/include/spm.h b/include/spm.h
index f9b2201..5382378 100644
--- a/include/spm.h
+++ b/include/spm.h
@@ -4,6 +4,22 @@
#ifndef SPM_SPM_H
#define SPM_SPM_H
+// Define some platform detection shortcuts
+#define OS_DARWIN 0
+#define OS_WINDOWS 0
+#define OS_LINUX 0
+
+#if defined(__APPLE__) && defined(__MACH__)
+#undef OS_DARWIN
+#define OS_DARWIN 1
+#elif defined(_WIN32)
+#undef OS_WINDOWS
+#define OS_WINDOWS 1
+#elif defined(__linux) || defined(__linux__)
+#undef OS_LINUX
+#define OS_LINUX 1
+#endif
+
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
@@ -19,7 +35,7 @@
#include <openssl/md5.h>
#include <openssl/sha.h>
-#if !defined(_WIN32)
+#if !OS_WINDOWS
#include <fts.h>
#include <glob.h>
#include <unistd.h>
@@ -65,7 +81,7 @@ extern spm_vars SPM_GLOBAL;
#define DIRSEPS_UNIX "/"
#define PATHSEP_UNIX ';'
#define PATHSEPS_UNIX ";"
-#if defined(_WIN32)
+#if OS_WINDOWS
#define DIRSEP DIRSEP_WIN32
#define DIRSEPS DIRSEPS_WIN32
#define NOT_DIRSEP DIRSEP_UNIX
@@ -98,7 +114,7 @@ _1________________________________________________"
// GLOBALS
-#ifdef __APPLE__
+#if OS_DARWIN
extern char **environ;
#define __environ environ
#endif