Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_147D71377D1E56A8696F59E1@qq.com>
Date: Tue, 14 Oct 2014 11:04:26 +0800
From: "bobodog" <8192542@...com>
To: "musl" <musl@...ts.openwall.com>
Cc: "musl" <musl@...ts.openwall.com>
Subject: 回复: The math library have some bug forceil,floor,round functioin, in arm mode

I check the musl git repo, found one commit: 


d1a2ead878c27ac4ec600740320f8b76e1f961e9‍
math: rewrite rounding functions (ceil, floor, trunc, round, rint)‍


The old version of ceil and floor functions are tests ok in arm mode.
Here the some old codes:


static const double huge = 1.0e300;


double ceil(double x)
{
	int32_t i0,i1,j0;
	uint32_t i,j;


	EXTRACT_WORDS(i0, i1, x);
	// FIXME signed shift
	j0 = ((i0>>20)&0x7ff) - 0x3ff;
	if (j0 < 20) {
		if (j0 < 0) {
			 /* raise inexact if x != 0 */
			if (huge+x > 0.0) {
				if (i0 < 0) {
					i0 = 0x80000000;
					i1=0;
				} else if ((i0|i1) != 0) {
					i0=0x3ff00000;
					i1=0;
				}
			}
		} else {
			i = 0x000fffff>>j0;
			if (((i0&i)|i1) == 0) /* x is integral */
				return x;
			/* raise inexact flag */
			if (huge+x > 0.0) {
				if (i0 > 0)
					i0 += 0x00100000>>j0;
				i0 &= ~i;
				i1 = 0;
			}
		}
	} else if (j0 > 51) {
		if (j0 == 0x400)  /* inf or NaN */
			return x+x;
		return x;         /* x is integral */
	} else {
		i = (uint32_t)0xffffffff>>(j0-20);
		if ((i1&i) == 0)
			return x; /* x is integral */
		/* raise inexact flag */
		if (huge+x > 0.0) {
			if (i0 > 0) {
				if (j0 == 20)
					i0 += 1;
				else {
					j = i1 + (1<<(52-j0));
					if (j < i1)  /* got a carry */
						i0 += 1;
					i1 = j;
				}
			}
			i1 &= ~i;
		}
	}
	INSERT_WORDS(x, i0, i1);
	return x;
}‍



The old code test in x86 mode passed!


------------------
____________________________
蒋建军                            
深圳市九鼎创展科技有限公司
地址:深圳市宝安区西乡街道宝源路宝安互联网产业基地A区7栋301
邮编:518101
手机:18665386306
电邮:8192542@...com
网站:http://www.9tripod.com

论坛:http://xboot.org
 


 




------------------ 原始邮件 ------------------
发件人: "8192542";<8192542@...com>;
发送时间: 2014年10月14日(星期二) 上午10:51
收件人: "musl"<musl@...ts.openwall.com>; 
抄送: "musl"<musl@...ts.openwall.com>; 
主题: 回复: [musl] [math] The math library have some bug forceil,floor,round functioin, in arm mode



Test it in qemu-system-arm, with soft fp, realview-pb-a8 platform‍


we porting musl to our project, and just write test functions to test cases, i don't kown, how to test musl in origin test cases.


------------------
____________________________
蒋建军                            
深圳市九鼎创展科技有限公司
地址:深圳市宝安区西乡街道宝源路宝安互联网产业基地A区7栋301
邮编:518101
手机:18665386306
电邮:8192542@...com
网站:http://www.9tripod.com

论坛:http://xboot.org
 


 




------------------ 原始邮件 ------------------
发件人: "Rich Felker";<dalias@...c.org>;
发送时间: 2014年10月14日(星期二) 上午10:42
收件人: "bobodog"<8192542@...com>; 
抄送: "musl"<musl@...ts.openwall.com>; 
主题: Re: [musl] [math] The math library have some bug forceil,floor,round functioin, in arm mode



On Tue, Oct 14, 2014 at 10:17:34AM +0800, bobodog wrote:
> HI,ALL
>          We use musl in arm process, but found some bugs about math library,  x86 process is ok!

I can't reproduce this issue. Are you using soft (arm) or hard (armhf)
float based target?

>         The test code:
> int test(int argc, char ** argv)
> {
> 	double n = 0.0;
> 	int i;
> 
> 
> 	for(i = 0; i < 20; i++)
> 	{
> 		n = n - 0.125;
> 		printf("ceil(%f) = %f, floor(%f) = %f, round(%f) = %f\n", n, ceil(n), n, floor(n), n, round(n));
> 	}
> 
> 
> 	return 0;
> }‍

Is this the whole test program? I don't see a main function or any
#include directives. Compiling it with gcc -Dtest=main results in:

foo.c:10:17: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
foo.c:10:78: warning: incompatible implicit declaration of built-in function ‘ceil’ [enabled by default]
foo.c:10:90: warning: incompatible implicit declaration of built-in function ‘floor’ [enabled by default]
foo.c:10:103: warning: incompatible implicit declaration of built-in function ‘round’ [enabled by default]

These warnings should all be treated as errors; calling a function
with variadic arguments (printf) or a function that returns a floating
point type without a valid declaration/prototype is a serious error
and will not work.

Rich
Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.