tests
3 years ago
config.m4
3 years ago
hash_crc32c.c
3 years ago
install_crc32c.sh
3 years ago
php_crc32c.c
3 years ago
php_crc32c.h
3 years ago
php_crc32c.h
54 lines
| 1 | /** |
| 2 | * Copyright 2019 Google Inc. All Rights Reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /** |
| 18 | * crc32c extension for PHP |
| 19 | */ |
| 20 | #ifndef PHP_CRC32C_H |
| 21 | # define PHP_CRC32C_H |
| 22 | |
| 23 | #ifdef HAVE_CONFIG_H |
| 24 | # include "config.h" |
| 25 | #endif |
| 26 | |
| 27 | #include "php.h" |
| 28 | |
| 29 | #include <stdint.h> |
| 30 | #include <stdbool.h> |
| 31 | |
| 32 | #ifdef ZTS |
| 33 | # include "TSRM.h" |
| 34 | #endif |
| 35 | |
| 36 | extern zend_module_entry crc32c_module_entry; |
| 37 | |
| 38 | # define PHP_CRC32C_VERSION "1.0.0" |
| 39 | |
| 40 | # if PHP_VERSION_ID >= 70000 |
| 41 | # if defined(ZTS) && defined(COMPILE_DL_CRC32C) |
| 42 | ZEND_TSRMLS_CACHE_EXTERN() |
| 43 | # endif |
| 44 | # endif |
| 45 | |
| 46 | static void int2byte(uint32_t i, uint8_t b[4]) { |
| 47 | b[0] = (uint8_t) ((i >> 24) & 0xff); |
| 48 | b[1] = (uint8_t) ((i >> 16) & 0xff); |
| 49 | b[2] = (uint8_t) ((i >> 8) & 0xff); |
| 50 | b[3] = (uint8_t) (i & 0xff); |
| 51 | } |
| 52 | |
| 53 | #endif /* PHP_CRC32C_H */ |
| 54 |