Skip to content

Commit

Permalink
Merge pull request nasa#96 from jphickey/fix-95-isnan
Browse files Browse the repository at this point in the history
Fix nasa#95, add local isnan, isfinite macros
  • Loading branch information
dzbaker committed Aug 17, 2023
2 parents feb5bf5 + 6b78bdc commit ca47670
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions fsw/src/lc_watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,27 @@
#include "lc_perfids.h"
#include "lc_platform_cfg.h"

#include <float.h>
#include <math.h>

/*
* An ISO-compliant math.h header should provide "isnan" and "isfinite" macros
* as they are dicatated by C99. However some C libraries still in use are not
* fully compliant. If these macros are not defined, define a substitute here.
*
* Note these are not ideal/complete implementations of these macros, but they
* are OK based on the way they are used inside this source file. Use caution if
* changing the code using these, notably:
* - isfinite assumes float type
* - both macros evaluate the argument twice - use only with a simple variable
*/
#ifndef isnan
#define isnan(x) ((x) != (x))
#endif
#ifndef isfinite
#define isfinite(x) ((x) > -FLT_MAX && (x) < FLT_MAX)
#endif

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* LC_GetHashTableIndex() - convert messageID to hash table index */
Expand Down

0 comments on commit ca47670

Please sign in to comment.