mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-34825: my_cpu.h - non-glibc ism for POWER
Taking both the FreeBSD[1] and Alpine[1] patch concepts;
provide non-GLIBC definations for HMT_*.
Provide FreeBSD ASM base for __ppc_get_timebase.
On alternately use __builtin_ppc_get_timebase which is described
on https://gcc.gnu.org/onlinedocs/gcc/Basic-PowerPC-Built-in-Functions-Available-on-all-Configurations.html
an not depended on glibc/musl.
[1] 15d22e1c70/databases/mariadb106-server/files/patch-include_my__cpu.h
[2] https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/mariadb/ppc-remove-glibc-dep.patch
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#ifdef _ARCH_PWR8
|
||||
#ifdef __GLIBC__
|
||||
#include <sys/platform/ppc.h>
|
||||
/* Very low priority */
|
||||
#define HMT_very_low() __ppc_set_ppr_very_low()
|
||||
@@ -37,6 +38,18 @@
|
||||
#define HMT_medium_high() __ppc_set_ppr_med_high()
|
||||
/* High priority */
|
||||
#define HMT_high() asm volatile("or 3,3,3")
|
||||
#else /* GLIBC */
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#define HMT_very_low() __asm__ volatile ("or 31,31,31")
|
||||
#define HMT_low() __asm__ volatile ("or 1,1,1")
|
||||
#define HMT_medium_low() __asm__ volatile ("or 6,6,6")
|
||||
#define HMT_medium() __asm__ volatile ("or 2,2,2")
|
||||
#define HMT_medium_high() __asm__ volatile ("or 5,5,5")
|
||||
#define HMT_high() asm volatile("or 3,3,3")
|
||||
#endif /* GLIBC */
|
||||
#else
|
||||
#define HMT_very_low()
|
||||
#define HMT_low()
|
||||
@@ -81,7 +94,13 @@ static inline void MY_RELAX_CPU(void)
|
||||
__asm__ __volatile__ ("pause");
|
||||
#endif
|
||||
#elif defined(_ARCH_PWR8)
|
||||
__ppc_get_timebase();
|
||||
#ifdef __FreeBSD__
|
||||
uint64_t __tb;
|
||||
__asm__ volatile ("mfspr %0, 268" : "=r" (__tb));
|
||||
#else
|
||||
/* Changed from __ppc_get_timebase for musl compatibility */
|
||||
__builtin_ppc_get_timebase();
|
||||
#endif
|
||||
#elif defined __GNUC__ && (defined __arm__ || defined __aarch64__)
|
||||
/* Mainly, prevent the compiler from optimizing away delay loops */
|
||||
#ifdef _aarch64_
|
||||
|
Reference in New Issue
Block a user