From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1921) id C44AD3853809; Wed, 4 May 2022 15:34:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C44AD3853809 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Sebastian Huber To: cygwin-cvs@sourceware.org, newlib-cvs@sourceware.org Subject: [newlib-cygwin] Remove _global_impure_ptr indirection X-Act-Checkin: newlib-cygwin X-Git-Author: Sebastian Huber X-Git-Refname: refs/heads/master X-Git-Oldrev: 357d7fcc6ad1b0660e2b3131d09eb22e2559e46d X-Git-Newrev: ad51d0006a0aaf17aa61ec34221add09bfe01f0c Message-Id: <20220504153435.C44AD3853809@sourceware.org> Date: Wed, 4 May 2022 15:34:35 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2022 15:34:35 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dad51d0006a0= aaf17aa61ec34221add09bfe01f0c commit ad51d0006a0aaf17aa61ec34221add09bfe01f0c Author: Sebastian Huber Date: Tue May 3 14:51:55 2022 +0200 Remove _global_impure_ptr indirection =20 Remove the pointer indirection through the read-only _global_impure_ptr= and directly use a externally visible _impure_data object of type struct _r= eent. This enables the static initialization of global data structures in a f= ollow up patch. In addition, we get rid of a machine-specific file. Diff: --- newlib/Makefile.in | 21 +-------------------- newlib/libc/include/sys/reent.h | 9 +++++++-- newlib/libc/machine/spu/Makefile.inc | 2 +- newlib/libc/machine/spu/impure.c | 14 -------------- newlib/libc/machine/spu/sys/errno.h | 1 - newlib/libc/reent/impure.c | 16 +++------------- winsup/cygwin/dcrt0.cc | 2 +- 7 files changed, 13 insertions(+), 52 deletions(-) diff --git a/newlib/Makefile.in b/newlib/Makefile.in index 41e41412b..4ea83f09f 100644 --- a/newlib/Makefile.in +++ b/newlib/Makefile.in @@ -816,7 +816,7 @@ check_PROGRAMS =3D @HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/ferror.c libc/machine/spu/ff= lush.c libc/machine/spu/fgetc.c libc/machine/spu/fgetpos.c libc/machine/spu= /fgets.c libc/machine/spu/fileno.c libc/machine/spu/fiprintf.S \ @HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/fiscanf.S libc/machine/spu/f= open.c libc/machine/spu/fprintf.S libc/machine/spu/fputc.c libc/machine/spu= /fputs.c libc/machine/spu/fread.c libc/machine/spu/freopen.c \ @HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/fscanf.S libc/machine/spu/fs= eek.c libc/machine/spu/fsetpos.c libc/machine/spu/ftell.c libc/machine/spu/= fwrite.c libc/machine/spu/getc.c libc/machine/spu/getchar.c \ -@HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/gets.c libc/machine/spu/impu= re.c libc/machine/spu/iprintf.S libc/machine/spu/iscanf.S libc/machine/spu/= memcmp.c libc/machine/spu/memcpy.c libc/machine/spu/memmove.c \ +@HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/gets.c libc/machine/spu/ipri= ntf.S libc/machine/spu/iscanf.S libc/machine/spu/memcmp.c libc/machine/spu/= memcpy.c libc/machine/spu/memmove.c \ @HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/memset.c libc/machine/spu/pe= rror.c libc/machine/spu/printf.S libc/machine/spu/putc.c libc/machine/spu/p= utchar.c libc/machine/spu/puts.c libc/machine/spu/remove.c \ @HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/rename.c libc/machine/spu/re= wind.c libc/machine/spu/scanf.S libc/machine/spu/setbuf.c libc/machine/spu/= setvbuf.c libc/machine/spu/siprintf.S libc/machine/spu/siscanf.S \ @HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/sleep.c libc/machine/spu/sni= printf.S libc/machine/spu/snprintf.S libc/machine/spu/sprintf.S libc/machin= e/spu/sscanf.S libc/machine/spu/stdio.c libc/machine/spu/strcat.c \ @@ -2131,7 +2131,6 @@ am__objects_51 =3D libc/ssp/libc_a-chk_fail.$(OBJEXT)= \ @HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/libc_a-getc.$(OBJEXT) \ @HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/libc_a-getchar.$(OBJEXT) \ @HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/libc_a-gets.$(OBJEXT) \ -@HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/libc_a-impure.$(OBJEXT) \ @HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/libc_a-iprintf.$(OBJEXT) \ @HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/libc_a-iscanf.$(OBJEXT) \ @HAVE_LIBC_MACHINE_SPU_TRUE@ libc/machine/spu/libc_a-memcmp.$(OBJEXT) \ @@ -8812,9 +8811,6 @@ libc/machine/spu/libc_a-getchar.$(OBJEXT): \ libc/machine/spu/libc_a-gets.$(OBJEXT): \ libc/machine/spu/$(am__dirstamp) \ libc/machine/spu/$(DEPDIR)/$(am__dirstamp) -libc/machine/spu/libc_a-impure.$(OBJEXT): \ - libc/machine/spu/$(am__dirstamp) \ - libc/machine/spu/$(DEPDIR)/$(am__dirstamp) libc/machine/spu/libc_a-iprintf.$(OBJEXT): \ libc/machine/spu/$(am__dirstamp) \ libc/machine/spu/$(DEPDIR)/$(am__dirstamp) @@ -12121,7 +12117,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/spu/$(DEPDIR)/libc_a-get= c.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/spu/$(DEPDIR)/libc_a-get= char.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/spu/$(DEPDIR)/libc_a-get= s.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@libc/machine/spu/$(DEPDIR)/libc_a-imp= ure.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/spu/$(DEPDIR)/libc_a-ipr= intf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/spu/$(DEPDIR)/libc_a-isc= anf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/spu/$(DEPDIR)/libc_a-mal= loc_ea.Po@am__quote@ @@ -33451,20 +33446,6 @@ libc/machine/spu/libc_a-gets.obj: libc/machine/spu= /gets.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=3D$(DEPDIR) $(CCDEPMODE) $(depcom= p) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDE= S) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c= -o libc/machine/spu/libc_a-gets.obj `if test -f 'libc/machine/spu/gets.c';= then $(CYGPATH_W) 'libc/machine/spu/gets.c'; else $(CYGPATH_W) '$(srcdir)/= libc/machine/spu/gets.c'; fi` =20 -libc/machine/spu/libc_a-impure.o: libc/machine/spu/impure.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDE= S) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machi= ne/spu/libc_a-impure.o -MD -MP -MF libc/machine/spu/$(DEPDIR)/libc_a-impure= .Tpo -c -o libc/machine/spu/libc_a-impure.o `test -f 'libc/machine/spu/impu= re.c' || echo '$(srcdir)/'`libc/machine/spu/impure.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/machine/spu/$(DEPDIR)/libc_a= -impure.Tpo libc/machine/spu/$(DEPDIR)/libc_a-impure.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source=3D'libc/machine/spu/imp= ure.c' object=3D'libc/machine/spu/libc_a-impure.o' libtool=3Dno @AMDEPBACKS= LASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=3D$(DEPDIR) $(CCDEPMODE) $(depcom= p) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDE= S) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c= -o libc/machine/spu/libc_a-impure.o `test -f 'libc/machine/spu/impure.c' |= | echo '$(srcdir)/'`libc/machine/spu/impure.c - -libc/machine/spu/libc_a-impure.obj: libc/machine/spu/impure.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDE= S) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machi= ne/spu/libc_a-impure.obj -MD -MP -MF libc/machine/spu/$(DEPDIR)/libc_a-impu= re.Tpo -c -o libc/machine/spu/libc_a-impure.obj `if test -f 'libc/machine/s= pu/impure.c'; then $(CYGPATH_W) 'libc/machine/spu/impure.c'; else $(CYGPATH= _W) '$(srcdir)/libc/machine/spu/impure.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/machine/spu/$(DEPDIR)/libc_a= -impure.Tpo libc/machine/spu/$(DEPDIR)/libc_a-impure.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source=3D'libc/machine/spu/imp= ure.c' object=3D'libc/machine/spu/libc_a-impure.obj' libtool=3Dno @AMDEPBAC= KSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=3D$(DEPDIR) $(CCDEPMODE) $(depcom= p) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDE= S) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c= -o libc/machine/spu/libc_a-impure.obj `if test -f 'libc/machine/spu/impure= .c'; then $(CYGPATH_W) 'libc/machine/spu/impure.c'; else $(CYGPATH_W) '$(sr= cdir)/libc/machine/spu/impure.c'; fi` - libc/machine/spu/libc_a-memcmp.o: libc/machine/spu/memcmp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDE= S) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machi= ne/spu/libc_a-memcmp.o -MD -MP -MF libc/machine/spu/$(DEPDIR)/libc_a-memcmp= .Tpo -c -o libc/machine/spu/libc_a-memcmp.o `test -f 'libc/machine/spu/memc= mp.c' || echo '$(srcdir)/'`libc/machine/spu/memcmp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/machine/spu/$(DEPDIR)/libc_a= -memcmp.Tpo libc/machine/spu/$(DEPDIR)/libc_a-memcmp.Po diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reen= t.h index f8ecf8586..4bc78a447 100644 --- a/newlib/libc/include/sys/reent.h +++ b/newlib/libc/include/sys/reent.h @@ -821,7 +821,12 @@ extern __FILE __sf[3]; #endif =20 extern struct _reent *_impure_ptr __ATTRIBUTE_IMPURE_PTR__; -extern struct _reent *const _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__; + +#ifndef __ATTRIBUTE_IMPURE_DATA__ +#define __ATTRIBUTE_IMPURE_DATA__ +#endif + +extern struct _reent _impure_data __ATTRIBUTE_IMPURE_DATA__; =20 void _reclaim_reent (struct _reent *); =20 @@ -836,7 +841,7 @@ void _reclaim_reent (struct _reent *); # define _REENT _impure_ptr #endif /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */ =20 -#define _GLOBAL_REENT _global_impure_ptr +#define _GLOBAL_REENT (&_impure_data) =20 #ifdef _REENT_GLOBAL_ATEXIT extern struct _atexit *_global_atexit; /* points to head of LIFO stack */ diff --git a/newlib/libc/machine/spu/Makefile.inc b/newlib/libc/machine/spu= /Makefile.inc index bc84e9a23..5384a5f28 100644 --- a/newlib/libc/machine/spu/Makefile.inc +++ b/newlib/libc/machine/spu/Makefile.inc @@ -3,7 +3,7 @@ libc_a_SOURCES +=3D \ %D%/ferror.c %D%/fflush.c %D%/fgetc.c %D%/fgetpos.c %D%/fgets.c %D%/filen= o.c %D%/fiprintf.S \ %D%/fiscanf.S %D%/fopen.c %D%/fprintf.S %D%/fputc.c %D%/fputs.c %D%/fread= .c %D%/freopen.c \ %D%/fscanf.S %D%/fseek.c %D%/fsetpos.c %D%/ftell.c %D%/fwrite.c %D%/getc.= c %D%/getchar.c \ - %D%/gets.c %D%/impure.c %D%/iprintf.S %D%/iscanf.S %D%/memcmp.c %D%/memcp= y.c %D%/memmove.c \ + %D%/gets.c %D%/iprintf.S %D%/iscanf.S %D%/memcmp.c %D%/memcpy.c %D%/memmo= ve.c \ %D%/memset.c %D%/perror.c %D%/printf.S %D%/putc.c %D%/putchar.c %D%/puts.= c %D%/remove.c \ %D%/rename.c %D%/rewind.c %D%/scanf.S %D%/setbuf.c %D%/setvbuf.c %D%/sipr= intf.S %D%/siscanf.S \ %D%/sleep.c %D%/sniprintf.S %D%/snprintf.S %D%/sprintf.S %D%/sscanf.S %D%= /stdio.c %D%/strcat.c \ diff --git a/newlib/libc/machine/spu/impure.c b/newlib/libc/machine/spu/imp= ure.c deleted file mode 100644 index f9c86efdc..000000000 --- a/newlib/libc/machine/spu/impure.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -/* Note that there is a copy of this in sys/reent.h. */ -#ifndef __ATTRIBUTE_IMPURE_PTR__ -#define __ATTRIBUTE_IMPURE_PTR__ -#endif - -#ifndef __ATTRIBUTE_IMPURE_DATA__ -#define __ATTRIBUTE_IMPURE_DATA__ -#endif - -struct _reent __ATTRIBUTE_IMPURE_DATA__ _impure_data =3D _REENT_INIT(_impu= re_data); -struct _reent *__ATTRIBUTE_IMPURE_PTR__ _impure_ptr =3D &_impure_data; -struct _reent *const __ATTRIBUTE_IMPURE_PTR__ _global_impure_ptr =3D &_imp= ure_data; diff --git a/newlib/libc/machine/spu/sys/errno.h b/newlib/libc/machine/spu/= sys/errno.h index ef087bd68..b008ff6f4 100644 --- a/newlib/libc/machine/spu/sys/errno.h +++ b/newlib/libc/machine/spu/sys/errno.h @@ -27,7 +27,6 @@ extern "C" { =20 #include =20 -extern struct _reent _impure_data; #define errno (_impure_data._errno) =20 /* Please don't use these variables directly. diff --git a/newlib/libc/reent/impure.c b/newlib/libc/reent/impure.c index 76f67459e..f10665fd0 100644 --- a/newlib/libc/reent/impure.c +++ b/newlib/libc/reent/impure.c @@ -1,14 +1,5 @@ #include =20 -/* Note that there is a copy of this in sys/reent.h. */ -#ifndef __ATTRIBUTE_IMPURE_PTR__ -#define __ATTRIBUTE_IMPURE_PTR__ -#endif - -#ifndef __ATTRIBUTE_IMPURE_DATA__ -#define __ATTRIBUTE_IMPURE_DATA__ -#endif - /* Redeclare these symbols locally as weak so that the file containing their definitions (along with a lot of other stuff) isn't sucked in unless they are actually used by other compilation units. This is @@ -20,9 +11,8 @@ extern const struct __sFILE_fake __sf_fake_stdout _ATTRIB= UTE ((weak)); extern const struct __sFILE_fake __sf_fake_stderr _ATTRIBUTE ((weak)); #endif =20 -static struct _reent __ATTRIBUTE_IMPURE_DATA__ impure_data =3D _REENT_INIT= (impure_data); +struct _reent __ATTRIBUTE_IMPURE_DATA__ _impure_data =3D _REENT_INIT (_imp= ure_data); #ifdef __CYGWIN__ -extern struct _reent reent_data __attribute__ ((alias("impure_data"))); +extern struct _reent reent_data __attribute__ ((alias("_impure_data"))); #endif -struct _reent *__ATTRIBUTE_IMPURE_PTR__ _impure_ptr =3D &impure_data; -struct _reent *const __ATTRIBUTE_IMPURE_PTR__ _global_impure_ptr =3D &impu= re_data; +struct _reent *__ATTRIBUTE_IMPURE_PTR__ _impure_ptr =3D &_impure_data; diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 8869cbd75..5f460d8a5 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -816,7 +816,7 @@ static inline void main_thread_sinit () { __sinit (_impure_ptr); - /* At this point, _impure_ptr =3D=3D _global_impure_ptr =3D=3D _GLOBAL_R= EENT is + /* At this point, _impure_ptr =3D=3D _GLOBAL_REENT is initialized, but _REENT =3D=3D _my_tls.local_clib doesn't know about = it. It has been copied over from _GLOBAL_REENT in _cygtls::init_thread *before* the initialization took place.