From: Andrew Beekhof andrew@beekhof.net
Signed-off-by: Angus Salkeld asalkeld@redhat.com --- configure.ac | 11 +++++++++-- include/os_base.h | 4 ++++ lib/ipc_int.h | 6 +++++- lib/ipc_posix_mq.c | 2 ++ lib/ipcc.c | 1 - lib/ipcs.c | 2 ++ lib/log.c | 2 ++ lib/log_dcs.c | 4 +++- lib/log_thread.c | 9 ++++++--- lib/util.c | 16 ++++++++++++++++ 10 files changed, 49 insertions(+), 8 deletions(-)
diff --git a/configure.ac b/configure.ac index 129545c..81f375e 100644 --- a/configure.ac +++ b/configure.ac @@ -8,8 +8,12 @@ AC_INIT([libqb], [quarterback-devel@fedorahosted.org]) AC_CONFIG_SRCDIR([lib/ringbuffer.c]) AC_CONFIG_HEADERS([include/config.h include/qb/qbconfig.h]) -AM_INIT_AUTOMAKE([-Wno-portability dist-xz color-tests parallel-tests]) -AM_SILENT_RULES([yes]) +AM_INIT_AUTOMAKE([-Wno-portability]) +dnl automake >= 1.11 offers --enable-silent-rules for suppressing the output from +dnl normal compilation. When a failure occurs, it will then display the full +dnl command line +dnl Wrap in m4_ifdef to avoid breaking on older platforms +m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES]) LT_PREREQ([2.2.6]) LT_INIT
@@ -215,6 +219,9 @@ case "$host_os" in [Compiling for Darwin platform]) CP=rsync LIB_RT= + ac_cv_link_attribute_section=no + dnl Attribute section appears to work here but fails later with: + dnl cc1: error in backend: Global variable 'descriptor.4902' has an invalid section specifier '__verbose': mach-o section specifier requires a segment and section separated by a comma AC_DEFINE_UNQUOTED([MAP_ANONYMOUS], [MAP_ANON], [Shared memory define for Darwin platform]) AC_DEFINE_UNQUOTED([PATH_MAX], [4096], diff --git a/include/os_base.h b/include/os_base.h index decf375..c034d25 100644 --- a/include/os_base.h +++ b/include/os_base.h @@ -127,4 +127,8 @@ #endif /* _POSIX_THREAD_PROCESS_SHARED */ #endif /* DISABLE_POSIX_THREAD_PROCESS_SHARED */
+#ifdef QB_DARWIN +char *strchrnul (const char *s, int c_in); +#endif + #endif /* QB_OS_BASE_H_DEFINED */ diff --git a/lib/ipc_int.h b/lib/ipc_int.h index e05c053..c19be90 100644 --- a/lib/ipc_int.h +++ b/lib/ipc_int.h @@ -25,7 +25,9 @@ #include "os_base.h"
#include <dirent.h> -#include <mqueue.h> +#ifndef QB_DARWIN +# include <mqueue.h> +#endif #include <qb/qblist.h> #include <qb/qbloop.h> #include <qb/qbipcc.h> @@ -75,10 +77,12 @@ struct qb_ipc_one_way { void* shared_data; char shared_file_name[NAME_MAX]; } us; +#ifndef QB_DARWIN struct { mqd_t q; char name[NAME_MAX]; } pmq; +#endif struct { int32_t q; int32_t key; diff --git a/lib/ipc_posix_mq.c b/lib/ipc_posix_mq.c index 068fad3..d9c5372 100644 --- a/lib/ipc_posix_mq.c +++ b/lib/ipc_posix_mq.c @@ -19,6 +19,7 @@ * along with libqb. If not, see http://www.gnu.org/licenses/. */ #include "os_base.h" +#ifndef QB_DARWIN
#include <mqueue.h> #include <sys/resource.h> @@ -416,3 +417,4 @@ qb_ipcs_pmq_init(struct qb_ipcs_service *s) s->needs_sock_for_poll = QB_TRUE; #endif } +#endif diff --git a/lib/ipcc.c b/lib/ipcc.c index b63c676..93fd896 100644 --- a/lib/ipcc.c +++ b/lib/ipcc.c @@ -20,7 +20,6 @@ */ #include "os_base.h"
-#include <mqueue.h> #include "ipc_int.h" #include "util_int.h" #include <qb/qbdefs.h> diff --git a/lib/ipcs.c b/lib/ipcs.c index b1d64c7..d11c19b 100644 --- a/lib/ipcs.c +++ b/lib/ipcs.c @@ -121,10 +121,12 @@ _modify_dispatch_descriptor_(struct qb_ipcs_connection *c)
if (c->service->type == QB_IPC_POSIX_MQ && !c->service->needs_sock_for_poll) { +#ifndef QB_DARWIN return disp_mod(c->service->poll_priority, (int32_t) c->request.u.pmq.q, c->poll_events, c, qb_ipcs_dispatch_service_request); +#endif } else if (c->service->type == QB_IPC_SOCKET) { return disp_mod(c->service->poll_priority, c->event.u.us.sock, diff --git a/lib/log.c b/lib/log.c index 201670d..50fa58b 100644 --- a/lib/log.c +++ b/lib/log.c @@ -20,7 +20,9 @@ */ #include "os_base.h" #include <ctype.h> +#ifndef QB_DARWIN #include <link.h> +#endif #include <stdarg.h> #include <pthread.h> #include <dlfcn.h> diff --git a/lib/log_dcs.c b/lib/log_dcs.c index bbd2362..9b8db43 100644 --- a/lib/log_dcs.c +++ b/lib/log_dcs.c @@ -20,7 +20,9 @@ */ #include "os_base.h" #include <ctype.h> -#include <link.h> +#ifndef QB_DARWIN +# include <link.h> +#endif #include <stdarg.h>
#include <qb/qbdefs.h> diff --git a/lib/log_thread.c b/lib/log_thread.c index 4756816..178398e 100644 --- a/lib/log_thread.c +++ b/lib/log_thread.c @@ -122,11 +122,14 @@ qb_log_thread_priority_set(int32_t policy, int32_t priority)
logt_sched_policy = policy;
- if (policy == SCHED_OTHER || + if (policy == SCHED_OTHER #ifdef SCHED_IDLE - policy == SCHED_IDLE || + || policy == SCHED_IDLE #endif - policy == SCHED_BATCH) { +#ifndef QB_DARWIN + || policy == SCHED_BATCH +#endif + ) { logt_sched_param.sched_priority = 0; } else { logt_sched_param.sched_priority = priority; diff --git a/lib/util.c b/lib/util.c index 151b04a..1ce5f4f 100644 --- a/lib/util.c +++ b/lib/util.c @@ -470,3 +470,19 @@ qb_strerror_r(int errnum, char *buf, size_t buflen) return out_buf; #endif /* QB_LINUX */ } + +#ifdef QB_DARWIN +/* Borrowed from gnulib's strchrnul.c under GLPv2+ */ + +#include <string.h> +/* Find the first occurrence of C in S or the final NUL byte. */ +char * +strchrnul (const char *s, int c_in) +{ + char c = c_in; + while (*s && (*s != c)) + s++; + + return (char *) s; +} +#endif