Print this page
11210 libm should be cstyle(1ONBLD) clean
@@ -20,10 +20,11 @@
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -32,24 +33,27 @@
#include <sys/isa_defs.h> /* _ILP32 */
#include "libm.h"
#if defined(_ILP32)
long
-lrintf(float x) {
+lrintf(float x)
+{
/*
* Note: The following code works on x86 (in the default rounding
* precision mode), but one should just use the fistpl instruction
* instead.
*/
union {
unsigned i;
float f;
} xx, yy;
+
unsigned hx;
xx.f = x;
hx = xx.i & ~0x80000000;
+
if (hx < 0x4b000000) { /* |x| < 2^23 */
/* add and subtract a power of two to round x to an integer */
#if defined(__sparc)
yy.i = (xx.i & 0x80000000) | 0x4b000000;
#elif defined(__x86)
@@ -57,14 +61,14 @@
yy.i = (xx.i & 0x80000000) | 0x5f000000;
#else
#error Unknown architecture
#endif
x = (x + yy.f) - yy.f;
- return ((long) x);
+ return ((long)x);
}
/* now x is nan, inf, or integral */
- return ((long) x);
+ return ((long)x);
}
#else
#error Unsupported architecture
#endif /* defined(_ILP32) */