On Fri, 2016-03-04 at 16:02 +0100, Jan Pokorný wrote:
> On 02/03/16 17:35 +0100, Svante Signell wrote:
> > On Wed, 2016-03-02 at 16:50 +0100, Jan Pokorný wrote:
> > > On 02/03/16 14:56 +0100, Svante Signell wrote:
> > > > On Wed, 2016-03-02 at 14:25 +0100, Jan Pokorný wrote:
> > > > > On 02/03/16 11:21 +0100, Svante Signell wrote:
> > > 
> > > I created a separate pull request on your behalf:
> > > https://github.com/ClusterLabs/libqb/pull/192
> 
> Because of this ML/GH dualism, just wanted to let you know that I
> added a comment:
> https://github.com/ClusterLabs/libqb/pull/192#issuecomment-192308384

Attached is an updated patch addressing the issues in the above comment:

* Fixed indentation.
* Check for a working getres option CLOCK_MONOTONIC in configure.ac.

Next is a planned addition of SCM_CREDS support for GNU/Hurd to enable a working
ipc testsuite too.


Thanks!
From a8d5a5f909a12be578f6c4b709aef30142921d03 Mon Sep 17 00:00:00 2001
From: Svante Signell <[email protected]>
Date: Tue, 15 Mar 2016 17:07:58 +0100
Subject: [PATCH] Add Hurd support

  * configure.ac: Define QB_GNU.
  Add a check for a working clock_getres for the CLOCK_MONOTONIC
  option defining HAVE_CLOCK_GETRES_MONOTONIC.

  * lib/log_thread.c: Replace second argument of
  qb_log_thread_priority_set(): logt_sched_param.sched_priority by 0
  when not supported by the OS.

  * lib/util.c: Use the CLOCK_REALTIME option in clock_getres() if
  HAVE_CLOCK_GETRES_MONOTONIC os not defined.

---
 configure.ac     | 17 +++++++++++++++++
 lib/log_thread.c |  4 ++++
 lib/util.c       |  5 +++++
 3 files changed, 26 insertions(+)

diff --git a/configure.ac b/configure.ac
index 7cfde10..d39e2ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -173,6 +173,18 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
                  )
 
 
+AC_MSG_CHECKING(for a working clock_getres(CLOCK_MONOTONIC, &ts))
+AC_RUN_IFELSE([AC_LANG_PROGRAM(
+[[#include <time.h>]],
+[[struct timespec ts; if(clock_getres(CLOCK_MONOTONIC, &ts)) return -1;]])],
+                    [
+                      AC_MSG_RESULT([yes])
+                      AC_DEFINE_UNQUOTED([HAVE_CLOCK_GETRES_MONOTONIC], 1, [Define to 1 if clock_getres(CLOCK_MONOTONIC, &ts) works])
+                    ],
+                    [
+                      AC_MSG_RESULT([no])
+                    ]
+                 )
 AC_MSG_CHECKING(for MSG_NOSIGNAL)
 AC_TRY_COMPILE([#include <sys/socket.h>],
 	       [ int f = MSG_NOSIGNAL; ],
@@ -335,6 +347,11 @@ case "$host_os" in
 		CP=rsync
 		AC_MSG_RESULT([Solaris])
 	;;
+	*gnu*)
+		AC_DEFINE_UNQUOTED([QB_GNU], [1],
+				   [Compiling for GNU/Hurd platform])
+		AC_MSG_RESULT([GNU])
+	;;
 	*)
 		AC_MSG_ERROR([Unsupported OS? hmmmm])
 	;;
diff --git a/lib/log_thread.c b/lib/log_thread.c
index 56008f8..930fb33 100644
--- a/lib/log_thread.c
+++ b/lib/log_thread.c
@@ -164,7 +164,11 @@ qb_log_thread_start(void)
 
 	if (logt_sched_param_queued) {
 		res = qb_log_thread_priority_set(logt_sched_policy,
+#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && defined(HAVE_SCHED_GET_PRIORITY_MAX)
 		                                 logt_sched_param.sched_priority);
+#else
+		                                 0);
+#endif
 		if (res != 0) {
 			goto cleanup_pthread;
 		}
diff --git a/lib/util.c b/lib/util.c
index ef5ba25..6181a25 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -169,7 +169,12 @@ qb_util_nano_monotonic_hz(void)
 	uint64_t nano_monotonic_hz;
 	struct timespec ts;
 
+#if HAVE_CLOCK_GETRES_MONOTONIC
 	clock_getres(CLOCK_MONOTONIC, &ts);
+#else
+	if (clock_getres(CLOCK_REALTIME, &ts) != 0)
+	    qb_util_perror(LOG_ERR,"CLOCK_REALTIME");
+#endif
 
 	nano_monotonic_hz =
 	    QB_TIME_NS_IN_SEC / ((ts.tv_sec * QB_TIME_NS_IN_SEC) + ts.tv_nsec);
-- 
2.6.4

_______________________________________________
Developers mailing list
[email protected]
http://clusterlabs.org/mailman/listinfo/developers

Reply via email to