newlib/newlib/libc
Craig Blackmore ab215e3dd1 libc/stdlib: Fix build failure in nano_calloc
commit 588a5e1dde added a non-reentrant
call to nano_malloc which causes a build failure if INTERNAL_NEWLIB is
defined.

Here is a snippet of the error:

In file included from .../newlib/newlib/libc/stdlib/nano-mallocr.c:38:
.../newlib/newlib/libc/include/malloc.h:42:25: note: expected 'struct _reent *' but argument is of type 'ptrdiff_t' {aka 'int'}
   42 | extern void *_malloc_r (struct _reent *, size_t);
      |                         ^~~~~~~~~~~~~~~
.../newlib/newlib/libc/stdlib/nano-mallocr.c:67:22: error: too few arguments to function '_malloc_r'
   67 | #define nano_malloc  _malloc_r
      |                      ^~~~~~~~~
.../newlib/newlib/libc/stdlib/nano-mallocr.c:456:11: note: in expansion of macro 'nano_malloc'
  456 |     mem = nano_malloc(bytes);
      |           ^~~~~~~~~~~
In file included from .../newlib/newlib/libc/stdlib/nano-mallocr.c:38:
.../newlib/newlib/libc/include/malloc.h:42:14: note: declared here
   42 | extern void *_malloc_r (struct _reent *, size_t);
      |              ^~~~~~~~~
.../newlib/newlib/libc/stdlib/nano-mallocr.c:43: warning: "assert" redefined
   43 | #define assert(x) ((void)0)
      |

This patch adds a missing RCALL to the args when calling nano_malloc
from nano_calloc, so that if the call is reentrant, reent_ptr is passed
as the first argument.

The variable `bytes` (also added in 588a5e1d) has been changed from a
`ptrdiff_t` to `malloc_size_t` as it does not need to be signed. It is
used to store the product of two unsigned malloc_size_t variables and
then iff there was no overflow is it passed to malloc and memset which
both expect size_t which is unsigned.

Signed-off-by: Craig Blackmore <craig.blackmore@embecosm.com>
2020-08-13 09:59:45 +02:00
..
argz ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
ctype Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
errno makedoc: make errors visible 2017-12-07 11:54:11 +00:00
iconv libc/iconv: find_alias was mis-computing remaining alias table length 2020-07-10 10:51:43 +02:00
include libm: Control errno support with _IEEE_LIBM configuration parameter 2020-08-05 22:23:02 +02:00
locale Locale modifier "@cjksingle" to enforce single-width CJK width. 2020-02-18 11:35:42 +01:00
machine arm: Fix fenv support 2020-07-29 06:58:17 +02:00
misc Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
posix Cygwin: posix_spawn: add Cygwin-specific code fixing process synchronisation 2020-08-03 12:41:44 +02:00
reent ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
search Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
signal Fix newlib functions perror()/psignal() not to use writev(). 2018-07-05 15:33:49 -04:00
ssp AMD GCN Port contributed by Andrew Stubbs <ams@codesourcery.com> 2019-01-15 10:48:08 -05:00
stdio Typo in license for newlib/libc/stdio/flags.c 2020-02-06 11:58:50 +01:00
stdio64 Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
stdlib libc/stdlib: Fix build failure in nano_calloc 2020-08-13 09:59:45 +02:00
string Locale modifier "@cjksingle" to enforce single-width CJK width. 2020-02-18 11:35:42 +01:00
sys RTEMS: Include missing header and fix stub 2020-03-13 13:51:20 -05:00
syscalls ansification: remove _HAVE_STDC 2018-01-17 11:47:30 -06:00
time newlib: strftime: fix over-enthusiastic fix from 0283642f35 2018-08-08 23:59:34 +02:00
unix Fix comparison between two character arrays 2018-07-30 09:36:49 +02:00
xdr xdr_private.h needs sys/types.h for u_char 2018-09-06 14:10:42 +02:00
Makefile.am ssp: add build infrastructure 2017-11-29 11:25:46 -06:00
Makefile.in ssp: add build infrastructure 2017-11-29 11:25:46 -06:00
aclocal.m4 Fix up errors in regenerated files for 2.3.0 release. 2016-01-04 12:57:31 -05:00
configure Bump up newlib release to 3.3.0 2020-01-21 15:17:43 -05:00
configure.in ssp: add build infrastructure 2017-11-29 11:25:46 -06:00
libc.in.xml ssp: add documentation 2017-11-29 11:25:45 -06:00
libc.texinfo ssp: add documentation 2017-11-29 11:25:45 -06:00
saber Remove matherr, and SVID and X/Open math library configurations 2019-01-23 10:46:24 +01:00
sys.tex Don't include stdio64 functions in reentrant syscalls menu when not bulding stdio64. 2015-08-03 09:54:33 +01:00