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.

75 lines
2.7 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. @@ -86,8 +86,7 @@ private:
  24. independent way by using YieldProcessor. */
  25. # define UT_RELAX_CPU() YieldProcessor()
  26. # elif defined(__powerpc__)
  27. -#include <sys/platform/ppc.h>
  28. -# define UT_RELAX_CPU() __ppc_get_timebase()
  29. +# define UT_RELAX_CPU() __builtin_ppc_get_timebase()
  30. # else
  31. # define UT_RELAX_CPU() ((void)0) /* avoid warning for an empty statement */
  32. # endif
  33. @@ -101,9 +100,8 @@ private:
  34. #endif
  35. # if defined(HAVE_HMT_PRIORITY_INSTRUCTION)
  36. -#include <sys/platform/ppc.h>
  37. -# define UT_LOW_PRIORITY_CPU() __ppc_set_ppr_low()
  38. -# define UT_RESUME_PRIORITY_CPU() __ppc_set_ppr_med()
  39. +# define UT_LOW_PRIORITY_CPU() __asm__ __volatile__ ("or 1,1,1")
  40. +# define UT_RESUME_PRIORITY_CPU() __asm__ __volatile__ ("or 2,2,2")
  41. # else
  42. # define UT_LOW_PRIORITY_CPU() ((void)0)
  43. # define UT_RESUME_PRIORITY_CPU() ((void)0)
  44. --- a/storage/innobase/include/ut0ut.h
  45. +++ b/storage/innobase/include/ut0ut.h
  46. @@ -89,8 +89,7 @@ private:
  47. independent way by using YieldProcessor. */
  48. # define UT_RELAX_CPU() YieldProcessor()
  49. # elif defined(__powerpc__)
  50. -#include <sys/platform/ppc.h>
  51. -# define UT_RELAX_CPU() __ppc_get_timebase()
  52. +# define UT_RELAX_CPU() __builtin_ppc_get_timebase()
  53. # else
  54. # define UT_RELAX_CPU() ((void)0) /* avoid warning for an empty statement */
  55. # endif
  56. @@ -104,9 +103,8 @@ private:
  57. #endif
  58. # if defined(HAVE_HMT_PRIORITY_INSTRUCTION)
  59. -#include <sys/platform/ppc.h>
  60. -# define UT_LOW_PRIORITY_CPU() __ppc_set_ppr_low()
  61. -# define UT_RESUME_PRIORITY_CPU() __ppc_set_ppr_med()
  62. +# define UT_LOW_PRIORITY_CPU() __asm__ __volatile__ ("or 1,1,1")
  63. +# define UT_RESUME_PRIORITY_CPU() __asm__ __volatile__ ("or 2,2,2")
  64. # else
  65. # define UT_LOW_PRIORITY_CPU() ((void)0)
  66. # define UT_RESUME_PRIORITY_CPU() ((void)0)