crc32_x86.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | https://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Author: Frank Du <frank.du@intel.com> |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifndef _CRC32_X86_HEADER_H_
  17. #define _CRC32_X86_HEADER_H_
  18. #include "php.h"
  19. typedef enum {
  20. /* polynomial: 0x04C11DB7, used by bzip */
  21. X86_CRC32 = 0,
  22. /*
  23. polynomial: 0x04C11DB7 with reversed ordering,
  24. used by ethernet (IEEE 802.3), gzip, zip, png, etc
  25. */
  26. X86_CRC32B,
  27. /*
  28. polynomial: 0x1EDC6F41 with reversed ordering,
  29. used by iSCSI, SCTP, Btrfs, ext4, etc
  30. */
  31. X86_CRC32C,
  32. X86_CRC32_MAX,
  33. } X86_CRC32_TYPE;
  34. #if ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PTR
  35. PHP_MINIT_FUNCTION(crc32_x86_intrin);
  36. #endif
  37. #if ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE || ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER
  38. /* Return the size processed by SIMD routine */
  39. size_t crc32_x86_simd_update(X86_CRC32_TYPE type, uint32_t *crc, const unsigned char *p, size_t nr);
  40. #else
  41. static inline size_t crc32_x86_simd_update(X86_CRC32_TYPE type, uint32_t *crc, const unsigned char *p, size_t nr)
  42. {
  43. return 0;
  44. }
  45. #endif
  46. #endif