[asterisk-bugs] [Asterisk 0018193]: [patch] roundf causing asterisk to fail to compile

Asterisk Bug Tracker noreply at bugs.digium.com
Mon Jan 10 10:26:39 CST 2011


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=18193 
====================================================================== 
Reported By:                ovi
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   18193
Category:                   Core/Portability
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     ready for testing
Asterisk Version:           1.6.2.16-rc1 
JIRA:                       SWP-2884 
Regression:                 No 
Reviewboard Link:            
SVN Branch (only for SVN checkouts, not tarball releases): 1.6.2 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2010-10-22 15:56 CDT
Last Modified:              2011-01-10 10:26 CST
====================================================================== 
Summary:                    [patch] roundf causing asterisk to fail to compile
Description: 
roundf is not available on some embedded systems and this is causing the
compilation to fail.
By applying the following patch, the issue was circumvented:

<inline patch removed by lmadsen>

Can we add a detection for roundf during configure and ifdef the roundf
call?
====================================================================== 

---------------------------------------------------------------------- 
 (0130356) wdoekes (reporter) - 2011-01-10 10:26
 https://issues.asterisk.org/view.php?id=18193#c130356 
---------------------------------------------------------------------- 
I don't know if it would cause problems, but

#define roundf(a)	((float) (int) ((a) + 0.5))

is wrong.

The manual for round states that it should round halfway cases away from
zero.

See this:


walter at walter-laptop:0:~$ cat 1.c 
#include <stdio.h>
#include <math.h>
#define bad_roundf(a) ((float) (int) ((a) + 0.5))
float better_roundf(float a) { if (a < 0.0) return (float)(int)((a) -
0.5); return (float)(int)((a) + 0.5); }
int main() {
	printf("%.1f %.1f\n", roundf(0.5), roundf(-0.5));
	printf("%.1f %.1f\n", bad_roundf(0.5), bad_roundf(-0.5));
	printf("%.1f %.1f\n", better_roundf(0.5), better_roundf(-0.5));
	return 0;
}
walter at walter-laptop:0:~$ gcc 1.c 
walter at walter-laptop:0:~$ ./a.out 
1.0 -1.0
1.0 0.0
1.0 -1.0 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-01-10 10:26 wdoekes        Note Added: 0130356                          
======================================================================




More information about the asterisk-bugs mailing list