Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #95, add local isnan, isfinite macros #96

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Check notice

Code scanning / CodeQL

Conditional compilation Note

Use of conditional compilation must be kept to a minimum.
#define isnan(x) ((x) != (x))
#endif
#ifndef isfinite

Check notice

Code scanning / CodeQL

Conditional compilation Note

Use of conditional compilation must be kept to a minimum.
#define isfinite(x) ((x) > -FLT_MAX && (x) < FLT_MAX)
#endif

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