Redlib stdlib.h issues

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Redlib stdlib.h issues

1,421件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micronpn on Wed Jul 09 10:33:13 MST 2014
Because function I need are declared in stdlib.h I decided to test all functions declared in it.
These are my results:

1. abort(): is not C standard lib compliant because it calls function(s) defined to be execute before exit using atexit(). The standard says that he abort function causes abnormal program termination. This does not execute cleanup functions registered with atexit or on_exit.
It should also raise SIGABRT signal that could be intercepted by the user.
I tryed to test abort() and SIGABRT but seems that signals aren't handled in Redlib also if signal macros, signal() and raise() are declared in signal.h

2. atoll(), llabs(), lldiv(), strtoll(), strtoull(), strtold(), _Exit():
declared in stdlib.h but not implemented in the library. But ldiv_t and lldiv_t are defined.

3. mblen(), mbtowc(), wctomb(), mbstowcs(), wcstombs()
declared and implemented but wprintf() is not implemented and printf() doesn't accept %ls or %S to print wchar_t strings.

Actually I don't need wchar_t support functions but I still need 64bit data type functions so I am implementing them.
0 件の賞賛
返信
3 返答(返信)

1,257件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Fri Jul 11 11:01:46 MST 2014
Thanks for the information on wchar_t - I'll take a look at this.

Based on what you have said about exit() etc, I suggest that you consider implementing your own versions - as the Redlib ones are never going to do what you want. In fact the current plan is to actually remove their functionality completely.

Regards,
LPCXpresso Support
0 件の賞賛
返信

1,257件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micronpn on Thu Jul 10 03:35:11 MST 2014
I found another unconsistency:

GCC by defaults treats wchar_t as a 4 byte long integer and also redlib was built with this setup but in stdlib.h wchar_t is defined to be 2 bytes longer so to properly test and use wchar_t functions stdlib.h and any other .h file should be modified to define wchar_t as 4 bytes integer. Alternatively redlib should be rebuilt with  -fshort-wchar

I know that  a set of C90/C99 functions handling with files, system and environment aren't implemented (also if I am always surprised when a scanf or printf family function is not implemented).

I am more surprised when wide char functions are implemented or standard 64bit conversion functions aren't implemented.

In this particular case I need to add the 64bits support functions.

About the abort() "bug". It is not an important bug, the only thing that should be corrected is that it hasn't to call functions declared by atexit(), if signals aren't implemented documentation should only report that abort() doesn't rise SIGABRT signal.

About exit(), atexit(), setjmp() and longjmp() functions: if properly used they are the most valuable to recover a software error or at least log it before to reset the microcontroller.

It is true that Cortex-M3 have 2 different ways to reset the microcontroller but if you reuse old software using the 4 functions I mentioned before, it is simpler to implement them if they are not supported.

About the 64bit functions: they should be frequently used considering that Cortex-M3 is a 32bit mcu.
0 件の賞賛
返信

1,257件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Thu Jul 10 00:34:26 MST 2014
Thank you for your continuing feedback following on from your previous thread.  We'll look into these additional discrepancies between the headers and the library implementation.

It is worth stressing that although Redlib is basically a C90 library, it is aimed completely at embedded use. Some functions that basically rely on being used in an application being run within a full desktop operating system, are not expected to be of use in an embedded system, and hence they may not be implemented, or not implemented in a complete manner. For example we would not expect you to need to call exit() or related functions.

We aim to start expanding our Redlib documentation to cover such issues over the coming months.

Regards,
LPCXpresso Support
0 件の賞賛
返信