From kde-commits Tue Jun 29 19:44:18 2004 From: Andy Fawcett Date: Tue, 29 Jun 2004 19:44:18 +0000 To: kde-commits Subject: kdeartwork/kscreensaver/kdesavers Message-Id: <20040629194418.E2E6D9449 () office ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=108853827020042 CVS commit by fawcett: More portable support for NAN on 2.95 based systems, the original workaround for this problem didn't work on FreeBSD 4.x (reported to kde-core-devel@) This code is based on some in Qt itself, and gratuitously simplified by Michael Nottebrock, Frerich Raabe and myself. M +14 -5 vec3.cpp 1.3 --- kdeartwork/kscreensaver/kdesavers/vec3.cpp #1.2:1.3 @@ -11,8 +11,17 @@ //============================================================================ -#ifndef _ISOC99_SOURCE -// NAN is not defined by default for gcc 2.95. Enable the ISO C99 extensions -// which includes the definition of NAN. -#define _ISOC99_SOURCE 1 +#include +#if !defined(NAN) +static inline double nan__() +{ + static const unsigned int one = 1; + static const bool BigEndian = (*((unsigned char *) &one) == 0); + + static const unsigned char be_nan_bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 }; + static const unsigned char le_nan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }; + + return *( ( const double * )( BigEndian ? be_nan_bytes : le_nan_bytes ) ); +} +# define NAN (::nan__()) #endif