[PATCH 0/5] newlib: when building with TLS, don't pass a _reent *
H. Peter Anvin
hpa@zytor.com
Thu Dec 3 22:01:34 GMT 2026
This patchset removes the passing of an explicit "struct _reent *"
around when compiling with TLS enabled
(--enable-newlib-reent-thread-local).
This relies on separate C and C++ extensions, available in both gcc
and clang:
1. In C, an empty structure requires no space.
2. In C++, a structure containing only a zero-length array
requires no space.
The C++ case matters, because in a few cases this type is visible
outside the library.
The first patch very large but it is strictly a mechanical type name
change.
H. Peter Anvin (5):
newlib: use __reent_ptr_t for reentrancy context arguments
newlib: test reentrancy context argument forwarding
newlib: prepare to eliminate unused TLS context arguments
configure: check for zero-sized empty structure support
newlib: use empty reentrancy context arguments with TLS
libgloss/aarch64/syscalls.c | 2 +-
libgloss/arm/syscalls.c | 2 +-
libgloss/epiphany/sbrk.c | 6 +-
libgloss/m32r/eit.h | 2 +-
libgloss/m32r/trapmon0.c | 2 +-
libgloss/or1k/impure.c | 12 +-
libgloss/or1k/sbrk.c | 2 +-
libgloss/or1k/syscalls.c | 58 ++---
libgloss/or1k/util.c | 12 +-
libgloss/rs6000/sim-errno.c | 2 +-
newlib/README | 6 +
newlib/configure | 31 +++
newlib/configure.ac | 13 ++
newlib/libc/ctype/towctrans.c | 2 +-
newlib/libc/ctype/wctrans.c | 2 +-
newlib/libc/ctype/wctype.c | 2 +-
newlib/libc/iconv/ces/euc.c | 8 +-
newlib/libc/iconv/ces/table-pcs.c | 8 +-
newlib/libc/iconv/ces/table.c | 12 +-
newlib/libc/iconv/ces/ucs-2.c | 4 +-
newlib/libc/iconv/ces/ucs-4.c | 4 +-
newlib/libc/iconv/ces/utf-16.c | 6 +-
newlib/libc/iconv/lib/aliasesi.c | 12 +-
newlib/libc/iconv/lib/conv.h | 12 +-
newlib/libc/iconv/lib/iconv.c | 12 +-
newlib/libc/iconv/lib/iconvnls.c | 12 +-
newlib/libc/iconv/lib/nullconv.c | 6 +-
newlib/libc/iconv/lib/ucsconv.c | 6 +-
newlib/libc/iconv/lib/ucsconv.h | 12 +-
newlib/libc/include/envlock.h | 4 +-
newlib/libc/include/iconv.h | 6 +-
newlib/libc/include/inttypes.h | 11 +-
newlib/libc/include/locale.h | 16 +-
newlib/libc/include/malloc.h | 30 +--
newlib/libc/include/reent.h | 52 ++---
newlib/libc/include/signal.h | 7 +-
newlib/libc/include/stdio.h | 210 +++++++++----------
newlib/libc/include/stdlib.h | 86 ++++----
newlib/libc/include/string.h | 6 +-
newlib/libc/include/sys/_types.h | 23 ++
newlib/libc/include/sys/iconvnls.h | 8 +-
newlib/libc/include/sys/reent.h | 46 ++--
newlib/libc/include/time.h | 2 +-
newlib/libc/include/wchar.h | 88 ++++----
newlib/libc/locale/duplocale.c | 2 +-
newlib/libc/locale/freelocale.c | 2 +-
newlib/libc/locale/getlocalename_l.c | 2 +-
newlib/libc/locale/locale.c | 4 +-
newlib/libc/locale/localeconv.c | 2 +-
newlib/libc/locale/newlocale.c | 2 +-
newlib/libc/locale/setlocale.h | 12 +-
newlib/libc/locale/uselocale.c | 2 +-
newlib/libc/machine/amdgcn/getreent.c | 2 +-
newlib/libc/machine/amdgcn/mlock.c | 4 +-
newlib/libc/machine/amdgcn/simt-malloc.c | 24 +--
newlib/libc/machine/msp430/tiny-printf.c | 8 +-
newlib/libc/machine/nvptx/callocr.c | 2 +-
newlib/libc/machine/nvptx/mallocr.c | 4 +-
newlib/libc/machine/nvptx/reallocr.c | 2 +-
newlib/libc/machine/powerpc/atosfix16.c | 2 +-
newlib/libc/machine/powerpc/atosfix32.c | 2 +-
newlib/libc/machine/powerpc/atosfix64.c | 2 +-
newlib/libc/machine/powerpc/atoufix16.c | 2 +-
newlib/libc/machine/powerpc/atoufix32.c | 2 +-
newlib/libc/machine/powerpc/atoufix64.c | 2 +-
newlib/libc/machine/powerpc/machine/malloc.h | 4 +-
newlib/libc/machine/powerpc/machine/stdlib.h | 28 +--
newlib/libc/machine/powerpc/simdldtoa.c | 4 +-
newlib/libc/machine/powerpc/strtosfix16.c | 2 +-
newlib/libc/machine/powerpc/strtosfix32.c | 2 +-
newlib/libc/machine/powerpc/strtosfix64.c | 2 +-
newlib/libc/machine/powerpc/strtoufix16.c | 2 +-
newlib/libc/machine/powerpc/strtoufix32.c | 2 +-
newlib/libc/machine/powerpc/strtoufix64.c | 2 +-
newlib/libc/machine/powerpc/ufix64toa.c | 4 +-
newlib/libc/machine/powerpc/vec_mallocr.c | 10 +-
newlib/libc/machine/powerpc/vfprintf.c | 22 +-
newlib/libc/machine/powerpc/vfscanf.c | 4 +-
newlib/libc/machine/spu/c99ppe.h | 4 +-
newlib/libc/machine/spu/fopen.c | 2 +-
newlib/libc/machine/spu/stdio.c | 6 +-
newlib/libc/machine/spu/tmpfile.c | 2 +-
newlib/libc/machine/xstormy16/callocr.c | 2 +-
newlib/libc/machine/xstormy16/freer.c | 2 +-
newlib/libc/machine/xstormy16/mallocr.c | 2 +-
newlib/libc/machine/xstormy16/reallocr.c | 2 +-
newlib/libc/reent/closer.c | 4 +-
newlib/libc/reent/execr.c | 12 +-
newlib/libc/reent/fcntlr.c | 4 +-
newlib/libc/reent/fstat64r.c | 4 +-
newlib/libc/reent/fstatr.c | 4 +-
newlib/libc/reent/getentropyr.c | 4 +-
newlib/libc/reent/getreent.c | 2 +-
newlib/libc/reent/gettimeofdayr.c | 4 +-
newlib/libc/reent/isattyr.c | 4 +-
newlib/libc/reent/linkr.c | 4 +-
newlib/libc/reent/lseek64r.c | 4 +-
newlib/libc/reent/lseekr.c | 4 +-
newlib/libc/reent/mkdirr.c | 4 +-
newlib/libc/reent/open64r.c | 4 +-
newlib/libc/reent/openr.c | 4 +-
newlib/libc/reent/readr.c | 4 +-
newlib/libc/reent/reent.c | 2 +-
newlib/libc/reent/reent.tex | 10 +
newlib/libc/reent/renamer.c | 4 +-
newlib/libc/reent/sbrkr.c | 4 +-
newlib/libc/reent/signalr.c | 8 +-
newlib/libc/reent/stat64r.c | 4 +-
newlib/libc/reent/statr.c | 4 +-
newlib/libc/reent/timesr.c | 4 +-
newlib/libc/reent/unlinkr.c | 4 +-
newlib/libc/reent/writer.c | 4 +-
newlib/libc/signal/raise.c | 2 +-
newlib/libc/signal/signal.c | 8 +-
newlib/libc/stdio/asiprintf.c | 2 +-
newlib/libc/stdio/asniprintf.c | 4 +-
newlib/libc/stdio/asnprintf.c | 6 +-
newlib/libc/stdio/asprintf.c | 4 +-
newlib/libc/stdio/diprintf.c | 6 +-
newlib/libc/stdio/dprintf.c | 10 +-
newlib/libc/stdio/fclose.c | 4 +-
newlib/libc/stdio/fcloseall.c | 4 +-
newlib/libc/stdio/fdopen.c | 4 +-
newlib/libc/stdio/fflush.c | 10 +-
newlib/libc/stdio/fgetc.c | 8 +-
newlib/libc/stdio/fgetc_u.c | 4 +-
newlib/libc/stdio/fgetpos.c | 4 +-
newlib/libc/stdio/fgets.c | 6 +-
newlib/libc/stdio/fgetwc.c | 14 +-
newlib/libc/stdio/fgetwc_u.c | 4 +-
newlib/libc/stdio/fgetws.c | 8 +-
newlib/libc/stdio/findfp.c | 18 +-
newlib/libc/stdio/fiprintf.c | 2 +-
newlib/libc/stdio/fiscanf.c | 2 +-
newlib/libc/stdio/flags.c | 2 +-
newlib/libc/stdio/fmemopen.c | 12 +-
newlib/libc/stdio/fopen.c | 4 +-
newlib/libc/stdio/fopencookie.c | 12 +-
newlib/libc/stdio/fprintf.c | 4 +-
newlib/libc/stdio/fpurge.c | 4 +-
newlib/libc/stdio/fputc.c | 4 +-
newlib/libc/stdio/fputc_u.c | 4 +-
newlib/libc/stdio/fputs.c | 6 +-
newlib/libc/stdio/fputwc.c | 14 +-
newlib/libc/stdio/fputwc_u.c | 4 +-
newlib/libc/stdio/fputws.c | 8 +-
newlib/libc/stdio/fread.c | 8 +-
newlib/libc/stdio/freopen.c | 4 +-
newlib/libc/stdio/fscanf.c | 4 +-
newlib/libc/stdio/fseek.c | 6 +-
newlib/libc/stdio/fseeko.c | 8 +-
newlib/libc/stdio/fsetpos.c | 4 +-
newlib/libc/stdio/ftell.c | 6 +-
newlib/libc/stdio/ftello.c | 6 +-
newlib/libc/stdio/funopen.c | 12 +-
newlib/libc/stdio/fvwrite.c | 2 +-
newlib/libc/stdio/fvwrite.h | 4 +-
newlib/libc/stdio/fwalk.c | 2 +-
newlib/libc/stdio/fwide.c | 4 +-
newlib/libc/stdio/fwprintf.c | 2 +-
newlib/libc/stdio/fwrite.c | 6 +-
newlib/libc/stdio/fwscanf.c | 2 +-
newlib/libc/stdio/getc.c | 6 +-
newlib/libc/stdio/getc_u.c | 2 +-
newlib/libc/stdio/getchar.c | 6 +-
newlib/libc/stdio/getchar_u.c | 4 +-
newlib/libc/stdio/gets.c | 4 +-
newlib/libc/stdio/getwc.c | 2 +-
newlib/libc/stdio/getwc_u.c | 2 +-
newlib/libc/stdio/getwchar.c | 6 +-
newlib/libc/stdio/getwchar_u.c | 2 +-
newlib/libc/stdio/iprintf.c | 4 +-
newlib/libc/stdio/iscanf.c | 2 +-
newlib/libc/stdio/local.h | 68 +++---
newlib/libc/stdio/makebuf.c | 4 +-
newlib/libc/stdio/mktemp.c | 26 +--
newlib/libc/stdio/nano-vfprintf.c | 32 +--
newlib/libc/stdio/nano-vfprintf_float.c | 8 +-
newlib/libc/stdio/nano-vfprintf_i.c | 8 +-
newlib/libc/stdio/nano-vfprintf_local.h | 14 +-
newlib/libc/stdio/nano-vfscanf.c | 28 +--
newlib/libc/stdio/nano-vfscanf_float.c | 2 +-
newlib/libc/stdio/nano-vfscanf_i.c | 6 +-
newlib/libc/stdio/nano-vfscanf_local.h | 10 +-
newlib/libc/stdio/open_memstream.c | 14 +-
newlib/libc/stdio/perror.c | 4 +-
newlib/libc/stdio/printf.c | 6 +-
newlib/libc/stdio/putc.c | 6 +-
newlib/libc/stdio/putc_u.c | 4 +-
newlib/libc/stdio/putchar.c | 6 +-
newlib/libc/stdio/putchar_u.c | 2 +-
newlib/libc/stdio/puts.c | 4 +-
newlib/libc/stdio/putwc.c | 2 +-
newlib/libc/stdio/putwc_u.c | 2 +-
newlib/libc/stdio/putwchar.c | 6 +-
newlib/libc/stdio/putwchar_u.c | 2 +-
newlib/libc/stdio/refill.c | 4 +-
newlib/libc/stdio/remove.c | 4 +-
newlib/libc/stdio/rewind.c | 4 +-
newlib/libc/stdio/rget.c | 2 +-
newlib/libc/stdio/scanf.c | 6 +-
newlib/libc/stdio/setvbuf.c | 2 +-
newlib/libc/stdio/sfputs_r.c | 2 +-
newlib/libc/stdio/sfputws_r.c | 2 +-
newlib/libc/stdio/siprintf.c | 14 +-
newlib/libc/stdio/siscanf.c | 8 +-
newlib/libc/stdio/sniprintf.c | 4 +-
newlib/libc/stdio/snprintf.c | 6 +-
newlib/libc/stdio/sprint_r.c | 2 +-
newlib/libc/stdio/sprintf.c | 16 +-
newlib/libc/stdio/sscanf.c | 10 +-
newlib/libc/stdio/ssprint_r.c | 4 +-
newlib/libc/stdio/ssputs_r.c | 2 +-
newlib/libc/stdio/ssputws_r.c | 4 +-
newlib/libc/stdio/sswprint_r.c | 4 +-
newlib/libc/stdio/stdio.c | 10 +-
newlib/libc/stdio/swprint_r.c | 2 +-
newlib/libc/stdio/swprintf.c | 10 +-
newlib/libc/stdio/swscanf.c | 8 +-
newlib/libc/stdio/tmpfile.c | 4 +-
newlib/libc/stdio/tmpnam.c | 16 +-
newlib/libc/stdio/ungetc.c | 6 +-
newlib/libc/stdio/ungetwc.c | 6 +-
newlib/libc/stdio/vasiprintf.c | 2 +-
newlib/libc/stdio/vasniprintf.c | 2 +-
newlib/libc/stdio/vasnprintf.c | 4 +-
newlib/libc/stdio/vasprintf.c | 4 +-
newlib/libc/stdio/vdiprintf.c | 2 +-
newlib/libc/stdio/vdprintf.c | 4 +-
newlib/libc/stdio/vfprintf.c | 38 ++--
newlib/libc/stdio/vfscanf.c | 28 +--
newlib/libc/stdio/vfwprintf.c | 28 +--
newlib/libc/stdio/vfwscanf.c | 20 +-
newlib/libc/stdio/viprintf.c | 16 +-
newlib/libc/stdio/viscanf.c | 10 +-
newlib/libc/stdio/vprintf.c | 6 +-
newlib/libc/stdio/vscanf.c | 6 +-
newlib/libc/stdio/vsiprintf.c | 2 +-
newlib/libc/stdio/vsiscanf.c | 2 +-
newlib/libc/stdio/vsniprintf.c | 2 +-
newlib/libc/stdio/vsnprintf.c | 4 +-
newlib/libc/stdio/vsprintf.c | 4 +-
newlib/libc/stdio/vsscanf.c | 4 +-
newlib/libc/stdio/vswprintf.c | 2 +-
newlib/libc/stdio/vswscanf.c | 2 +-
newlib/libc/stdio/vwprintf.c | 4 +-
newlib/libc/stdio/vwscanf.c | 4 +-
newlib/libc/stdio/wbuf.c | 2 +-
newlib/libc/stdio/wbufw.c | 2 +-
newlib/libc/stdio/wprintf.c | 4 +-
newlib/libc/stdio/wscanf.c | 4 +-
newlib/libc/stdio/wsetup.c | 2 +-
newlib/libc/stdio64/fdopen64.c | 2 +-
newlib/libc/stdio64/fgetpos64.c | 4 +-
newlib/libc/stdio64/fopen64.c | 2 +-
newlib/libc/stdio64/freopen64.c | 4 +-
newlib/libc/stdio64/fseeko64.c | 6 +-
newlib/libc/stdio64/fsetpos64.c | 4 +-
newlib/libc/stdio64/ftello64.c | 4 +-
newlib/libc/stdio64/stdio64.c | 4 +-
newlib/libc/stdio64/tmpfile64.c | 2 +-
newlib/libc/stdlib/__adjust.c | 2 +-
newlib/libc/stdlib/_mallocr.c | 10 +-
newlib/libc/stdlib/atoi.c | 6 +-
newlib/libc/stdlib/atol.c | 2 +-
newlib/libc/stdlib/atoll.c | 4 +-
newlib/libc/stdlib/drand48.c | 2 +-
newlib/libc/stdlib/dtoa.c | 2 +-
newlib/libc/stdlib/ecvtbuf.c | 12 +-
newlib/libc/stdlib/envlock.c | 8 +-
newlib/libc/stdlib/erand48.c | 2 +-
newlib/libc/stdlib/gdtoa-dmisc.c | 12 +-
newlib/libc/stdlib/gdtoa-gdtoa.c | 6 +-
newlib/libc/stdlib/gdtoa-gethex.c | 4 +-
newlib/libc/stdlib/gdtoa-ldtoa.c | 4 +-
newlib/libc/stdlib/gdtoa.h | 8 +-
newlib/libc/stdlib/gdtoaimp.h | 4 +-
newlib/libc/stdlib/getenv_r.c | 6 +-
newlib/libc/stdlib/jrand48.c | 2 +-
newlib/libc/stdlib/l64a.c | 2 +-
newlib/libc/stdlib/lcong48.c | 2 +-
newlib/libc/stdlib/ldtoa.c | 4 +-
newlib/libc/stdlib/local.h | 6 +-
newlib/libc/stdlib/lrand48.c | 2 +-
newlib/libc/stdlib/mblen.c | 2 +-
newlib/libc/stdlib/mblen_r.c | 4 +-
newlib/libc/stdlib/mbrlen.c | 2 +-
newlib/libc/stdlib/mbrtowc.c | 4 +-
newlib/libc/stdlib/mbsnrtowcs.c | 6 +-
newlib/libc/stdlib/mbsrtowcs.c | 2 +-
newlib/libc/stdlib/mbstowcs_r.c | 2 +-
newlib/libc/stdlib/mbtowc.c | 2 +-
newlib/libc/stdlib/mbtowc_r.c | 100 ++++-----
newlib/libc/stdlib/mlock.c | 8 +-
newlib/libc/stdlib/mprec.c | 20 +-
newlib/libc/stdlib/mprec.h | 30 +--
newlib/libc/stdlib/mrand48.c | 2 +-
newlib/libc/stdlib/mstats.c | 2 +-
newlib/libc/stdlib/nano-mallocr.c | 4 +-
newlib/libc/stdlib/nrand48.c | 2 +-
newlib/libc/stdlib/putenv_r.c | 2 +-
newlib/libc/stdlib/rand.c | 4 +-
newlib/libc/stdlib/rand48.c | 2 +-
newlib/libc/stdlib/rand48.h | 2 +-
newlib/libc/stdlib/random.c | 4 +-
newlib/libc/stdlib/reallocf.c | 2 +-
newlib/libc/stdlib/seed48.c | 2 +-
newlib/libc/stdlib/setenv.c | 2 +-
newlib/libc/stdlib/setenv_r.c | 6 +-
newlib/libc/stdlib/srand48.c | 2 +-
newlib/libc/stdlib/std.h | 2 +-
newlib/libc/stdlib/strtod.c | 4 +-
newlib/libc/stdlib/strtodg.c | 10 +-
newlib/libc/stdlib/strtoimax.c | 4 +-
newlib/libc/stdlib/strtol.c | 4 +-
newlib/libc/stdlib/strtold.c | 4 +-
newlib/libc/stdlib/strtoll.c | 4 +-
newlib/libc/stdlib/strtorQ.c | 4 +-
newlib/libc/stdlib/strtorx.c | 4 +-
newlib/libc/stdlib/strtoul.c | 4 +-
newlib/libc/stdlib/strtoull.c | 4 +-
newlib/libc/stdlib/strtoumax.c | 4 +-
newlib/libc/stdlib/system.c | 8 +-
newlib/libc/stdlib/wcrtomb.c | 4 +-
newlib/libc/stdlib/wcsnrtombs.c | 8 +-
newlib/libc/stdlib/wcsrtombs.c | 2 +-
newlib/libc/stdlib/wcstod.c | 6 +-
newlib/libc/stdlib/wcstoimax.c | 4 +-
newlib/libc/stdlib/wcstol.c | 4 +-
newlib/libc/stdlib/wcstoll.c | 4 +-
newlib/libc/stdlib/wcstombs_r.c | 2 +-
newlib/libc/stdlib/wcstoul.c | 4 +-
newlib/libc/stdlib/wcstoull.c | 4 +-
newlib/libc/stdlib/wcstoumax.c | 4 +-
newlib/libc/stdlib/wctob.c | 2 +-
newlib/libc/stdlib/wctomb.c | 2 +-
newlib/libc/stdlib/wctomb_r.c | 100 ++++-----
newlib/libc/string/strdup_r.c | 2 +-
newlib/libc/string/strerror.c | 2 +-
newlib/libc/string/strndup_r.c | 2 +-
newlib/libc/string/strsignal.c | 2 +-
newlib/libc/string/strtok.c | 2 +-
newlib/libc/string/wcsdup.c | 4 +-
newlib/libc/sys/arm/syscalls.c | 2 +-
newlib/libc/sys/atari/filemode.c | 2 +-
newlib/libc/sys/or1k/mlock.c | 4 +-
newlib/libc/sys/rdos/rdoshelp.c | 2 +-
newlib/libc/sys/rtems/crt0.c | 50 ++---
newlib/libc/syscalls/syssbrk.c | 2 +-
newlib/libc/time/asctime.c | 2 +-
newlib/libc/time/gmtime.c | 2 +-
newlib/libc/time/lcltime.c | 2 +-
newlib/libc/time/local.h | 2 +-
newlib/libc/time/strftime.c | 2 +-
newlib/libc/time/tzset.c | 2 +-
newlib/libc/time/tzset_r.c | 4 +-
newlib/libc/unix/pread.c | 4 +-
newlib/libc/unix/pwrite.c | 4 +-
newlib/newlib.hin | 3 +
newlib/testsuite/newlib.stdlib/reent_ptr.c | 72 +++++++
360 files changed, 1535 insertions(+), 1365 deletions(-)
create mode 100644 newlib/testsuite/newlib.stdlib/reent_ptr.c
--
2.56.1
More information about the Newlib
mailing list