public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Stephen Kitt <steve@sk2.org>
To: gcc-patches@gcc.gnu.org
Cc: Stephen Kitt <steve@sk2.org>
Subject: [PATCH] mingw-w64: avoid undefining _REENTRANT
Date: Sat, 30 Sep 2023 14:33:53 +0200	[thread overview]
Message-ID: <20230930123353.2575906-1-steve@sk2.org> (raw)

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


                 reply	other threads:[~2023-09-30 12:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230930123353.2575906-1-steve@sk2.org \
    --to=steve@sk2.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).