summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver_geostar.c4
-rw-r--r--driver_tsip.c5
-rw-r--r--driver_zodiac.c5
-rw-r--r--gps2udp.c2
-rw-r--r--gpsctl.c5
-rw-r--r--gpsd_json.c7
-rw-r--r--gpspipe.c2
-rw-r--r--gpsrinex.c4
-rw-r--r--libgps_json.c4
-rw-r--r--libgpsd_core.c5
10 files changed, 29 insertions, 14 deletions
diff --git a/driver_geostar.c b/driver_geostar.c
index 127d92e1..5bacbfcf 100644
--- a/driver_geostar.c
+++ b/driver_geostar.c
@@ -10,10 +10,10 @@
* SPDX-License-Identifier: BSD-2-clause
*/
-#ifdef __linux__
+#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
/* isfinite() and pselect() needs _POSIX_C_SOURCE >= 200112L */
#define _POSIX_C_SOURCE 200112L
-#endif /* __linux__ */
+#endif /* _POSIX_C_SOURCE */
#include <sys/time.h> /* for pselect() */
#include <stdbool.h>
diff --git a/driver_tsip.c b/driver_tsip.c
index e6252027..cb30394b 100644
--- a/driver_tsip.c
+++ b/driver_tsip.c
@@ -18,9 +18,12 @@
/* if we insist on C99, then we need this to get M_LN2 from math.h */
/* 500 mean X/Open 1995 */
#define _XOPEN_SOURCE 500
+#endif /* __linux__ */
+
+#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
/* round() needs _POSIX_C_SOURCE >= 200112L */
#define _POSIX_C_SOURCE 200112L
-#endif /* __linux__ */
+#endif
#include <sys/time.h> /* for pselect() */
diff --git a/driver_zodiac.c b/driver_zodiac.c
index b9fa5522..b4c38b01 100644
--- a/driver_zodiac.c
+++ b/driver_zodiac.c
@@ -16,9 +16,12 @@
/* if we insisnt on C99, then we need this to get M_LN2 from math.h */
/* 500 means X/Open 1995 */
#define _XOPEN_SOURCE 500
+#endif /* __linux__ */
+
+#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
/* round() needs _POSIX_C_SOURCE >= 200112L */
#define _POSIX_C_SOURCE 200112L
-#endif /* __linux__ */
+#endif
#include <stdio.h>
diff --git a/gps2udp.c b/gps2udp.c
index 467919bf..ced24613 100644
--- a/gps2udp.c
+++ b/gps2udp.c
@@ -15,7 +15,7 @@
/* strsep() needs _DEFAULT_SOURCE */
#define _DEFAULT_SOURCE
-#ifdef __linux__
+#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
/* isfinite() and pselect() needs _POSIX_C_SOURCE >= 200112L */
#define _POSIX_C_SOURCE 200112L
#endif /* __linux__ */
diff --git a/gpsctl.c b/gpsctl.c
index 737a30e2..92e9f446 100644
--- a/gpsctl.c
+++ b/gpsctl.c
@@ -9,9 +9,12 @@
/* FreeBSD chokes on this */
/* sys/ipc.h needs _XOPEN_SOURCE, 500 means X/Open 1995 */
#define _XOPEN_SOURCE 500
+#endif /* __linux__ */
+
+#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
/* pselect() needs _POSIX_C_SOURCE >= 200112L */
#define _POSIX_C_SOURCE 200112L
-#endif /* __linux__ */
+#endif
/* strlcpy() needs _DARWIN_C_SOURCE */
#define _DARWIN_C_SOURCE
diff --git a/gpsd_json.c b/gpsd_json.c
index b3c0b2dd..5c5fa5e1 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -18,12 +18,15 @@ PERMISSIONS
/* FreeBSD chokes on this */
/* isascii() needs _XOPEN_SOURCE, 500 means X/Open 1995 */
#define _XOPEN_SOURCE 500
+#endif /* __linux__ */
+
+#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
/* isfinite() needs _POSIX_C_SOURCE >= 200112L
* check for isfinite() not isnan().
* isnan(+inf) returns false, isfinite(+inf) returns false.
*/
-#define _POSIX_C_SOURCE 200112L
-#endif /* __linux__ */
+#define _POSIX_C_SOURCE 200112L
+#endif
/* vsnprintf() needs __DARWIN_C_LEVEL >= 200112L */
#define __DARWIN_C_LEVEL 200112L
diff --git a/gpspipe.c b/gpspipe.c
index 39f6c301..80079393 100644
--- a/gpspipe.c
+++ b/gpspipe.c
@@ -26,7 +26,7 @@
/* cfmakeraw() needs _DEFAULT_SOURCE */
#define _DEFAULT_SOURCE
-#ifdef __linux__
+#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
/* isfinite() and pselect() needs _POSIX_C_SOURCE >= 200112L */
#define _POSIX_C_SOURCE 200112L
#endif /* __linux__ */
diff --git a/gpsrinex.c b/gpsrinex.c
index 6d3bf818..650b67f7 100644
--- a/gpsrinex.c
+++ b/gpsrinex.c
@@ -59,13 +59,13 @@
*
*/
-#ifdef __linux__
+#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
/* isfinite() needs _POSIX_C_SOURCE >= 200112L
* isnan(+Inf) is false, isfinite(+Inf) is false
* use isfinite() to make sure a float is valid
*/
#define _POSIX_C_SOURCE 200112L
-#endif /* __linux__ */
+#endif
#ifndef _XOPEN_SOURCE
/* need >= 500 for strdup() */
diff --git a/libgps_json.c b/libgps_json.c
index 1d1f892b..a1bde226 100644
--- a/libgps_json.c
+++ b/libgps_json.c
@@ -14,13 +14,13 @@ PERMISSIONS
***************************************************************************/
-#ifdef __linux__
+#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
/* isfinite() needs _POSIX_C_SOURCE >= 200112L
* isnan(+Inf) is false, isfinite(+Inf) is false
* use isfinite() to make sure a float is valid
*/
#define _POSIX_C_SOURCE 200112L
-#endif /* __linux__ */
+#endif
#include <stdbool.h>
#include <math.h>
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 15fa8070..cc7d5fbd 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -14,9 +14,12 @@
/* FreeBSD chokes on this */
/* getsid() needs _XOPEN_SOURCE, 500 means X/Open 1995 */
#define _XOPEN_SOURCE 500
+#endif /* __linux__ */
+
+#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
/* isfinite() and pselect() needs _POSIX_C_SOURCE >= 200112L */
#define _POSIX_C_SOURCE 200112L
-#endif /* __linux__ */
+#endif
/* strlcpy() needs _DARWIN_C_SOURCE */
#define _DARWIN_C_SOURCE