Skip to content

Commit b63a664

Browse files
committed
Merge pull request #1552 from bettio/biggerint
Add bigint (256 bit + sign) initial scaffolding This PR introduces support to signed 256 bit integers. Briefly: - Add code for generic big integer handling (`intn.c`), limited to 256 bit for the sake of simplicity, but it might be expanded to generic big integers with some additional work - Refactored arithmetic BIF helpers - Refactored `integer_to_binary`/`_to_list` in order to reduce both code duplication and make it simpler adding big integers support - Reimplemented `binary_to_integer` in to make it compliant with OTP (binaries such as `<<"0xCAFE">>` or `<<" 42">>` must be rejected). - Replaced `lltoa` with more performant functions that do not rely on slow helpers, specially for base 10 and 16 - Added bigint support to '*' operator - Boxed integers can be either positive and negative; also added predicates for checking signed type - Added support for big literals - Added support for big integers to `binary_to_term` and `term_to_binary` These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 75d6d2d + 2582014 commit b63a664

26 files changed

+3440
-494
lines changed

.github/workflows/build-and-test.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ jobs:
380380
working-directory: build
381381
run: |
382382
ulimit -c unlimited
383-
valgrind --error-exitcode=1 ./tests/test-erlang -s prime_smp
383+
valgrind --suppressions=../tests/valgrind-suppressions.sup --error-exitcode=1 ./tests/test-erlang -s prime_smp
384384
./tests/test-erlang -s prime_smp
385385
386386
- name: "Test: test-enif"
@@ -418,30 +418,30 @@ jobs:
418418
run: |
419419
ulimit -c unlimited
420420
./src/AtomVM ./tests/libs/etest/test_etest.avm
421-
valgrind ./src/AtomVM ./tests/libs/etest/test_etest.avm
421+
valgrind --suppressions=../tests/valgrind-suppressions.sup ./src/AtomVM ./tests/libs/etest/test_etest.avm
422422
423423
- name: "Test: test_estdlib.avm"
424424
timeout-minutes: 5
425425
working-directory: build
426426
run: |
427427
ulimit -c unlimited
428-
valgrind --error-exitcode=1 ./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm
428+
valgrind --suppressions=../tests/valgrind-suppressions.sup --error-exitcode=1 ./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm
429429
./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm
430430
431431
- name: "Test: test_eavmlib.avm"
432432
timeout-minutes: 10
433433
working-directory: build
434434
run: |
435435
ulimit -c unlimited
436-
valgrind --error-exitcode=1 ./src/AtomVM ./tests/libs/eavmlib/test_eavmlib.avm
436+
valgrind --suppressions=../tests/valgrind-suppressions.sup --error-exitcode=1 ./src/AtomVM ./tests/libs/eavmlib/test_eavmlib.avm
437437
./src/AtomVM ./tests/libs/eavmlib/test_eavmlib.avm
438438
439439
- name: "Test: test_alisp.avm"
440440
timeout-minutes: 10
441441
working-directory: build
442442
run: |
443443
ulimit -c unlimited
444-
valgrind --error-exitcode=1 ./src/AtomVM ./tests/libs/alisp/test_alisp.avm
444+
valgrind --suppressions=../tests/valgrind-suppressions.sup --error-exitcode=1 ./src/AtomVM ./tests/libs/alisp/test_alisp.avm
445445
./src/AtomVM ./tests/libs/alisp/test_alisp.avm
446446
447447
- name: "Test: Tests.avm (Elixir)"
@@ -451,7 +451,7 @@ jobs:
451451
ulimit -c unlimited
452452
if command -v elixirc >/dev/null 2>&1 && command -v elixir >/dev/null 2>&1
453453
then
454-
valgrind --error-exitcode=1 ./src/AtomVM ./tests/libs/exavmlib/Tests.avm
454+
valgrind --suppressions=../tests/valgrind-suppressions.sup --error-exitcode=1 ./src/AtomVM ./tests/libs/exavmlib/Tests.avm
455455
./src/AtomVM ./tests/libs/exavmlib/Tests.avm
456456
else
457457
echo "Elixir not installed, skipping Elixir tests"

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
- Added `erlang:unique_integer/0` and `erlang:unique_integer/1`
3030
- Added support for 'ets:delete/1'.
3131

32+
### Changed
33+
- `binary_to_integer/1` no longer accepts binaries such as `<<"0xFF">>` or `<<" 123">>`
34+
3235
### Fixed
3336
- ESP32: improved sntp sync speed from a cold boot.
3437
- Utilize reserved `phy_init` partition on ESP32 to store wifi calibration for faster connections.

src/libAtomVM/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ set(HEADER_FILES
4242
globalcontext.h
4343
iff.h
4444
interop.h
45+
intn.h
4546
list.h
4647
listeners.h
4748
mailbox.h
@@ -89,6 +90,7 @@ set(SOURCE_FILES
8990
globalcontext.c
9091
iff.c
9192
interop.c
93+
intn.c
9294
mailbox.c
9395
memory.c
9496
module.c
@@ -102,6 +104,7 @@ set(SOURCE_FILES
102104
term.c
103105
timer_list.c
104106
unicode.c
107+
utils.c
105108
valueshashtable.c
106109
)
107110

0 commit comments

Comments
 (0)