diff options
author | Michael Widenius <monty@mysql.com> | 2009-04-25 12:04:38 +0300 |
---|---|---|
committer | Michael Widenius <monty@mysql.com> | 2009-04-25 12:04:38 +0300 |
commit | 210a412522b10115d34b431c66acf403faab7bfe (patch) | |
tree | 56c09cfd1053265897d114e4acb52d395185f27e /include/my_global.h | |
parent | 059b9356a19118a48fbad31be81c4859e15d3bc8 (diff) | |
parent | 4aeeb1d157a67c5359475d8941267641fb894b22 (diff) | |
download | mariadb-git-210a412522b10115d34b431c66acf403faab7bfe.tar.gz |
bzr merge from guilhem's maria tree to our local 5.1
configure.in:
Manually merged
mysql-test/lib/My/ConfigFactory.pm:
Manually merged
mysql-test/mysql-test-run.pl:
Manually merged
mysql-test/t/information_schema.test:
Manually merged
sql/handler.cc:
Manually merged
support-files/mysql.spec.sh:
Manually merged
Diffstat (limited to 'include/my_global.h')
-rw-r--r-- | include/my_global.h | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/include/my_global.h b/include/my_global.h index 37bcab244ff..f14204cf215 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -430,6 +430,9 @@ C_MODE_END #ifdef HAVE_FLOAT_H #include <float.h> #endif +#ifdef HAVE_FENV_H +#include <fenv.h> /* For fesetround() */ +#endif #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -592,8 +595,39 @@ typedef unsigned short ushort; #define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1)) #define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0]))) #ifndef HAVE_RINT -#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5)) -#endif +/** + All integers up to this number can be represented exactly as double precision + values (DBL_MANT_DIG == 53 for IEEE 754 hardware). +*/ +#define MAX_EXACT_INTEGER ((1LL << DBL_MANT_DIG) - 1) + +/** + rint(3) implementation for platforms that do not have it. + Always rounds to the nearest integer with ties being rounded to the nearest + even integer to mimic glibc's rint() behavior in the "round-to-nearest" + FPU mode. Hardware-specific optimizations are possible (frndint on x86). + Unlike this implementation, hardware will also honor the FPU rounding mode. +*/ + +static inline double rint(double x) +{ + double f, i; + f = modf(x, &i); + /* + All doubles with absolute values > MAX_EXACT_INTEGER are even anyway, + no need to check it. + */ + if (x > 0.0) + i += (double) ((f > 0.5) || (f == 0.5 && + i <= (double) MAX_EXACT_INTEGER && + (longlong) i % 2)); + else + i -= (double) ((f < -0.5) || (f == -0.5 && + i >= (double) -MAX_EXACT_INTEGER && + (longlong) i % 2)); + return i; +} +#endif /* HAVE_RINT */ /* Define some general constants */ #ifndef TRUE @@ -635,7 +669,6 @@ C_MODE_END */ #define _VARARGS(X) X #define _STATIC_VARARGS(X) X -#define _PC(X) X /* The DBUG_ON flag always takes precedence over default DBUG_OFF */ #if defined(DBUG_ON) && defined(DBUG_OFF) @@ -739,7 +772,6 @@ typedef SOCKET_SIZE_TYPE size_socket; #define UNSINT32 /* unsigned int32 */ /* General constants */ -#define SC_MAXWIDTH 256 /* Max width of screen (for error messages) */ #define FN_LEN 256 /* Max file name len */ #define FN_HEADLEN 253 /* Max length of filepart of file name */ #define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */ |