patch-ext_standard_crc32_c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. --- php-7.4.25.orig/ext/standard/crc32.c 2021-10-19 17:18:19.000000000 +0200
  2. +++ php-7.4.25/ext/standard/crc32.c 2021-10-29 14:58:12.777563842 +0200
  3. @@ -20,56 +20,6 @@
  4. #include "basic_functions.h"
  5. #include "crc32.h"
  6. -#if HAVE_AARCH64_CRC32
  7. -# include <arm_acle.h>
  8. -# if defined(__linux__)
  9. -# include <sys/auxv.h>
  10. -# include <asm/hwcap.h>
  11. -# endif
  12. -
  13. -static inline int has_crc32_insn() {
  14. - /* Only go through the runtime detection once. */
  15. - static int res = -1;
  16. - if (res != -1)
  17. - return res;
  18. -# if defined(HWCAP_CRC32)
  19. - res = getauxval(AT_HWCAP) & HWCAP_CRC32;
  20. - return res;
  21. -# elif defined(HWCAP2_CRC32)
  22. - res = getauxval(AT_HWCAP2) & HWCAP2_CRC32;
  23. - return res;
  24. -# else
  25. - res = 0;
  26. - return res;
  27. -# endif
  28. -}
  29. -
  30. -# pragma GCC push_options
  31. -# pragma GCC target ("+nothing+crc")
  32. -static uint32_t crc32_aarch64(uint32_t crc, char *p, size_t nr) {
  33. - while (nr >= sizeof(uint64_t)) {
  34. - crc = __crc32d(crc, *(uint64_t *)p);
  35. - p += sizeof(uint64_t);
  36. - nr -= sizeof(uint64_t);
  37. - }
  38. - if (nr >= sizeof(int32_t)) {
  39. - crc = __crc32w(crc, *(uint32_t *)p);
  40. - p += sizeof(uint32_t);
  41. - nr -= sizeof(uint32_t);
  42. - }
  43. - if (nr >= sizeof(int16_t)) {
  44. - crc = __crc32h(crc, *(uint16_t *)p);
  45. - p += sizeof(uint16_t);
  46. - nr -= sizeof(uint16_t);
  47. - }
  48. - if (nr) {
  49. - crc = __crc32b(crc, *p);
  50. - }
  51. - return crc;
  52. -}
  53. -# pragma GCC pop_options
  54. -#endif
  55. -
  56. /* {{{ proto string crc32(string str)
  57. Calculate the crc32 polynomial of a string */
  58. PHP_NAMED_FUNCTION(php_if_crc32)
  59. @@ -85,13 +35,6 @@ PHP_NAMED_FUNCTION(php_if_crc32)
  60. crc = crcinit^0xFFFFFFFF;
  61. -#if HAVE_AARCH64_CRC32
  62. - if (has_crc32_insn()) {
  63. - crc = crc32_aarch64(crc, p, nr);
  64. - RETURN_LONG(crc^0xFFFFFFFF);
  65. - }
  66. -#endif
  67. -
  68. for (; nr--; ++p) {
  69. crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32tab[(crc ^ (*p)) & 0xFF ];
  70. }