-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This creates a header for os_compat.c, and moves the related prototypes into it from gpsd_config.h (as created by SConstruct), after adding references to it to gpsd.h (via gpsd.h-tail) and a few other sources that need it but don't include gpsd.h. It also removes includes of <time.h> in the places where they were only needed for the code now removed from gpsd_config.h. TESTED: Ran "scons build-all check" on OSX 10.9 (with strlcat/strlcpy but no clock_gettime), OSX 10.12 (with strlcat/strlcpy and clock_gettime), and Ubuntu 14 (with clock_gettime but no strlcat/strlcpy). Also verified that fallback versions were not being included where unnecessary.
- Loading branch information
Showing
14 changed files
with
74 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
|
||
#include "gps.h" | ||
#include "libgps.h" | ||
#include "os_compat.h" | ||
|
||
#ifdef USE_QT | ||
#include <QDateTime> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters