[PATCH, rs6000] Allow libitm to use HTM on newer hw and kernels
Peter Bergner
bergner@linux.ibm.com
Thu Dec 13 00:55:00 GMT 2018
On 12/12/18 2:52 PM, Segher Boessenkool wrote:
>> +/* This is a fairly new feature bit, so handle it not being defined. */
>> +#ifndef PPC_FEATURE2_HTM_NO_SUSPEND
>> +# define PPC_FEATURE2_HTM_NO_SUSPEND 0
>> +#endif
>
> Doing it this way can be pretty surprising for users not aware you defined
> it to 0. Since there are no other users yet it's no big deal.
Would you instead prefer something along the lines of the following?
Peter
static inline bool
htm_available (void)
{
- return (getauxval (AT_HWCAP2) & PPC_FEATURE2_HAS_HTM) ? true : false;
+#ifdef __BUILTIN_CPU_SUPPORTS__
+ if (__builtin_cpu_supports ("htm-no-suspend")
+ || __builtin_cpu_supports ("htm"))
+ return true;
+#else
+#ifdef PPC_FEATURE2_HTM_NO_SUSPEND
+ unsigned long htm_flags = PPC_FEATURE2_HAS_HTM | PPC_FEATURE2_HTM_NO_SUSPEND;
+#else
+ unsigned long htm_flags = PPC_FEATURE2_HAS_HTM;
+#endif
+ if (getauxval (AT_HWCAP2) & htm_flags)
+ return true;
+#endif
+ return false;
}
More information about the Gcc-patches
mailing list