Re: _REENT_CHECK_VERIFY calls __assert_func even if NDEBUG is defined

"R. Diez via Newlib" <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
> An alternative change would require modifications to all the
> existing conversion routines using eBalloc() and their callers
> to do checking of return values and bubble up to the user,
> setting errno to ENOMEM.

I am not sure what conversion routines you are referring to. I found this issue with rand(), because lwIP needs a source of random numbers. It is normally not expected that rand() calls malloc(). rand() returns no error indication, according to the POSIX standard:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/rand.html

So using errno here is difficult.

rand() ends up calling _REENT_CHECK, which does a malloc(). What do you mean with eBalloc()?

  
> The memory in question is being allocated by Balloc()
> which is part of the mprec.c solution used in newlib.
> The allocated _REENT_MP_FREELIST has an array
> of storage to reuse for different k values so newlib will reuse
> [...]

Does that apply in my scenario? I am building Newlib without thread support. There is no reent creation or destruction, as far as I can tell.

I have been digging further, and I believe (the code is not easy to follow) that these unexpected allocations come from using the "small reent". What does --enable-newlib-reent-small actually do? The README file at this location:

  https://sourceware.org/newlib/README

has this description:

  `--enable-newlib-reent-small'
    Enable small reentrant struct support.
    Disabled by default.

But it does not really say what the difference between the normal and "small" versions is.

Thanks in advance,
  rdiez
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.