SQLite

Check-in [54d23521c3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the SQLITE_HAVE_ISNAN compile-time option which, if present, causes SQLite to use the math library isnan() function rather than its own homebrew implementation of isnan(). (CVS 6517)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 54d23521c37938b9d98f41f5547975c469c0c8f0
User & Date: drh 2009-04-17 11:57:22.000
Context
2009-04-17
15:18
Get the behavior of SQLITE_HAVE_ISNAN right. It was reversed in check-in (6517). Ticket #3809. (CVS 6518) (check-in: 97c6ea2368 user: drh tags: trunk)
11:57
Add the SQLITE_HAVE_ISNAN compile-time option which, if present, causes SQLite to use the math library isnan() function rather than its own homebrew implementation of isnan(). (CVS 6517) (check-in: 54d23521c3 user: drh tags: trunk)
11:56
Check-in (6514) did not completely remove the obsolete test, resulting in a segfault. This check-in finishes the job. Ticket #3802. (CVS 6516) (check-in: c29b37ea36 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/util.c.
10
11
12
13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.249 2009/03/01 22:29:20 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>


/*
** Routine needed to support the testcase() macro.
*/
#ifdef SQLITE_COVERAGE_TEST
void sqlite3Coverage(int x){
  static int dummy = 0;







|



>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.250 2009/04/17 11:57:22 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <math.h>

/*
** Routine needed to support the testcase() macro.
*/
#ifdef SQLITE_COVERAGE_TEST
void sqlite3Coverage(int x){
  static int dummy = 0;
48
49
50
51
52
53
54



55
56







57
58
59
60
61
62
63
64
  assert( ALWAYS_was_false_or_NEVER_was_true );      /* Always fails */
  return ALWAYS_was_false_or_NEVER_was_true++;       /* Not Reached */
}
#endif

/*
** Return true if the floating point value is Not a Number (NaN).



*/
int sqlite3IsNaN(double x){







  /* This NaN test sometimes fails if compiled on GCC with -ffast-math.
  ** On the other hand, the use of -ffast-math comes with the following
  ** warning:
  **
  **      This option [-ffast-math] should never be turned on by any
  **      -O option since it can result in incorrect output for programs
  **      which depend on an exact implementation of IEEE or ISO 
  **      rules/specifications for math functions.







>
>
>


>
>
>
>
>
>
>
|







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  assert( ALWAYS_was_false_or_NEVER_was_true );      /* Always fails */
  return ALWAYS_was_false_or_NEVER_was_true++;       /* Not Reached */
}
#endif

/*
** Return true if the floating point value is Not a Number (NaN).
**
** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN.
** Otherwise, we have our own implementation that works on most systems.
*/
int sqlite3IsNaN(double x){
#if defined(SQLITE_HAVE_ISNAN)
  /*
  ** Systems that support the isnan() library function should probably
  ** make use of it by compiling with -DSQLITE_HAVE_ISNAN.  But we have
  ** found that many systems do not have a working isnan() function so
  ** this implementation is provided as an alternative.
  **
  ** This NaN test sometimes fails if compiled on GCC with -ffast-math.
  ** On the other hand, the use of -ffast-math comes with the following
  ** warning:
  **
  **      This option [-ffast-math] should never be turned on by any
  **      -O option since it can result in incorrect output for programs
  **      which depend on an exact implementation of IEEE or ISO 
  **      rules/specifications for math functions.
73
74
75
76
77
78
79



80
81
82
83
84
85
86
  */
#ifdef __FAST_MATH__
# error SQLite will not work correctly with the -ffast-math option of GCC.
#endif
  volatile double y = x;
  volatile double z = y;
  return y!=z;



}

/*
** Compute a string length that is limited to what can be stored in
** lower 30 bits of a 32-bit signed integer.
*/
int sqlite3Strlen30(const char *z){







>
>
>







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
  */
#ifdef __FAST_MATH__
# error SQLite will not work correctly with the -ffast-math option of GCC.
#endif
  volatile double y = x;
  volatile double z = y;
  return y!=z;
#else  /* if defined(SQLITE_HAVE_ISNAN) */
  return isnan(x);
#endif /* SQLITE_HAVE_ISNAN */
}

/*
** Compute a string length that is limited to what can be stored in
** lower 30 bits of a 32-bit signed integer.
*/
int sqlite3Strlen30(const char *z){