mirror of
https://github.com/awslabs/aws-crt-php.git
synced 2026-08-18 01:57:13 +00:00
Crc32 (#31)
* broken * crc tests * ffi changes * large buffer test * ffi cmake fix * formatting * laws-checksums config.m4 * broken * crc tests * ffi changes * large buffer test * ffi cmake fix * formatting * laws-checksums config.m4 * Fixed aws-crt-ffi after rebase of main * Regenerated awscrt_arginfo.h * merge fix * Fixed arginfo * try forcing memory limit higher * mem_limit set * newline Co-authored-by: Itamar Levy-Or <[email protected]>
This commit is contained in:
co-authored by
Itamar Levy-Or
parent
078df4825c
commit
ebfb91f562
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
|
||||
#include "php_aws_crt.h"
|
||||
|
||||
PHP_FUNCTION(aws_crt_crc32) {
|
||||
zend_ulong prev = 0;
|
||||
const char *input = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
aws_php_parse_parameters("sl", &input, &len, &prev);
|
||||
|
||||
if (prev > UINT32_MAX) {
|
||||
aws_php_throw_exception("previous crc cannot be larger than UINT32_MAX");
|
||||
}
|
||||
RETURN_LONG((zend_ulong)aws_crt_crc32((const uint8_t *)input, len, prev));
|
||||
}
|
||||
|
||||
PHP_FUNCTION(aws_crt_crc32c) {
|
||||
zend_ulong prev = 0;
|
||||
const char *input = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
aws_php_parse_parameters("sl", &input, &len, &prev);
|
||||
|
||||
if (prev > UINT32_MAX) {
|
||||
aws_php_throw_exception("previous crc cannot be larger than UINT32_MAX");
|
||||
}
|
||||
RETURN_LONG((zend_ulong)aws_crt_crc32c((const uint8_t *)input, len, prev));
|
||||
}
|
||||
Reference in New Issue
Block a user