From 395d6b02dda3db1acd08936f49c1dc8efc48e613 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 28 Sep 2016 13:26:49 -0400 Subject: [PATCH] Fix: time redefinition warnings on macOS builds MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/ust-metadata.c | 2 +- src/common/Makefile.am | 2 +- src/common/compat/time.h | 4 ++++ src/common/sessiond-comm/inet.c | 3 +-- src/common/sessiond-comm/inet6.c | 3 +-- src/common/time.h | 27 +++++++++++++++++++++++++++ tests/utils/utils.c | 4 +--- 7 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 src/common/time.h diff --git a/src/bin/lttng-sessiond/ust-metadata.c b/src/bin/lttng-sessiond/ust-metadata.c index 49edb1711..c1a80c746 100644 --- a/src/bin/lttng-sessiond/ust-metadata.c +++ b/src/bin/lttng-sessiond/ust-metadata.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "ust-registry.h" #include "ust-clock.h" @@ -37,7 +38,6 @@ #define max_t(type, a, b) ((type) ((a) > (b) ? (a) : (b))) #endif -#define NSEC_PER_SEC 1000000000ULL #define NR_CLOCK_OFFSET_SAMPLES 10 struct offset_sample { diff --git a/src/common/Makefile.am b/src/common/Makefile.am index e63ddeb73..8619b5e25 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -61,7 +61,7 @@ AM_CFLAGS = -fno-strict-aliasing noinst_HEADERS = lttng-kernel.h defaults.h macros.h error.h futex.h \ uri.h utils.h lttng-kernel-old.h \ - align.h bitfield.h bug.h + align.h bitfield.h bug.h time.h # Common library noinst_LTLIBRARIES = libcommon.la diff --git a/src/common/compat/time.h b/src/common/compat/time.h index f51075dc3..c8d5859ff 100644 --- a/src/common/compat/time.h +++ b/src/common/compat/time.h @@ -32,6 +32,10 @@ typedef int clockid_t; #include #include +#undef NSEC_PER_SEC +#undef NSEC_PER_MSEC +#undef NSEC_PER_USEC + #define CLOCK_REALTIME CALENDAR_CLOCK #define CLOCK_MONOTONIC SYSTEM_CLOCK diff --git a/src/common/sessiond-comm/inet.c b/src/common/sessiond-comm/inet.c index 84bee5bd9..25dbd2195 100644 --- a/src/common/sessiond-comm/inet.c +++ b/src/common/sessiond-comm/inet.c @@ -30,11 +30,10 @@ #include #include +#include #include "inet.h" -#define MSEC_PER_SEC 1000 -#define NSEC_PER_MSEC 1000000 #define RECONNECT_DELAY 200 /* ms */ /* diff --git a/src/common/sessiond-comm/inet6.c b/src/common/sessiond-comm/inet6.c index 1413c3517..0b0383cdd 100644 --- a/src/common/sessiond-comm/inet6.c +++ b/src/common/sessiond-comm/inet6.c @@ -30,11 +30,10 @@ #include #include +#include #include "inet6.h" -#define MSEC_PER_SEC 1000 -#define NSEC_PER_MSEC 1000000 #define RECONNECT_DELAY 200 /* ms */ /* diff --git a/src/common/time.h b/src/common/time.h new file mode 100644 index 000000000..81770779b --- /dev/null +++ b/src/common/time.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2016 - Jérémie Galarneau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LTTNG_TIME_H +#define LTTNG_TIME_H + +#define MSEC_PER_SEC 1000ULL +#define NSEC_PER_SEC 1000000000ULL +#define NSEC_PER_MSEC 1000000ULL +#define NSEC_PER_USEC 1000ULL + +#endif /* LTTNG_TIME_H */ diff --git a/tests/utils/utils.c b/tests/utils/utils.c index 7aa8667d4..b85f027e0 100644 --- a/tests/utils/utils.c +++ b/tests/utils/utils.c @@ -17,14 +17,12 @@ #include #include +#include #include #include #include #include -#define NSEC_PER_SEC 1000000000ULL -#define NSEC_PER_USEC 1000ULL - static inline int64_t elapsed_time_ns(struct timespec *t1, struct timespec *t2) { -- 2.34.1