xref: /PHP-8.2/ext/standard/crc32_x86.h (revision c3299d7d)
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 
17 #ifndef _CRC32_X86_HEADER_H_
18 #define _CRC32_X86_HEADER_H_
19 
20 #include "php.h"
21 
22 typedef enum {
23 	/* polynomial: 0x04C11DB7, used by bzip */
24 	X86_CRC32 = 0,
25 	/*
26 	 polynomial: 0x04C11DB7 with reversed ordering,
27 	 used by ethernet (IEEE 802.3), gzip, zip, png, etc
28 	*/
29 	X86_CRC32B,
30 	/*
31 	 polynomial: 0x1EDC6F41 with reversed ordering,
32 	 used by iSCSI, SCTP, Btrfs, ext4, etc
33 	*/
34 	X86_CRC32C,
35 	X86_CRC32_MAX,
36 } X86_CRC32_TYPE;
37 
38 #if ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PTR
39 PHP_MINIT_FUNCTION(crc32_x86_intrin);
40 #endif
41 
42 #if ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE || ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER
43 /* Return the size processed by SIMD routine */
44 size_t crc32_x86_simd_update(X86_CRC32_TYPE type, uint32_t *crc, const unsigned char *p, size_t nr);
45 #else
crc32_x86_simd_update(X86_CRC32_TYPE type,uint32_t * crc,const unsigned char * p,size_t nr)46 static inline size_t crc32_x86_simd_update(X86_CRC32_TYPE type, uint32_t *crc, const unsigned char *p, size_t nr)
47 {
48 	return 0;
49 }
50 #endif
51 
52 #endif
53