From 2b12535e5698fad87e86d000d85491e8d47e5b2b Mon Sep 17 00:00:00 2001
From: Albert Graef <aggraef@gmail.com>
Date: Mon, 26 Aug 2019 22:10:23 +0200
Subject: [PATCH] fix HAVE_UNISTD_H glitches

---
 externals/loaders/hexloader/hexloader.c | 2 +-
 pd/src/configure.ac                     | 2 +-
 pd/src/s_main.c                         | 6 +++---
 pd/src/s_path.c                         | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/externals/loaders/hexloader/hexloader.c b/externals/loaders/hexloader/hexloader.c
index f11e72248..063dc2377 100644
--- a/externals/loaders/hexloader/hexloader.c
+++ b/externals/loaders/hexloader/hexloader.c
@@ -36,7 +36,7 @@
 #ifdef DL_OPEN
 # include <dlfcn.h>
 #endif
-#ifdef UNISTD
+#ifdef HAVE_UNISTD_H
 # include <stdlib.h>
 # include <unistd.h>
 #endif
diff --git a/pd/src/configure.ac b/pd/src/configure.ac
index 77e491283..3f1395ecc 100644
--- a/pd/src/configure.ac
+++ b/pd/src/configure.ac
@@ -121,7 +121,7 @@ dnl This should be fixed so Pd can use ALSA shared libraries where appropriate.
       LDFLAGS="$LDFLAGS -static"
     fi 
     EXT=pd_linux
-    CPPFLAGS="-DHAVE_LIBDL -DPA_USE_OSS -DUNIX -DUNISTD -fno-strict-aliasing"
+    CPPFLAGS="-DHAVE_LIBDL -DPA_USE_OSS -DUNIX -DHAVE_UNISTD_H -fno-strict-aliasing"
 dnl No OSS on hurd
     if test `uname -s` = "GNU";
     then
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index 86cd504f3..975e42dc9 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -14,7 +14,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 
-#ifdef UNISTD
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 #ifdef MSW
@@ -519,7 +519,7 @@ static char *(usagemessage[]) = {
 "-send \"msg...\"   -- send a message at startup, after patches are loaded\n",
 "-noprefs         -- suppress loading preferences on startup\n",
 "-console         -- open the console along with the pd window\n",
-#ifdef UNISTD
+#ifdef HAVE_UNISTD_H
 "-rt or -realtime -- use real-time priority\n",
 "-nrt             -- don't use real-time priority\n",
 #endif
@@ -996,7 +996,7 @@ int sys_argparse(int argc, char **argv)
             sys_noautopatch = 0;
             argc--; argv++;
         }
-#ifdef UNISTD
+#ifdef HAVE_UNISTD_H
         else if (!strcmp(*argv, "-rt") || !strcmp(*argv, "-realtime"))
         {
             sys_hipriority = 1;
diff --git a/pd/src/s_path.c b/pd/src/s_path.c
index e7ac2b1ec..82df1fcce 100644
--- a/pd/src/s_path.c
+++ b/pd/src/s_path.c
@@ -14,7 +14,7 @@
 #define DEBUG(x)
 
 #include <stdlib.h>
-#ifdef UNISTD
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #include <sys/stat.h>
 #endif
@@ -360,7 +360,7 @@ int sys_trytoopenone(const char *dir, const char *name, const char* ext,
     if ((fd=open(dirresult,O_RDONLY | MSWOPENFLAG(bin))) >= 0)
     {
             /* in unix, further check that it's not a directory */
-#ifdef UNISTD
+#ifdef HAVE_UNISTD_H
         struct stat statbuf;
         int ok =  ((fstat(fd, &statbuf) >= 0) &&
             !S_ISDIR(statbuf.st_mode));
-- 
GitLab