Hello,
I discover some strange behaviour of sqrtf() function when usart
interrupts are enabled.
My  sdcclibs are compiled with --stack-auto option, libm too.
My program is simple and just do a sqrt calculations in endless loop
(my code compiled is with --stack-auto):

float val;
unsigned int x;
while(1){
  val=sqrtf(20000);
  x=(unsigned int) val;
 if(x!=141) printf("x=%u val=%.4f",x,val);
}

When usart receive some data (usart interrupt routine does some
integer calculations, only integer, not float) sometimes I get
randomly wrong values from sqrtf():
x=0 val=0.0000
x=19 val=19.0000
x=1 val=1.0000

I suspect some reentrancy problems, becouse when usart doesn't receive
any chars, sqrtf always return 141.4214
As I metioned above libsdcc and lib are compiled with --stack-auto, so
all helper (int/float) functions should be reentrant...

regards,
ml

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to