You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
3.0 KiB

  1. From f5cf70d9d1dc7f4cbeffb7fb75cbbe08720e3873 Mon Sep 17 00:00:00 2001
  2. From: Gustavo Romero <gromero@br.ibm.com>
  3. Date: Sun, 26 Mar 2017 15:08:15 +0000
  4. Subject: [PATCH] Remove dependency on glibc on PPC
  5. Remove dependency on glibc by using gcc builtin function and no glibc
  6. wrappers.
  7. Currently there are no surrogates in musl for:
  8. __ppc_get_timebase()
  9. __ppc_set_ppr_low()
  10. __ppc_set_ppr_med()
  11. however glibc __ppc_get_timebase() is just a wrapper for GCC builtin
  12. __builtin_get_timebase() available since GCC 4.8 [1], so assuming that
  13. aports on ppc64le will never be built using GCC < 4.8 we can just
  14. switch directly to the GCC builtin function.
  15. Also __ppc_set_ppr_{low,med}() are not available on musl but both
  16. are simple glibc wrappers on a single asm instruction, hence there
  17. is no harm in using asm directly instead. Actually, using asm
  18. directly was the first solution adopted in MariaDB [2].
  19. [1] https://goo.gl/jxLV6O
  20. [2] https://goo.gl/9bjuVC
  21. --- a/storage/xtradb/include/ut0ut.h
  22. +++ b/storage/xtradb/include/ut0ut.h
  23. @@ -85,9 +85,8 @@ private:
  24. the YieldProcessor macro defined in WinNT.h. It is a CPU architecture-
  25. independent way by using YieldProcessor. */
  26. # define UT_RELAX_CPU() YieldProcessor()
  27. -# elif defined(__powerpc__) && defined __GLIBC__
  28. -#include <sys/platform/ppc.h>
  29. -# define UT_RELAX_CPU() __ppc_get_timebase()
  30. +# elif defined(__powerpc__)
  31. +# define UT_RELAX_CPU() __builtin_ppc_get_timebase()
  32. # else
  33. # define UT_RELAX_CPU() ((void)0) /* avoid warning for an empty statement */
  34. # endif
  35. @@ -101,9 +100,8 @@ private:
  36. #endif
  37. # if defined(HAVE_HMT_PRIORITY_INSTRUCTION)
  38. -#include <sys/platform/ppc.h>
  39. -# define UT_LOW_PRIORITY_CPU() __ppc_set_ppr_low()
  40. -# define UT_RESUME_PRIORITY_CPU() __ppc_set_ppr_med()
  41. +# define UT_LOW_PRIORITY_CPU() __asm__ __volatile__ ("or 1,1,1")
  42. +# define UT_RESUME_PRIORITY_CPU() __asm__ __volatile__ ("or 2,2,2")
  43. # else
  44. # define UT_LOW_PRIORITY_CPU() ((void)0)
  45. # define UT_RESUME_PRIORITY_CPU() ((void)0)
  46. --- a/storage/innobase/include/ut0ut.h
  47. +++ b/storage/innobase/include/ut0ut.h
  48. @@ -70,9 +70,8 @@ typedef time_t ib_time_t;
  49. the YieldProcessor macro defined in WinNT.h. It is a CPU architecture-
  50. independent way by using YieldProcessor. */
  51. # define UT_RELAX_CPU() YieldProcessor()
  52. -#elif defined(__powerpc__) && defined __GLIBC__
  53. -# include <sys/platform/ppc.h>
  54. -# define UT_RELAX_CPU() __ppc_get_timebase()
  55. +#elif defined(__powerpc__)
  56. +# define UT_RELAX_CPU() __builtin_ppc_get_timebase()
  57. #else
  58. # define UT_RELAX_CPU() do { \
  59. volatile int32 volatile_var; \
  60. @@ -90,9 +89,8 @@ typedef time_t ib_time_t;
  61. #endif
  62. #if defined(HAVE_HMT_PRIORITY_INSTRUCTION)
  63. -# include <sys/platform/ppc.h>
  64. -# define UT_LOW_PRIORITY_CPU() __ppc_set_ppr_low()
  65. -# define UT_RESUME_PRIORITY_CPU() __ppc_set_ppr_med()
  66. +# define UT_LOW_PRIORITY_CPU() __asm__ __volatile__ ("or 1,1,1")
  67. +# define UT_RESUME_PRIORITY_CPU() __asm__ __volatile__ ("or 2,2,2")
  68. #else
  69. # define UT_LOW_PRIORITY_CPU() ((void)0)
  70. # define UT_RESUME_PRIORITY_CPU() ((void)0)