summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct51
-rw-r--r--cgps.c1
-rw-r--r--gpsd.h-tail1
-rw-r--r--gpsdclient.c2
-rw-r--r--gpsutils.c1
-rw-r--r--json.c3
-rw-r--r--libgps_shm.c1
-rw-r--r--os_compat.c4
-rw-r--r--os_compat.h67
-rw-r--r--ppsthread.c1
-rw-r--r--shared_json.c1
-rw-r--r--shmexport.c1
-rw-r--r--test_matrix.c1
-rw-r--r--test_timespec.c1
14 files changed, 74 insertions, 62 deletions
diff --git a/SConstruct b/SConstruct
index d6922788..41698da0 100644
--- a/SConstruct
+++ b/SConstruct
@@ -860,57 +860,6 @@ else:
confdefs.append('''\
-/* Some libcs do not have strlcat/strlcpy. Local copies are provided */
-#ifndef HAVE_STRLCAT
-# ifdef __cplusplus
-extern "C" {
-# endif
-#include <string.h>
-size_t strlcat(/*@out@*/char *dst, /*@in@*/const char *src, size_t size);
-# ifdef __cplusplus
-}
-# endif
-#endif
-#ifndef HAVE_STRLCPY
-# ifdef __cplusplus
-extern "C" {
-# endif
-#include <string.h>
-size_t strlcpy(/*@out@*/char *dst, /*@in@*/const char *src, size_t size);
-# ifdef __cplusplus
-}
-# endif
-#endif
-#ifndef HAVE_CLOCK_GETTIME
-# ifdef __cplusplus
-extern "C" {
-# endif
-#ifndef CLOCKID_T_DEFINED
-typedef int clockid_t;
-#define CLOCKID_T_DEFINED
-# endif
-/*
- * OS X 10.5 and later use _STRUCT_TIMESPEC (like other OSes)
- * 10.4 uses _TIMESPEC
- * 10.3 and earlier use _TIMESPEC_DECLARED
- */
-#if !defined(_STRUCT_TIMESPEC) && \
- !defined(_TIMESPEC) && \
- !defined(_TIMESPEC_DECLARED) && \
- !defined(__timespec_defined)
-#define _STRUCT_TIMESPEC
-struct timespec {
- time_t tv_sec;
- long tv_nsec;
-};
-#endif
-/* OS X does not have clock_gettime */
-#define CLOCK_REALTIME 0
-int clock_gettime(clockid_t, struct timespec *);
-# ifdef __cplusplus
-}
-# endif
-#endif
#define GPSD_CONFIG_H
#endif /* GPSD_CONFIG_H */
diff --git a/cgps.c b/cgps.c
index e5b749a3..56f90736 100644
--- a/cgps.c
+++ b/cgps.c
@@ -101,6 +101,7 @@
#include "compiler.h" /* for UNUSED */
#include "gpsdclient.h"
#include "revision.h"
+#include "os_compat.h"
static struct gps_data_t gpsdata;
static time_t status_timer; /* Time of last state change. */
diff --git a/gpsd.h-tail b/gpsd.h-tail
index d1fb5ead..72b3abd4 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -11,6 +11,7 @@
#include "gps.h"
#include "compiler.h"
+#include "os_compat.h"
/*
* Constants for the VERSION response
diff --git a/gpsdclient.c b/gpsdclient.c
index 70093b4a..b1b679be 100644
--- a/gpsdclient.c
+++ b/gpsdclient.c
@@ -8,13 +8,13 @@
#include <stdlib.h>
#include <string.h>
#include <strings.h> /* for strcasecmp() */
-#include <time.h> /* for time_t */
#include <math.h>
#include <assert.h>
#include "gpsd_config.h"
#include "gps.h"
#include "gpsdclient.h"
+#include "os_compat.h"
static struct exportmethod_t exportmethods[] = {
#if defined(DBUS_EXPORT_ENABLE)
diff --git a/gpsutils.c b/gpsutils.c
index 254cd552..7c6dbd0a 100644
--- a/gpsutils.c
+++ b/gpsutils.c
@@ -21,6 +21,7 @@
#include "gps.h"
#include "libgps.h"
+#include "os_compat.h"
#ifdef USE_QT
#include <QDateTime>
diff --git a/json.c b/json.c
index ed440e72..f5b59fba 100644
--- a/json.c
+++ b/json.c
@@ -67,10 +67,9 @@ PERMISSIONS
#include <stdlib.h>
#include <stdbool.h>
#include <stdarg.h>
-#include <time.h> /* for time_t */
#include <ctype.h>
-#include "gpsd_config.h" /* for strlcpy() prototype */
+#include "os_compat.h"
#ifdef SOCKET_EXPORT_ENABLE
#include "json.h"
diff --git a/libgps_shm.c b/libgps_shm.c
index a9250ca0..6d065ced 100644
--- a/libgps_shm.c
+++ b/libgps_shm.c
@@ -18,7 +18,6 @@ PERMISSIONS
/* sys/ipc.h needs _XOPEN_SOURCE, 500 means X/Open 1995 */
#define _XOPEN_SOURCE 500
-#include <time.h> /* for time_t */
#include "gpsd_config.h"
#ifdef SHM_EXPORT_ENABLE
diff --git a/os_compat.c b/os_compat.c
index 6e11ee89..4ffefb08 100644
--- a/os_compat.c
+++ b/os_compat.c
@@ -13,9 +13,7 @@
* in the histories of those files.
*/
-/* Determine which of these functions we need */
-#include <time.h> /* For time_t (temp until we fix gpsd_config.h) */
-#include "gpsd_config.h"
+#include "os_compat.h" /* Includes gpsd_config.h */
#ifndef HAVE_CLOCK_GETTIME
diff --git a/os_compat.h b/os_compat.h
new file mode 100644
index 00000000..4dbe9de3
--- /dev/null
+++ b/os_compat.h
@@ -0,0 +1,67 @@
+/*
+ * This file is Copyright (c) 2017 by the GPSD project
+ * BSD terms apply: see the file COPYING in the distribution root for details.
+ *
+ * This is the header for os_compat.c, which contains functions dealing with
+ * compatibility issues across OSes.
+ */
+#ifndef _GPSD_OS_COMPAT_H_
+#define _GPSD_OS_COMPAT_H_
+
+/* Determine which of these functions we need */
+#include "gpsd_config.h"
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+#ifndef HAVE_CLOCK_GETTIME
+
+#include <time.h>
+
+#ifndef CLOCKID_T_DEFINED
+typedef int clockid_t;
+#define CLOCKID_T_DEFINED
+#endif /* !CLOCKID_T_DEFINED */
+
+/*
+ * OS X 10.5 and later use _STRUCT_TIMESPEC (like other OSes)
+ * 10.4 uses _TIMESPEC
+ * 10.3 and earlier use _TIMESPEC_DECLARED
+ */
+#if !defined(_STRUCT_TIMESPEC) && \
+ !defined(_TIMESPEC) && \
+ !defined(_TIMESPEC_DECLARED) && \
+ !defined(__timespec_defined)
+#define _STRUCT_TIMESPEC
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+#endif /* !_STRUCT_TIMESPEC ... */
+
+/* OS X does not have clock_gettime */
+#define CLOCK_REALTIME 0
+int clock_gettime(clockid_t, struct timespec *);
+
+#endif /* !HAVE_CLOCK_GETTIME */
+
+#ifndef HAVE_STRLCAT
+
+#include <string.h>
+size_t strlcat(char *dst, const char *src, size_t size);
+
+#endif /* !HAVE_STRLCAT */
+
+#ifndef HAVE_STRLCPY
+
+#include <string.h>
+size_t strlcpy(char *dst, const char *src, size_t size);
+
+#endif /* !HAVE_STRLCPY */
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif /* _GPSD_OS_COMPAT_H_ */
diff --git a/ppsthread.c b/ppsthread.c
index 53a93b2e..6aadf90d 100644
--- a/ppsthread.c
+++ b/ppsthread.c
@@ -84,6 +84,7 @@
#include "timespec.h"
#include "ppsthread.h"
+#include "os_compat.h"
/*
* Tell GCC that we want thread-safe behavior with _REENTRANT;
diff --git a/shared_json.c b/shared_json.c
index a1589421..3cabccc4 100644
--- a/shared_json.c
+++ b/shared_json.c
@@ -17,7 +17,6 @@ PERMISSIONS
#include <math.h>
#include <stdbool.h>
-#include <time.h> /* for time_t */
#include "gpsd.h"
#ifdef SOCKET_EXPORT_ENABLE
diff --git a/shmexport.c b/shmexport.c
index cef94d77..2edf0776 100644
--- a/shmexport.c
+++ b/shmexport.c
@@ -18,7 +18,6 @@ PERMISSIONS
/* sys/ipc.h needs _XOPEN_SOURCE, 500 means X/Open 1995 */
#define _XOPEN_SOURCE 500
-#include <time.h> /* for time_t */
#include "gpsd_config.h"
#ifdef SHM_EXPORT_ENABLE
diff --git a/test_matrix.c b/test_matrix.c
index a1249cba..b7e78851 100644
--- a/test_matrix.c
+++ b/test_matrix.c
@@ -8,7 +8,6 @@
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
-#include <time.h> /* for time_t */
#include <math.h>
#include "compiler.h"
diff --git a/test_timespec.c b/test_timespec.c
index 315d974a..80644684 100644
--- a/test_timespec.c
+++ b/test_timespec.c
@@ -8,7 +8,6 @@
#include <stdio.h>
#include <stdint.h> /* required by C99, for int32_t */
#include <string.h>
-#include <time.h> /* for time_t */
#include <math.h>
#include <unistd.h>