Thanks Kai,

We probably don't need to push and pop because this is not a header to be
installed

Updated diff

diff --git a/mingw-w64-crt/intrincs/rdtsc.c b/mingw-w64-crt/intrincs/rdtsc.c
index fd9cb75d..bf9c03b3 100644
--- a/mingw-w64-crt/intrincs/rdtsc.c
+++ b/mingw-w64-crt/intrincs/rdtsc.c
@@ -4,11 +4,14 @@
  * No warranty is given; refer to the file DISCLAIMER.PD within this
package.
  */
-#ifdef __clang__
-#define __IA32INTRIN_H
-#endif
 #include <intrin.h>
+/* Clang has support for MSVC builtins, GCC doesn't */
+#ifndef __has_builtin
+  #define __has_builtin(x) 0
+#endif
+
+#if !__has_builtin(__rdtsc)
 unsigned __int64 __rdtsc(void)
 {
 #ifdef _WIN64
@@ -21,4 +24,4 @@ unsigned __int64 __rdtsc(void)
           : "=a" (val1), "=d" (val2));
       return ((unsigned __int64)val1) | (((unsigned __int64)val2) << 32);
 }
-
+#endif

On Thu, May 11, 2017 at 1:15 PM, Kai Tietz <[email protected]> wrote:

> Hmm, where is the corresponding pop_macro pragma?
>
> Regards,
> Kai
>
> 2017-05-11 14:09 GMT+02:00 Martell Malone <[email protected]>:
> >>
> >> While it's not "good form" to have the prototype
> >> in multiple places...
> >
> > Attached updated diff
> >
> > Please Review
> >
> > diff --git a/mingw-w64-crt/intrincs/rdtsc.c b/mingw-w64-crt/intrincs/
> rdtsc.c
> > index fd9cb75d..7c5adeb0 100644
> > --- a/mingw-w64-crt/intrincs/rdtsc.c
> > +++ b/mingw-w64-crt/intrincs/rdtsc.c
> > @@ -4,11 +4,15 @@
> >   * No warranty is given; refer to the file DISCLAIMER.PD within this
> > package.
> >   */
> > -#ifdef __clang__
> > -#define __IA32INTRIN_H
> > -#endif
> >  #include <intrin.h>
> > +/* Clang has support for MSVC builtins, GCC doesn't */
> > +#pragma push_macro("__has_builtin")
> > +#ifndef __has_builtin
> > +  #define __has_builtin(x) 0
> > +#endif
> > +
> > +#if !__has_builtin(__rdtsc)
> >  unsigned __int64 __rdtsc(void)
> >  {
> >  #ifdef _WIN64
> > @@ -21,4 +25,4 @@ unsigned __int64 __rdtsc(void)
> >            : "=a" (val1), "=d" (val2));
> >        return ((unsigned __int64)val1) | (((unsigned __int64)val2) <<
> 32);
> >  }
> > -
> > +#endif
> >
> > On Sun, Apr 16, 2017 at 3:06 AM, David Wohlferd <[email protected]>
> > wrote:
> >
> >> On 4/14/2017 7:14 AM, Martell Malone wrote:
> >> > Updated clang no longer defines __IA32INTRIN_H so lets do this
> properly.
> >>
> >> It appears that the only use for <intrin.h> in that file is the
> >> prototype for __rdtsc.  While it's not "good form" to have the prototype
> >> in multiple places...
> >>
> >> > I assume intrin-impl.h is only ever included by intrin.h?
> >>
> >> Fraid not.
> >>
> >> mingw-w64-headers\include\winbase.h:#include <psdk_inc/intrin-impl.h>
> >> mingw-w64-headers\include\winnt.h:#include <psdk_inc/intrin-impl.h>
> >>
> >> > If not I will have to find a way to deal with __has_builtin in both
> files
> >>
> >>
> >> ------------------------------------------------------------
> >> ------------------
> >> Check out the vibrant tech community on one of the world's most
> >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >> _______________________________________________
> >> Mingw-w64-public mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
> >>
> > ------------------------------------------------------------
> ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Mingw-w64-public mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Mingw-w64-public mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to