From 9d2e89179d0a8d9b09a2b996c92034bdd8836059 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@gmail.com>
Date: Sun, 17 Feb 2019 07:12:36 +0100
Subject: Convert existing patch to git patchset.


diff --git a/configure.ac b/configure.ac
index 59f9b81..1ed4a6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -314,9 +314,12 @@ AC_CHECK_TYPES([in_port_t, in_addr_t], , ,
 # only looks in /etc/hosts), so we only look for -lsocket if we need
 # it.
 AC_SEARCH_LIBS(gethostent, [nsl])
-AC_SEARCH_LIBS(setsockopt, [socket])
+AC_SEARCH_LIBS(setsockopt, [socket network])
 AC_SEARCH_LIBS(hstrerror, [resolv])
 AC_SEARCH_LIBS(inet_aton, [resolv])
+AC_SEARCH_LIBS(strsep, [bsd])
+AC_SEARCH_LIBS(wait3, [bsd])
+AC_SEARCH_LIBS(wait4, [bsd])
 
 if test x"$with_included_popt" != x"yes"  && test x"$with_included_popt" != xno
 then
@@ -379,6 +382,7 @@ AC_CHECK_FUNCS([snprintf vsnprintf vasprintf asprintf getcwd getwd mkdtemp])
 AC_CHECK_FUNCS([getrusage strsignal gettimeofday])
 AC_CHECK_FUNCS([getaddrinfo getnameinfo inet_ntop inet_ntoa])
 AC_CHECK_FUNCS([strndup strsep mmap strlcpy])
+AC_CHECK_FUNCS([nice])
 
 AC_CHECK_FUNCS([getloadavg])
 AC_CHECK_FUNCS([getline])
@@ -477,6 +481,8 @@ AC_CHECK_MEMBER([struct sockaddr_storage.ss_family],
     AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [define if you have struct sockaddr_storage]),,
     [#include <sys/socket.h>])
 
+AC_CHECK_MEMBERS([struct rusage.ru_minflt, struct rusage.ru_majflt])
+
 AC_ARG_WITH(avahi,
         AC_HELP_STRING([--without-avahi], [build without avahi]))
 
diff --git a/src/daemon.c b/src/daemon.c
index c8fee7c..169d846 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -197,15 +197,19 @@ int main(int argc, char *argv[])
     if ((ret = dcc_set_lifetime()) != 0)
         dcc_exit(ret);
 
+#ifdef HAVE_NICE
     /* do this before giving away root */
     if (nice(opt_niceness) == -1) {
         rs_log_warning("nice %d failed: %s", opt_niceness,
                        strerror(errno));
         /* continue anyhow */
     }
+#endif
 
+#ifndef __HAIKU__
     if ((ret = dcc_discard_root()) != 0)
         dcc_exit(ret);
+#endif
 
     /* Discard privileges before opening log so that if it's created, it has
      * the right ownership. */
diff --git a/src/exec.c b/src/exec.c
index 46b377e..4dd86f3 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -491,13 +491,19 @@ int dcc_collect_child(const char *what, pid_t pid,
              * critique_status(). */
             rs_trace("%s child %ld terminated with status %#x",
                      what, (long) ret_pid, *wait_status);
+#if defined HAVE_RUSAGE_RU_MINFLT && defined HAVE_RUSAGE_RU_MAJFLT
             rs_log_info("%s times: user %lld.%06lds, system %lld.%06lds, "
                         "%ld minflt, %ld majflt",
                         what,
                         (long long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
                         (long long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec,
                         ru.ru_minflt, ru.ru_majflt);
-
+#else
+            rs_log_info("%s times: user %ld.%06lds, system %ld.%06lds",
+                        what,
+                        ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
+                        ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
+#endif
             return 0;
         }
 
-- 
2.30.0


From fbff23b5e7a5f06307d47d83a8b397b051cdda92 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@gmail.com>
Date: Sun, 17 Feb 2019 08:00:17 +0100
Subject: strings.h fix


diff --git a/src/filename.c b/src/filename.c
index 9b23b38..f19157c 100644
--- a/src/filename.c
+++ b/src/filename.c
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#include <strings.h>
 #include <errno.h>
 
 #include "distcc.h"
-- 
2.30.0

