Skip to content

Commit

Permalink
AP_Math: rename macros to avoid conflicts
Browse files Browse the repository at this point in the history
these macros were also defined in NuttX in clock.h
  • Loading branch information
tridge committed May 6, 2017
1 parent e51bbce commit 607220d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
12 changes: 6 additions & 6 deletions libraries/AP_Math/AP_Math.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,32 +183,32 @@ static inline auto MAX(const A &one, const B &two) -> decltype(one > two ? one :

inline uint32_t hz_to_nsec(uint32_t freq)
{
return NSEC_PER_SEC / freq;
return AP_NSEC_PER_SEC / freq;
}

inline uint32_t nsec_to_hz(uint32_t nsec)
{
return NSEC_PER_SEC / nsec;
return AP_NSEC_PER_SEC / nsec;
}

inline uint32_t usec_to_nsec(uint32_t usec)
{
return usec * NSEC_PER_USEC;
return usec * AP_NSEC_PER_USEC;
}

inline uint32_t nsec_to_usec(uint32_t nsec)
{
return nsec / NSEC_PER_USEC;
return nsec / AP_NSEC_PER_USEC;
}

inline uint32_t hz_to_usec(uint32_t freq)
{
return USEC_PER_SEC / freq;
return AP_USEC_PER_SEC / freq;
}

inline uint32_t usec_to_hz(uint32_t usec)
{
return USEC_PER_SEC / usec;
return AP_USEC_PER_SEC / usec;
}

/*
Expand Down
18 changes: 11 additions & 7 deletions libraries/AP_Math/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ static const double WGS84_B = (WGS84_A * (1 - WGS84_F));
// Eccentricity of the Earth
static const double WGS84_E = (sqrt(2 * WGS84_F - WGS84_F * WGS84_F));

#define NSEC_PER_SEC 1000000000ULL
#define NSEC_PER_USEC 1000ULL
#define USEC_PER_SEC 1000000ULL
#define USEC_PER_MSEC 1000ULL
#define MSEC_PER_SEC 1000ULL
#define SEC_PER_WEEK (7ULL * 86400ULL)
#define MSEC_PER_WEEK (SEC_PER_WEEK * MSEC_PER_SEC)
/*
use AP_ prefix to prevent conflict with OS headers, such as NuttX
clock.h
*/
#define AP_NSEC_PER_SEC 1000000000ULL
#define AP_NSEC_PER_USEC 1000ULL
#define AP_USEC_PER_SEC 1000000ULL
#define AP_USEC_PER_MSEC 1000ULL
#define AP_MSEC_PER_SEC 1000ULL
#define AP_SEC_PER_WEEK (7ULL * 86400ULL)
#define AP_MSEC_PER_WEEK (AP_SEC_PER_WEEK * AP_MSEC_PER_SEC)

0 comments on commit 607220d

Please sign in to comment.