This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: Re: float error
- From: wjyasd <wjy21cn at 21cn dot com>
- To: newlib <newlib at sources dot redhat dot com>
- Date: Fri, 1 Mar 2002 12:53:33 +0800
- Subject: Re: Re: float error
Jeff,
>Have you made alterations to the library or are you attempting to use
>a piece of the library?
yes .
I am developing library of ANSI C for our Personal Digital Assistant .
Because our production don't powful. so I must make that librarys less than 64k byte.
I had been successd compile newlib-1.8.2 for m68k-elf target under cygwin on my computer!
but It is too big to download into our PDA. On the other side that library is static library
not dynamic link library so I want to make it into DLL version.
Now I have compiled string and ctype dynamic link lib for PDA ,It is work well.
When I compiled stdio library the matter are coming.
>a piece of the library? What error are you getting for _stdout_r
>(_REENT)->_data? Is _REENT (aka _impure_ptr) 0?
I must changed that code in printf.c
_stdout_r (_REENT)->_data = _REENT;
ret = vfprintf (_stdout_r (_REENT), fmt, ap);
into
FILE f;
f._data = _REENT;
ret = vfprintf ( &f, fmt, ap);
that the dll can be debuged .otherwise It will be die at _stdout_r (_REENT)->_data = _REENT; lines.
when I changed it ,the f._data is address 0x7660 not 0 .
so I test printf() and with %c %s %d %f (As default printf output is monitor ,I have
change fvwrite.c to redirect it output PDA display )
%c %s and %d can work right but %f couldn't work. When I use printf("%f",x); in program
and debug it ,the program and target will die, so i must restart computer and m68k-elf target
When I debug it step by step into printf.c and vfprintf.c ,
I found that cvt() function in charge of float . In cvt() function that _dtoa_r() be called!
so I continue debug ...when program run to dtoa.c 240 lines and die ....
234 _Bigint *b, *b1, *delta, *mlo, *mhi, *S;
235 double ds;
- 236 char *s, *s0;
237
- 238 d.d = _d;
239
- 240 if (ptr->_result) <<--------error!@
- 241 {
- 242 ptr->_result->_k = ptr->_result_k;
- 243 ptr->_result->_maxwds = 1 << ptr->_result_k;
244 Bfree (ptr, ptr->_result);
245 ptr->_result = 0;
- 246 }
so I think it maybe _stdout_r (_REENT)->_data = _REENT; cause the error!
if I don't change the code in print.c that program couldn't debug any more..
This problem has been trouble me a long time ,
Can you used your experience to give me some advise to work it out!
thanks
--JinYu Wu
>wjyasd wrote:
>>
>> Hi,
>> I have been trying to get newlib to compile a share library for m68k-elf target under cygwin on win98.
>>
>
>JinYu,
>
> You are going to have to give some details. How did you configure?
>Have you made alterations to the library or are you attempting to use
>a piece of the library? What error are you getting for _stdout_r
>(_REENT)->_data? Is _REENT (aka _impure_ptr) 0?
>
> The reentrancy scheme uses a reentrant structure which should be
>instantiated by libc/reent/impure.c. The _REENT is just a macro
>which defines to _impure_ptr. You should check the value of this
>when you fail. You should also check to see that the impure_data structure
>has properly been initialized.
>
>-- Jeff J.
>
>
>> When I used printf("%f",x) it couldn't run.
>>
>> frist,I change the printf.c
>>
>> // _stdout_r (_REENT)->_data = _REENT;
>> // ret = vfprintf (_stdout_r (_REENT), fmt, ap);
>> into
>> FILE f;
>> f._data = _REENT;
>> ret = vfprintf ( &f, fmt, ap);
>>
>> If I don't change it ,program will stop at " _stdout_r (_REENT)->_data = _REENT;"
>>
>> I debug it into [static char *cvt _PARAMS((struct _reent *, double, int, int, char *, int *, int, int *));] and dtoa.c file
>>
>> And at dtoa.c file
>>
>> 234 _Bigint *b, *b1, *delta, *mlo, *mhi, *S;
>> 235 double ds;
>> - 236 char *s, *s0;
>> 237
>> - 238 d.d = _d;
>> 239
>> - 240 if (ptr->_result) <<--------error!@
>> - 241 {
>> - 242 ptr->_result->_k = ptr->_result_k;
>> - 243 ptr->_result->_maxwds = 1 << ptr->_result_k;
>> 244 Bfree (ptr, ptr->_result);
>> 245 ptr->_result = 0;
>> - 246 }
>>
>>
>> When program run to 240 lines It stop again ,I don't know how to work out .
>> Can float part running under m68k if not can someone point me at the right line
>> to use.
>>
>> thanks
>>
>> JinYU Wu