Reverted some recent changes to detect isnan()

For some reason, checking in math.h ends up causing
compile failures on some Macs.

Change-Id: I454c91bd49f26018c862717edd00391a03f28996
Merge topic 'isnan-compile-fix' into master

8e9c51d7 Reverted some recent changes to detect isnan()