From 55e3fec3bc1b34a778475ddcfac6a014ff295284 Mon Sep 17 00:00:00 2001 From: Nik Date: Tue, 14 Mar 2023 14:40:58 +0100 Subject: [PATCH] includes/std: Added std::math::accumulate, corrected std::hash::crc32 --- includes/std/hash.pat | 4 ++-- includes/std/math.pat | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/includes/std/hash.pat b/includes/std/hash.pat index a3b6ad3..ea0a1e8 100644 --- a/includes/std/hash.pat +++ b/includes/std/hash.pat @@ -2,8 +2,8 @@ namespace std::hash { - fn crc32(ref auto pattern, u32 init, u32 poly) { - return builtin::std::hash::crc32(pattern, init, poly); + fn crc32(ref auto pattern, u32 init, u32 poly, u32 xorout, bool reflect_in, bool reflect_out) { + return builtin::std::hash::crc32(pattern, init, poly, xorout, reflect_in, reflect_out); }; } \ No newline at end of file diff --git a/includes/std/math.pat b/includes/std/math.pat index 9cbf5e0..6922404 100644 --- a/includes/std/math.pat +++ b/includes/std/math.pat @@ -1,5 +1,7 @@ #pragma once +#include + namespace std::math { fn min(auto a, auto b) { @@ -105,5 +107,17 @@ namespace std::math { fn asinh(auto value) { return builtin::std::math::asinh(value); }; fn acosh(auto value) { return builtin::std::math::acosh(value); }; fn atanh(auto value) { return builtin::std::math::atanh(value); }; + + enum AccumulateOperation : u8 { + Add = 0, + Multiply = 1, + Modulo = 2, + Min = 3, + Max = 4 + }; + + fn accumulate(u128 start, u128 end, u128 valueSize, std::mem::Section section = 0, AccumulateOperation operation = AccumulateOperation::Add, std::mem::Endian endian = std::mem::Endian::Native) { + return builtin::std::math::accumulate(start, end, valueSize, section, u128(operation), u128(endian)); + }; }