From 522d7f6ee4c10a71640863a91d3397c587e6e836 Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Thu, 4 Jul 2024 19:19:21 +0200 Subject: [PATCH] Berry `int64` added `low32()` and `high32()` methods, used in Matter (#21728) --- CHANGELOG.md | 1 + lib/libesp32/berry_int64/src/be_int64_class.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2c44a4f2..8e68ae57a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. - Support for Sonoff POWCT Ring (#21131) - NeoPool data validation and communication statistics default enabled for ESP32 only (#21721) - `FUNC_BUTTON_PRESSED` now contains `press_counter` encoded in `XdrvMailbox.command_code` (#21724) +- Berry `int64` added `low32()` and `high32()` methods, used in Matter ### Breaking Changed diff --git a/lib/libesp32/berry_int64/src/be_int64_class.c b/lib/libesp32/berry_int64/src/be_int64_class.c index 48dfc923a..16f8dbbba 100644 --- a/lib/libesp32/berry_int64/src/be_int64_class.c +++ b/lib/libesp32/berry_int64/src/be_int64_class.c @@ -212,6 +212,16 @@ int64_t* int64_frombytes(bvm *vm, uint8_t* ptr, size_t len, int32_t idx) { } BE_FUNC_CTYPE_DECLARE(int64_frombytes, "int64", "@(bytes)~[i]") +int32_t int64_low32(int64_t *i64) { + return (int32_t) *i64; +} +BE_FUNC_CTYPE_DECLARE(int64_low32, "i", "(int64)") + +int32_t int64_high32(int64_t *i64) { + return (int32_t) (*i64 >> 32); +} +BE_FUNC_CTYPE_DECLARE(int64_high32, "i", "(int64)") + /* def toint64(i) @@ -305,5 +315,8 @@ class be_class_int64 (scope: global, name: int64) { tobytes, ctype_func(int64_tobytes) frombytes, static_ctype_func(int64_frombytes) + + low32, ctype_func(int64_low32) // return low 32 bits as int + high32, ctype_func(int64_high32) // return high 32 bits as int } @const_object_info_end */