public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] mingw-w64: avoid undefining _REENTRANT
@ 2023-09-30 12:33 Stephen Kitt
  0 siblings, 0 replies; only message in thread
From: Stephen Kitt @ 2023-09-30 12:33 UTC (permalink / raw)
  To: gcc-patches; +Cc: Stephen Kitt

When pthread is used by default, _REENTRANT should be defined in all
cases except -no-pthread. When pthread is not used by default,
_REENTRANT should only be defined with -pthread.

The current spec for mingw-w64 for default pthread is

    %{!no-pthread:-D_REENTRANT} %{pthread:-U_REENTRANT}

and for non-default pthread is

    %{pthread:-D_REENTRANT} %{!no-pthread:-U_REENTRANT}

This means that when pthread is used by default, specifying -pthread
undefines _REENTRANT! Applying the mingw32 specs instead produces the
desired result,

    %{!no-pthread:-D_REENTRANT} %{pthread: }

for default pthread, and

    %{pthread:-D_REENTRANT} %{!no-pthread: }

for non-default pthread.

gcc/ChangeLog:

        * config/i386/mingw-w64.h (CPP_SPEC): Never undefine
          _REENTRANT, only define it when appropriate.

Signed-off-by: Stephen Kitt <steve@sk2.org>
---
 gcc/config/i386/mingw-w64.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h
index 0146ed4f793..39e7ec2ea1e 100644
--- a/gcc/config/i386/mingw-w64.h
+++ b/gcc/config/i386/mingw-w64.h
@@ -25,7 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \
 		 "%{municode:-DUNICODE} " \
 		 "%{" SPEC_PTHREAD1 ":-D_REENTRANT} " \
-		 "%{" SPEC_PTHREAD2 ":-U_REENTRANT} " \
+		 "%{" SPEC_PTHREAD2 ": } " \
 		 "%{mcrtdll=crtdll*:-U__MSVCRT__ -D__CRTDLL__} " \
 		 "%{mcrtdll=msvcrt10*:-D__MSVCRT_VERSION__=0x100} " \
 		 "%{mcrtdll=msvcrt20*:-D__MSVCRT_VERSION__=0x200} " \

base-commit: 1e6815071fd137424f79ca79a6ba66b776a98778
-- 
2.30.2


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-30 12:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-30 12:33 [PATCH] mingw-w64: avoid undefining _REENTRANT Stephen Kitt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).