Skip to content

Commit

Permalink
Add Hurd support
Browse files Browse the repository at this point in the history
  * 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.
  • Loading branch information
gnu-srs committed Mar 17, 2016
1 parent 0e8c01a commit 6bd3f08
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions configure.ac
Expand Up @@ -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; ],
Expand Down Expand Up @@ -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])
;;
Expand Down
4 changes: 4 additions & 0 deletions lib/log_thread.c
Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions lib/util.c
Expand Up @@ -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);
Expand Down

0 comments on commit 6bd3f08

Please sign in to comment.