Hi all, Here is the v2 version of this patch. Thanks for your patience. I believe I have fixed the issue with the extra space this time around, and have also cleaned up the patch a bit. Do note that I still do not have write access and need help pushing this when this passes review
best regards, Julian gcc/config/mingw/ChangeLog: * mingw32.h: Add new define for POSIX threads >From 76d586f595d72c22bb5cc7648f4636709411d4cd Mon Sep 17 00:00:00 2001 From: TheShermanTanker <tanksherma...@gmail.com> Date: Mon, 27 May 2024 12:57:33 +0800 Subject: [PATCH] Define which threading model is in use on Windows Signed-off-by: TheShermanTanker <tanksherma...@gmail.com> --- gcc/config/mingw/mingw32.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/config/mingw/mingw32.h b/gcc/config/mingw/mingw32.h index 08f1b5f0696..fa6e307476c 100644 --- a/gcc/config/mingw/mingw32.h +++ b/gcc/config/mingw/mingw32.h @@ -34,8 +34,12 @@ along with GCC; see the file COPYING3. If not see | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \ | MASK_MS_BITFIELD_LAYOUT) -#ifndef TARGET_USING_MCFGTHREAD -#define TARGET_USING_MCFGTHREAD 0 +#ifdef TARGET_USING_MCFGTHREAD +#define DEFINE_THREAD_MODEL builtin_define ("__USING_MCFGTHREAD__"); +#elif defined(TARGET_USE_PTHREAD_BY_DEFAULT) +#define DEFINE_THREAD_MODEL builtin_define ("__USING_POSIXTHREAD__"); +#else +#define DEFINE_THREAD_MODEL #endif /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS @@ -56,8 +60,7 @@ along with GCC; see the file COPYING3. If not see builtin_define_std ("WIN64"); \ builtin_define ("_WIN64"); \ } \ - if (TARGET_USING_MCFGTHREAD) \ - builtin_define ("__USING_MCFGTHREAD__"); \ + DEFINE_THREAD_MODEL \ } \ while (0) @@ -190,7 +193,7 @@ along with GCC; see the file COPYING3. If not see #else #define SHARED_LIBGCC_SPEC " -lgcc " #endif -#if TARGET_USING_MCFGTHREAD +#ifdef TARGET_USING_MCFGTHREAD #define MCFGTHREAD_SPEC " -lmcfgthread -lkernel32 -lntdll " #else #define MCFGTHREAD_SPEC "" -- 2.41.0 On Sun, May 26, 2024 at 5:02 PM Julian Waters <tanksherma...@gmail.com> wrote: > > Hi all, > > Please review a trivial change that defines which threading model is > used on Windows, so applications can check it. This is also useful for > system headers, since some headers should be switched off if pthread > is the threading model (Currently they are included unconditionally on > Windows). In effect this merely reworks some existing code that > defines __USING_MCFGTHREAD__ and adds some new logic to it to define > __USING_PTHREAD__ whenever appropriate. Do note that I don't have any > write access, so whoever reviews this for me has to help me push it as > well. There is a superfluous space that seems to break alignment of > backslashes in EXTRA_OS_CPP_BUILTINS added by this change, which seems > to be added by git format-patch and is not added by me. Unfortunately > I couldn't remove it, so feel free to edit my patch to remove the > space before pushing it. > > gcc/config/mingw/ChangeLog: > > * mingw32.h: Add new define for pthread. > > From 76eb8f46d815a633dc91f3c6b91c8bd9bbe3b108 Mon Sep 17 00:00:00 2001 > From: TheShermanTanker <tanksherma...@gmail.com> > Date: Sun, 26 May 2024 16:33:09 +0800 > Subject: [PATCH] Define which threading model is in use on Windows > > Signed-off-by: TheShermanTanker <tanksherma...@gmail.com> > --- > gcc/config/mingw/mingw32.h | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/gcc/config/mingw/mingw32.h b/gcc/config/mingw/mingw32.h > index 08f1b5f0696..6da57aa1b89 100644 > --- a/gcc/config/mingw/mingw32.h > +++ b/gcc/config/mingw/mingw32.h > @@ -34,8 +34,12 @@ along with GCC; see the file COPYING3. If not see > | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \ > | MASK_MS_BITFIELD_LAYOUT) > > -#ifndef TARGET_USING_MCFGTHREAD > -#define TARGET_USING_MCFGTHREAD 0 > +#ifdef TARGET_USING_MCFGTHREAD > +#define DEFINE_THREAD_MODEL builtin_define ("__USING_MCFGTHREAD__") > +#elif defined(TARGET_USE_PTHREAD_BY_DEFAULT) > +#define DEFINE_THREAD_MODEL builtin_define ("__USING_PTHREAD__") > +#else > +#define DEFINE_THREAD_MODEL ((void) 0) > #endif > > /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS > @@ -56,8 +60,7 @@ along with GCC; see the file COPYING3. If not see > builtin_define_std ("WIN64"); \ > builtin_define ("_WIN64"); \ > } \ > - if (TARGET_USING_MCFGTHREAD) \ > - builtin_define ("__USING_MCFGTHREAD__"); \ > + DEFINE_THREAD_MODEL; \ > } \ > while (0) > > @@ -190,7 +193,7 @@ along with GCC; see the file COPYING3. If not see > #else > #define SHARED_LIBGCC_SPEC " -lgcc " > #endif > -#if TARGET_USING_MCFGTHREAD > +#ifdef TARGET_USING_MCFGTHREAD > #define MCFGTHREAD_SPEC " -lmcfgthread -lkernel32 -lntdll " > #else > #define MCFGTHREAD_SPEC "" > -- > 2.41.0