├── libs ├── eavmlib │ ├── rebar.lock │ └── rebar.lock.license ├── exavmlib │ ├── mix.lock.license │ ├── .gitignore │ ├── .formatter.exs │ ├── lib │ │ ├── List.Chars.Integer.ex │ │ ├── List.Chars.Atom.ex │ │ ├── List.Chars.List.ex │ │ ├── String.Chars.List.ex │ │ ├── RuntimeError.ex │ │ ├── ArgumentError.ex │ │ ├── String.Chars.Integer.ex │ │ ├── ArithmeticError.ex │ │ ├── String.Chars.Atom.ex │ │ ├── Collectable.Map.ex │ │ ├── List.Chars.Float.ex │ │ ├── SystemLimitError.ex │ │ ├── Collectable.List.ex │ │ ├── CondClauseError.ex │ │ └── Module.ex │ └── mix.lock ├── alisp │ └── src │ │ └── rebar.config ├── estdlib │ └── src │ │ ├── inet-priv.hrl │ │ └── file.erl ├── gleam_avm │ ├── manifest.toml │ ├── gleam.toml │ └── src │ │ └── gleam_avm │ │ └── atomvm.gleam ├── esp32boot │ └── CMakeLists.txt └── jit │ └── rebar.conf ├── src ├── platforms │ ├── esp32 │ │ ├── sdkconfig.defaults.esp32h2 │ │ ├── test │ │ │ ├── wokwi.toml.license │ │ │ ├── main │ │ │ │ ├── idf_component.yml.license │ │ │ │ ├── idf_component.yml │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── test_erl_sources │ │ │ │ │ ├── test_md5.erl │ │ │ │ │ ├── test_list_to_binary.erl │ │ │ │ │ └── test_esp_timer_get_time.erl │ │ │ ├── qemu_esp32c3_efuse.bin.license │ │ │ ├── sdkconfig.ci.wokwi.license │ │ │ ├── sdkconfig.defaults.license │ │ │ ├── sim_boards │ │ │ │ ├── diagram.esp32.json.license │ │ │ │ ├── diagram.esp32c3.json.license │ │ │ │ ├── diagram.esp32c6.json.license │ │ │ │ ├── diagram.esp32h2.json.license │ │ │ │ ├── diagram.esp32p4.json.license │ │ │ │ ├── diagram.esp32s2.json.license │ │ │ │ ├── diagram.esp32s3.json.license │ │ │ │ ├── diagram.esp32p4.json │ │ │ │ ├── diagram.esp32h2.json │ │ │ │ ├── diagram.esp32c3.json │ │ │ │ ├── diagram.esp32s2.json │ │ │ │ ├── diagram.esp32s3.json │ │ │ │ └── diagram.esp32c6.json │ │ │ ├── wokwi.toml │ │ │ ├── sdkconfig.defaults │ │ │ ├── sdkconfig.ci.wokwi │ │ │ ├── partitions.csv │ │ │ └── qemu_esp32c3_efuse.bin │ │ ├── sdkconfig.defaults.license │ │ ├── sdkconfig.defaults.esp32h2.license │ │ ├── sdkconfig.release-defaults.license │ │ ├── main │ │ │ ├── idf_component.yml.example.license │ │ │ └── CMakeLists.txt │ │ ├── sdkconfig.defaults │ │ ├── sdkconfig.release-defaults │ │ ├── sdkconfig.defaults.esp32p4 │ │ ├── partitions.csv │ │ ├── partitions-elixir.csv │ │ ├── components │ │ │ ├── avm_builtins │ │ │ │ ├── idf_component.yml │ │ │ │ ├── otp_net_platform.c │ │ │ │ ├── otp_ssl_platform.c │ │ │ │ ├── otp_crypto_platform.c │ │ │ │ └── otp_socket_platform.c │ │ │ └── avm_sys │ │ │ │ └── jit_stream_flash.c │ │ └── tools │ │ │ └── flashimage.sh.in │ ├── rp2 │ │ ├── tests │ │ │ ├── tsconfig.json │ │ │ ├── package.json │ │ │ ├── package.json.license │ │ │ ├── tsconfig.json.license │ │ │ ├── package-lock.json.license │ │ │ └── .gitignore │ │ ├── .gitignore │ │ └── src │ │ │ └── lib │ │ │ ├── otp_ssl_platform.c │ │ │ ├── otp_crypto_platform.c │ │ │ ├── gpiodriver.h │ │ │ ├── platform_defaultatoms.h │ │ │ └── otp_net_lwip_raw.h │ ├── emscripten │ │ ├── .gitignore │ │ ├── tests │ │ │ └── .gitignore │ │ └── src │ │ │ └── lib │ │ │ └── websocket_nifs.h │ ├── stm32 │ │ ├── .gitignore │ │ └── src │ │ │ └── lib │ │ │ └── jit_stream_flash.c │ └── generic_unix │ │ └── lib │ │ ├── otp_socket_platform.c │ │ └── jit_stream_mmap.h └── libAtomVM │ ├── atomvm_version.h │ ├── version.h.in │ └── otp_crypto.h ├── doc ├── assets │ ├── dashbit-logo.png │ ├── sw-mansion-logo.png │ ├── dashbit-logo.png.license │ └── sw-mansion-logo.png.license ├── src │ ├── _static │ │ ├── AVM-alt.png │ │ ├── AtomVM-logo.png │ │ ├── avm_logo_banner.png │ │ ├── favicon │ │ │ ├── favicon.ico │ │ │ └── favicon.ico.license │ │ ├── AVM-alt.png.license │ │ ├── AtomVM-logo.png.license │ │ ├── avm_logo_banner.png.license │ │ ├── css │ │ │ └── custom.css │ │ └── avm_logo_banner.png.notice │ └── apidocs │ │ └── libatomvm │ │ ├── file.rst.in │ │ ├── macros.rst │ │ └── index.rst ├── edoc │ └── edown_dep │ │ ├── rebar.config │ │ ├── README.md │ │ └── src │ │ ├── edown_dep.app.src │ │ └── edown_dep.erl ├── requirements.txt ├── doxygen │ └── README.md └── graphviz │ └── globalcontext-atoms.dot ├── .github ├── pull_request_template.md.license ├── pull_request_template.md └── workflows │ └── reuse-lint.yaml ├── LICENSES └── LicenseRef-Proprietary.txt ├── tools ├── test │ └── smoke-test │ │ ├── .gitignore │ │ └── etc │ │ ├── common.sh │ │ └── esp32.sh └── uf2tool │ └── rebar.config ├── .reuse └── dep5 ├── code-queries └── qlpack.yml ├── .clang-format-ignore ├── SECURITY.md ├── examples ├── elixir │ ├── stm32 │ │ ├── README.md │ │ └── CMakeLists.txt │ ├── CMakeLists.txt │ └── esp32 │ │ └── CMakeLists.txt ├── gleam │ ├── CMakeLists.txt │ ├── hello_atomvm │ │ ├── CMakeLists.txt │ │ └── gleam.toml │ └── supervise_actor │ │ └── CMakeLists.txt └── erlang │ ├── esp32 │ ├── reformat_nvs.erl │ └── uartecho.erl │ ├── hello_world.erl │ └── rp2 │ └── picow_blink.erl ├── tests ├── libs │ ├── alisp │ │ ├── rebar.config │ │ ├── tests.erl │ │ └── CMakeLists.txt │ ├── exavmlib │ │ ├── Some.Submodule.ex │ │ └── CMakeLists.txt │ ├── etest │ │ └── CMakeLists.txt │ └── eavmlib │ │ └── tests.erl └── erlang_tests │ ├── modb.erl │ ├── modc.erl │ ├── test_display.erl │ ├── len_test.erl │ ├── negatives2.erl │ ├── add.erl │ ├── fact.erl │ ├── raise_if_end.erl │ ├── match.erl │ ├── nested_list_size0.erl │ ├── nested_list_size1.erl │ ├── tuple_size1.erl │ ├── nested_list_size2.erl │ ├── tuple_size2.erl │ ├── tuple_size3.erl │ ├── raise_badmatch.erl │ ├── test_match.erl │ ├── code_load │ └── export_test_module.erl │ ├── tuple_size4.erl │ ├── simple_list_size0.erl │ ├── bigfact.erl │ ├── bigfact2.erl │ ├── biggerintegers.erl │ ├── test_make_list.erl │ ├── tuple.erl │ ├── whereis_fail.erl │ ├── bigfact3.erl │ ├── negatives.erl │ ├── simple_list_size1.erl │ ├── test_bitwise2.erl │ ├── erlang_module_loaded.erl │ ├── nested_tuple_size0.erl │ ├── try_noerror.erl │ ├── tuples_and_list_size1.erl │ ├── boxedabs.erl │ ├── boxedneg.erl │ ├── compact27bitsinteger.erl │ ├── guards5.erl │ ├── byte_size_test.erl │ ├── ceilint.erl │ ├── guards4.erl │ ├── is_ref_test.erl │ ├── large_int_literal.erl │ ├── roundint.erl │ ├── truncint.erl │ ├── tuples_and_list_size2.erl │ ├── floorint.erl │ ├── compact15bitsinteger.erl │ ├── compact23bitsinteger.erl │ ├── test_list_gc.erl │ ├── compact23bitsneginteger.erl │ ├── floatabs.erl │ ├── moda.erl │ ├── complex_struct_size3.erl │ ├── spawn_fun2.erl │ ├── test_element.erl │ ├── to_hrl.erl │ ├── raise_case_end.erl │ ├── test_funs0.erl │ ├── mutrec.erl │ ├── nested_tuple_size1.erl │ ├── test_funs1.erl │ ├── test_bitwise.erl │ ├── test_funs2.erl │ ├── negovf.erl │ ├── absovf.erl │ ├── negdiv.erl │ ├── roundbadarg.erl │ ├── truncbadarg.erl │ ├── guards1.erl │ ├── if_test.erl │ ├── ceilbadarg.erl │ ├── ceilfloat.erl │ ├── count_char_bs.erl │ ├── count_char.erl │ ├── floorbadarg.erl │ ├── floorfloat.erl │ ├── roundfloat.erl │ ├── truncfloat.erl │ ├── morelabels.erl │ ├── test_concat_badarg.erl │ ├── test_func_info2.erl │ ├── test_func_info3.erl │ └── make_garbage5.erl ├── version.cmake ├── CMakeModules ├── FindGleam.cmake ├── FindDialyzer.cmake ├── FindGraphviz.cmake ├── FetchUnity.cmake ├── FindDoxygen.cmake ├── FindSphinx.cmake └── FindElixir.cmake └── .gitignore /libs/eavmlib/rebar.lock: -------------------------------------------------------------------------------- 1 | []. 2 | -------------------------------------------------------------------------------- /src/platforms/esp32/sdkconfig.defaults.esp32h2: -------------------------------------------------------------------------------- 1 | CONFIG_AVM_RTC_SLOW_MAX_SIZE=3072 2 | -------------------------------------------------------------------------------- /doc/assets/dashbit-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atomvm/AtomVM/HEAD/doc/assets/dashbit-logo.png -------------------------------------------------------------------------------- /doc/src/_static/AVM-alt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atomvm/AtomVM/HEAD/doc/src/_static/AVM-alt.png -------------------------------------------------------------------------------- /src/platforms/rp2/tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /doc/assets/sw-mansion-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atomvm/AtomVM/HEAD/doc/assets/sw-mansion-logo.png -------------------------------------------------------------------------------- /doc/src/_static/AtomVM-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atomvm/AtomVM/HEAD/doc/src/_static/AtomVM-logo.png -------------------------------------------------------------------------------- /libs/eavmlib/rebar.lock.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: CC0-1.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /libs/exavmlib/mix.lock.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: CC0-1.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /doc/src/_static/avm_logo_banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atomvm/AtomVM/HEAD/doc/src/_static/avm_logo_banner.png -------------------------------------------------------------------------------- /doc/src/_static/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atomvm/AtomVM/HEAD/doc/src/_static/favicon/favicon.ico -------------------------------------------------------------------------------- /doc/assets/dashbit-logo.png.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: (C) Dashbit 2 | SPDX-License-Identifier: LicenseRef-Proprietary 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/wokwi.toml.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/sdkconfig.defaults.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /.github/pull_request_template.md.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: CC0-1.0 2 | SPDX-FileCopyrightText: Davide Bettio 3 | -------------------------------------------------------------------------------- /doc/assets/sw-mansion-logo.png.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: (C) Software Mansion 2 | SPDX-License-Identifier: LicenseRef-Proprietary 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/sdkconfig.defaults.esp32h2.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/sdkconfig.release-defaults.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/main/idf_component.yml.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/qemu_esp32c3_efuse.bin.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sdkconfig.ci.wokwi.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sdkconfig.defaults.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/main/idf_component.yml.example.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /LICENSES/LicenseRef-Proprietary.txt: -------------------------------------------------------------------------------- 1 | This file is proprietary. Please contact the copyright holder for more information about its licensing and use. 2 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32.json.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32c3.json.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32c6.json.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32h2.json.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32p4.json.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32s2.json.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32s3.json.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: Apache-2.0 2 | SPDX-FileCopyrightText: AtomVM Contributors 3 | -------------------------------------------------------------------------------- /doc/src/_static/AVM-alt.png.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2022 Fred Dushin 2 | 3 | SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | -------------------------------------------------------------------------------- /doc/src/_static/AtomVM-logo.png.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2022 Fred Dushin 2 | 3 | SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | -------------------------------------------------------------------------------- /doc/src/_static/favicon/favicon.ico.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2022 Fred Dushin 2 | 3 | SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | -------------------------------------------------------------------------------- /src/platforms/emscripten/.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Paul Guyot 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | 5 | build 6 | -------------------------------------------------------------------------------- /src/platforms/esp32/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 3 | CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y 4 | CONFIG_LWIP_IPV6=n 5 | -------------------------------------------------------------------------------- /tools/test/smoke-test/.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023 Fred Dushin 3 | # 4 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 5 | # 6 | bin/activate 7 | -------------------------------------------------------------------------------- /doc/src/_static/avm_logo_banner.png.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2023 Winford (Uncle Grumpy) 2 | 3 | SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/wokwi.toml: -------------------------------------------------------------------------------- 1 | [wokwi] 2 | version = 1 3 | generatedBy = "pytest-embedded-wokwi 1.8.1" 4 | firmware = "build/flasher_args.json" 5 | elf = "build/atomvm-esp32-test.elf" 6 | -------------------------------------------------------------------------------- /src/platforms/stm32/.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Riccardo Binetti 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | 5 | build/ 6 | *.elf 7 | *.bin 8 | generated.*.ld 9 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | These changes are made under both the "Apache 2.0" and the "GNU Lesser General 2 | Public License 2.1 or later" license terms (dual license). 3 | 4 | SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 5 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: AtomVM 3 | Source: https://github.com/atomvm/AtomVM 4 | 5 | Files: CHANGELOG.md 6 | Copyright: AtomVM Contributors 7 | License: CC0-1.0 8 | -------------------------------------------------------------------------------- /doc/edoc/edown_dep/rebar.config: -------------------------------------------------------------------------------- 1 | % Copyright 2023 Winford (Uncle Grumpy) 2 | % 3 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | 5 | {erl_opts, [debug_info]}. 6 | {deps, [{edown, "~> 0.9.1"}]}. 7 | {plugins, []}. 8 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | "espressif/dp83848": 3 | version: "~1.0.0" 4 | rules: 5 | - if: "idf_version >=6.0" 6 | - if: target in ["esp32", "esp32p4"] 7 | - if: "$CONFIG{ETH_USE_OPENETH} == True" 8 | -------------------------------------------------------------------------------- /src/platforms/esp32/sdkconfig.release-defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 3 | CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y 4 | CONFIG_COMPILER_OPTIMIZATION_PERF=y 5 | CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y 6 | CONFIG_LWIP_IPV6=n 7 | -------------------------------------------------------------------------------- /doc/requirements.txt: -------------------------------------------------------------------------------- 1 | ## Copyright 2023 Winford (Uncle Grumpy) 2 | ## 3 | ## SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | 5 | # Python requirements to build AtomVM documentation. 6 | 7 | sphinx 8 | myst-parser 9 | sphinx-rtd-theme 10 | gitpython 11 | breathe 12 | pygments 13 | -------------------------------------------------------------------------------- /code-queries/qlpack.yml: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2023 Davide Bettio 5 | # 6 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 7 | # 8 | 9 | name: atomvm/cpp-atomvmql 10 | groups: [cpp] 11 | libraryPathDependencies: codeql/cpp-all 12 | extractor: cpp 13 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=n 4 | CONFIG_ESP_INT_WDT_TIMEOUT_MS=10000 5 | CONFIG_ETH_USE_OPENETH=y 6 | CONFIG_AVM_RTC_SLOW_MAX_SIZE=1024 7 | CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y 8 | CONFIG_LWIP_IPV6=n 9 | -------------------------------------------------------------------------------- /doc/src/_static/css/custom.css: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: 2024 Winford (Uncle Grumpy) 2 | * 3 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | */ 5 | 6 | /* Fix table widths too wide */ 7 | .wy-table-responsive table td, .wy-table-responsive table th { 8 | white-space: inherit; 9 | } 10 | -------------------------------------------------------------------------------- /doc/src/_static/avm_logo_banner.png.notice: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2023 Winford (Uncle Grumpy) 2 | 3 | SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | 5 | This is a derivative work based on Fred Dushin's original AtomVM-logo.png found at: 6 | https://github.com/atomvm/AtomVM/doc/src/_static/AtomVM-alt.png 7 | -------------------------------------------------------------------------------- /src/platforms/rp2/tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rp2040_tests", 3 | "description": "Tests using rp2040js emulator", 4 | "dependencies": { 5 | "@tsconfig/node20": "^20.1.2", 6 | "rp2040js": "^0.19.3", 7 | "sync-fetch": "^0.5.2", 8 | "tsx": "^3.12.8", 9 | "typescript": "^5.2.2", 10 | "uf2": "^1.0.0" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sdkconfig.ci.wokwi: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_CUSTOM=y 2 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 3 | CONFIG_ESP_INT_WDT_TIMEOUT_MS=10000 4 | CONFIG_AVM_RTC_SLOW_MAX_SIZE=1024 5 | CONFIG_ETH_USE_OPENETH=n 6 | CONFIG_COMPILER_OPTIMIZATION_PERF=y 7 | CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y 8 | CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y 9 | CONFIG_LWIP_IPV6=n 10 | -------------------------------------------------------------------------------- /doc/edoc/edown_dep/README.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # edown_dep 8 | 9 | Welcome to the edown_dep AtomVM application. 10 | 11 | To build and flash this application to your ESP32 device, issue the `esp32_flash` target 12 | 13 | shell$ rebar3 esp32_flash 14 | -------------------------------------------------------------------------------- /.clang-format-ignore: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2022 Davide Bettio 3 | # 4 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 5 | # 6 | 7 | # We have a number of existing files that are quite "re-format unfriendly" 8 | # Let's ignore all of them 9 | src/libAtomVM/opcodesswitch.h 10 | src/platforms/esp32/build/* 11 | src/platforms/esp32/components/* 12 | src/platforms/stm32/build/* 13 | -------------------------------------------------------------------------------- /doc/src/apidocs/libatomvm/file.rst.in: -------------------------------------------------------------------------------- 1 | .. Copyright 2023 Winford (Uncle Grumpy) 2 | .. 3 | .. SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | 5 | :orphan: 6 | 7 | .. c:namespace:: libAtomVM 8 | .. c:namespace-push:: @SOURCE_FILE@ 9 | 10 | ------------------ 11 | @SOURCE_FILE@ 12 | ------------------ 13 | 14 | .. toctree:: 15 | :maxdepth: 3 16 | 17 | .. doxygenfile:: @SOURCE_FILE@ 18 | :allow-dot-graphs: 19 | -------------------------------------------------------------------------------- /doc/edoc/edown_dep/src/edown_dep.app.src: -------------------------------------------------------------------------------- 1 | % Copyright 2023 Winford (Uncle Grumpy) 2 | % 3 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | 5 | {application, edown_dep, [ 6 | {description, "An OTP library"}, 7 | {vsn, "0.1.0"}, 8 | {registered, []}, 9 | {applications, [ 10 | kernel, stdlib 11 | ]}, 12 | {env,[]}, 13 | {modules, []}, 14 | {licenses, ["Apache 2.0"]}, 15 | {links, []} 16 | ]}. 17 | -------------------------------------------------------------------------------- /doc/src/apidocs/libatomvm/macros.rst: -------------------------------------------------------------------------------- 1 | .. Copyright 2023 Winford (Uncle Grumpy) 2 | .. 3 | .. SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | 5 | :orphan: 6 | 7 | .. c:namespace:: libAtomVM 8 | .. c:namespace-push:: macros 9 | 10 | --------------------- 11 | MACROS 12 | --------------------- 13 | 14 | .. toctree:: 15 | :maxdepth: 3 16 | 17 | .. doxygendefine:: ATOM_STR 18 | .. doxygendefine:: GET_LIST_ENTRY 19 | .. doxygendefine:: SELECT_INT_DEFAULT 20 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32p4.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "author": "Uri Shaked", 4 | "editor": "wokwi", 5 | "parts": [ 6 | { 7 | "type": "board-esp32-p4-function-ev", 8 | "id": "esp", 9 | "top": -17.23, 10 | "left": -16.04, 11 | "attrs": { "psramSize": "4" } 12 | } 13 | ], 14 | "connections": [ 15 | ["esp:37", "$serialMonitor:RX", "", []], 16 | ["esp:38", "$serialMonitor:TX", "", []] 17 | ], 18 | "serialMonitor": { "display": "terminal" }, 19 | "dependencies": {} 20 | } 21 | -------------------------------------------------------------------------------- /.github/workflows/reuse-lint.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Free Software Foundation Europe e.V. 2 | # 3 | # SPDX-License-Identifier: CC0-1.0 4 | 5 | name: REUSE Compliance Check 6 | 7 | on: [push, pull_request] 8 | 9 | concurrency: 10 | group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} 11 | cancel-in-progress: true 12 | 13 | jobs: 14 | test: 15 | runs-on: ubuntu-24.04 16 | steps: 17 | - uses: actions/checkout@v4 18 | - name: REUSE Compliance Check 19 | uses: fsfe/reuse-action@v1 20 | -------------------------------------------------------------------------------- /doc/doxygen/README.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # AtomVM Internal Documentation {#mainpage} 8 | 9 | Welcome to the AtomVM internal VM documentation. 10 | 11 | This documentation set is generated from the AtomVM C implementation and describes the internal data structures used to implement AtomVM. This documentation is useful for developers who are interested in the internal implementation details of AtomVM, and who may be interested in getting involved with AtomVM features and bug fixes. 12 | -------------------------------------------------------------------------------- /src/platforms/esp32/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | # SPDX-FileCopyrightText: AtomVM Contributors 3 | # 4 | # ESP32-P4 Flash and PSRAM 5 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 6 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_SPIRAM=y 9 | 10 | # esp-wifi-external config for ESP32-C6 esp_wifi_hosted via SDIO 11 | # (default options for esp32-p4-function-ev-board) 12 | CONFIG_LWIP_PPP_VJ_HEADER_COMPRESSION=n 13 | CONFIG_SLAVE_IDF_TARGET_ESP32C6=y 14 | CONFIG_LWIP_IPV6=y 15 | CONFIG_WIFI_RMT_EXTRA_IRAM_OPT=n 16 | CONFIG_WIFI_RMT_SLP_IRAM_OPT=n 17 | -------------------------------------------------------------------------------- /src/platforms/esp32/partitions.csv: -------------------------------------------------------------------------------- 1 | # Copyright 2018-2021 Davide Bettio 2 | # Copyright 2018-2021 Fred Dushin 3 | # 4 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 5 | 6 | # Name, Type, SubType, Offset, Size, Flags 7 | # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild 8 | nvs, data, nvs, 0x9000, 0x6000, 9 | phy_init, data, phy, 0xf000, 0x1000, 10 | factory, app, factory, 0x10000, 0x1C0000, 11 | boot.avm, data, phy, 0x1D0000, 0x40000, 12 | main.avm, data, phy, 0x210000, 0x100000 13 | -------------------------------------------------------------------------------- /src/platforms/esp32/partitions-elixir.csv: -------------------------------------------------------------------------------- 1 | # Copyright 2018-2021 Davide Bettio 2 | # Copyright 2018-2021 Fred Dushin 3 | # 4 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 5 | 6 | # Name, Type, SubType, Offset, Size, Flags 7 | # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild 8 | nvs, data, nvs, 0x9000, 0x6000, 9 | phy_init, data, phy, 0xf000, 0x1000, 10 | factory, app, factory, 0x10000, 0x1C0000, 11 | boot.avm, data, phy, 0x1D0000, 0x80000, 12 | main.avm, data, phy, 0x250000, 0x100000 13 | -------------------------------------------------------------------------------- /doc/src/apidocs/libatomvm/index.rst: -------------------------------------------------------------------------------- 1 | .. Copyright 2023 Winford (Uncle Grumpy) 2 | .. 3 | .. SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 4 | 5 | :orphan: 6 | 7 | .. c:namespace:: libAtomVM 8 | 9 | ------------------------- 10 | libAtomVM 11 | ------------------------- 12 | 13 | .. toctree:: 14 | :maxdepth: 3 15 | :caption: C Library APIs 16 | 17 | functions 18 | data_structures 19 | types 20 | macros 21 | 22 | ------------------------- 23 | libAtomVM source files 24 | ------------------------- 25 | 26 | .. toctree:: 27 | :maxdepth: 3 28 | :caption: Includes 29 | :glob: 30 | 31 | src/* 32 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # Security Policy 8 | 9 | ## Supported Versions 10 | 11 | | Version | Supported | 12 | | ------- | ------------------ | 13 | | 0.6.x | :white_check_mark: | 14 | | < 0.5 | :x: | 15 | 16 | 17 | ## Reporting a Vulnerability 18 | 19 | To submit a vulnerability report, please contact us at davide at uninstall.it. 20 | Please, **do not use GitHub issues for vulnerability reports**. 21 | Your submission will be promptly reviewed and validated by a member of our team. 22 | -------------------------------------------------------------------------------- /examples/elixir/stm32/README.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # STM32F4Discovery example 8 | 9 | This example will blink the 4 LEDs present on the STM32F4Discovery with 10 | different frequencies, using one process per LED. 11 | 12 | # Building 13 | From the root of the AtomVM repo, build the whole repo with 14 | - `mkdir build && cd build` 15 | - `cmake ..` 16 | - `make -j4` 17 | 18 | # Flashing 19 | - Follow the STM32 README (`src/platforms/stm32`) to build and flash AtomVM 20 | - From the root of the repo, `cd build/examples/elixir/stm32` 21 | - Flash the packed AVM with `st-flash --reset write MultiBlink.avm 0x8080000` 22 | -------------------------------------------------------------------------------- /src/platforms/rp2/tests/package.json.license: -------------------------------------------------------------------------------- 1 | This file is part of AtomVM. 2 | 3 | Copyright 2023 Paul Guyot 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 18 | -------------------------------------------------------------------------------- /src/platforms/rp2/tests/tsconfig.json.license: -------------------------------------------------------------------------------- 1 | This file is part of AtomVM. 2 | 3 | Copyright 2023 Paul Guyot 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 18 | -------------------------------------------------------------------------------- /src/platforms/rp2/tests/package-lock.json.license: -------------------------------------------------------------------------------- 1 | This file is part of AtomVM. 2 | 3 | Copyright 2023 Paul Guyot 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 18 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/partitions.csv: -------------------------------------------------------------------------------- 1 | # Copyright 2018-2021 Davide Bettio 2 | # Copyright 2018-2021 Fred Dushin 3 | # 4 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 5 | 6 | # UPDATE ALSO "test_erl_sources/test_esp_partition.erl" WHEN UPDATING THIS FILE 7 | # OTHERWISE "test_esp_partition.erl" TEST WILL ALWAYS FAIL. 8 | 9 | # Name, Type, SubType, Offset, Size, Flags 10 | # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild 11 | nvs, data, nvs, 0x9000, 0x6000, 12 | phy_init, data, phy, 0xf000, 0x1000, 13 | factory, app, factory, 0x10000, 0x2C0000, 14 | lib.avm, data, phy, 0x2D0000, 0x40000, 15 | main.avm, data, phy, 0x310000, 0x40000 16 | -------------------------------------------------------------------------------- /src/platforms/rp2/.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2022 Paul Guyot 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | build 21 | -------------------------------------------------------------------------------- /libs/exavmlib/.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Davide Bettio 2 | # 3 | # SPDX-License-Identifier: CC0-1.0 4 | 5 | # The directory Mix will write compiled artifacts to. 6 | /_build/ 7 | 8 | # If you run "mix test --cover", coverage assets end up here. 9 | /cover/ 10 | 11 | # The directory Mix downloads your dependencies sources to. 12 | /deps/ 13 | 14 | # Where third-party dependencies like ExDoc output generated docs. 15 | /doc/ 16 | 17 | # Ignore .fetch files in case you like to edit your project deps locally. 18 | /.fetch 19 | 20 | # If the VM crashes, it generates a dump, let's ignore it too. 21 | erl_crash.dump 22 | 23 | # Also ignore archive artifacts (built via "mix archive.build"). 24 | *.ez 25 | 26 | # Ignore package tarball (built via "mix hex.build"). 27 | exavmlib-*.tar 28 | 29 | -------------------------------------------------------------------------------- /src/platforms/rp2/tests/.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2023 Paul Guyot 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | node_modules 21 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32h2.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "author": "Uri Shaked", 4 | "editor": "wokwi", 5 | "parts": [ 6 | { "type": "board-esp32-h2-devkitm-1", "id": "esp", "top": 2.23, "left": -5.1, "attrs": {} }, 7 | { 8 | "type": "wokwi-slide-potentiometer", 9 | "id": "pot1", 10 | "top": 57.8, 11 | "left": -235.8, 12 | "rotate": 180, 13 | "attrs": { "travelLength": "30", "value": "512" } 14 | } 15 | ], 16 | "connections": [ 17 | [ "esp:TX", "$serialMonitor:RX", "", [] ], 18 | [ "esp:RX", "$serialMonitor:TX", "", [] ], 19 | [ "esp:GND.2", "pot1:GND", "black", [ "h0" ] ], 20 | [ "esp:3V3", "pot1:VCC", "red", [ "v0", "h-19.2", "v105.6" ] ], 21 | [ "esp:4", "pot1:SIG", "green", [ "h0" ] ] 22 | ], 23 | "dependencies": {} 24 | } -------------------------------------------------------------------------------- /libs/alisp/src/rebar.config: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2022 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | {project_plugins, [erlfmt]}. 22 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32c3.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "author": "Uri Shaked", 4 | "editor": "wokwi", 5 | "parts": [ 6 | { "type": "board-esp32-c3-devkitm-1", "id": "esp", "top": -0.3, "left": -3.78, "attrs": {} }, 7 | { 8 | "type": "wokwi-slide-potentiometer", 9 | "id": "pot1", 10 | "top": 9.8, 11 | "left": -235.8, 12 | "rotate": 180, 13 | "attrs": { "travelLength": "30", "value": "512" } 14 | } 15 | ], 16 | "connections": [ 17 | [ "esp:TX", "$serialMonitor:RX", "", [] ], 18 | [ "esp:RX", "$serialMonitor:TX", "", [] ], 19 | [ "esp:3", "pot1:SIG", "green", [ "h0" ] ], 20 | [ "esp:3V3.2", "pot1:VCC", "red", [ "h-22.98", "v38.1" ] ], 21 | [ "esp:GND.1", "pot1:GND", "black", [ "v0", "h-211.2" ] ] 22 | ], 23 | "dependencies": {} 24 | } -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32s2.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "author": "Uri Shaked", 4 | "editor": "wokwi", 5 | "parts": [ 6 | { "type": "board-esp32-s2-devkitm-1", "id": "esp", "top": -13.91, "left": 4.57, "attrs": {} }, 7 | { 8 | "type": "wokwi-slide-potentiometer", 9 | "id": "pot1", 10 | "top": 77, 11 | "left": -235.8, 12 | "rotate": 180, 13 | "attrs": { "travelLength": "30", "value": "256" } 14 | } 15 | ], 16 | "connections": [ 17 | [ "esp:TX", "$serialMonitor:RX", "", [] ], 18 | [ "esp:RX", "$serialMonitor:TX", "", [] ], 19 | [ "pot1:SIG", "esp:11", "green", [ "h14.8", "v5.6" ] ], 20 | [ "esp:GND.1", "pot1:GND", "black", [ "h0" ] ], 21 | [ "pot1:VCC", "esp:3V3", "red", [ "h24.4", "v-125.29" ] ] 22 | ], 23 | "dependencies": {} 24 | } -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32s3.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "author": "Uri Shaked", 4 | "editor": "wokwi", 5 | "parts": [ 6 | { "type": "board-esp32-s3-devkitc-1", "id": "esp", "top": 0, "left": 0, "attrs": {} }, 7 | { 8 | "type": "wokwi-slide-potentiometer", 9 | "id": "pot1", 10 | "top": 86.6, 11 | "left": -235.8, 12 | "rotate": 180, 13 | "attrs": { "travelLength": "30", "value": "512" } 14 | } 15 | ], 16 | "connections": [ 17 | [ "esp:TX", "$serialMonitor:RX", "", [] ], 18 | [ "esp:RX", "$serialMonitor:TX", "", [] ], 19 | [ "esp:GND.1", "pot1:GND", "black", [ "h0" ] ], 20 | [ "esp:3V3.2", "pot1:VCC", "red", [ "h-24.28", "v115.02" ] ], 21 | [ "esp:11", "pot1:SIG", "green", [ "h-14.68", "v-48.18" ] ] 22 | ], 23 | "dependencies": {} 24 | } -------------------------------------------------------------------------------- /tests/libs/alisp/rebar.config: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2021 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | {project_plugins, [erlfmt]}. 22 | -------------------------------------------------------------------------------- /src/platforms/esp32/components/avm_builtins/idf_component.yml: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | # SPDX-FileCopyrightText: AtomVM Contributors 3 | # 4 | ## IDF Component Manager Manifest File 5 | dependencies: 6 | # # Put list of dependencies here 7 | # # For components maintained by Espressif: 8 | # component: "~1.0.0" 9 | # # For 3rd party components: 10 | # username/component: ">=1.0.0,<2.0.0" 11 | # username2/component2: 12 | # version: "~1.0.0" 13 | # # For transient dependencies `public` flag can be set. 14 | # # `public` flag doesn't have an effect dependencies of the `main` component. 15 | # # All dependencies of `main` are public by default. 16 | # public: true 17 | 18 | espressif/esp_wifi_remote: 19 | rules: 20 | - if: "idf_version >= 5.4" 21 | - if: target in ["esp32p4"] 22 | -------------------------------------------------------------------------------- /doc/edoc/edown_dep/src/edown_dep.erl: -------------------------------------------------------------------------------- 1 | % 2 | % Copyright (c) 2023 Winford (Uncle Grumpy) winford@object.stream 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 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 17 | % 18 | 19 | -module(edown_dep). 20 | 21 | -export([start/0]). 22 | 23 | start() -> 24 | ok. 25 | -------------------------------------------------------------------------------- /tools/uf2tool/rebar.config: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2024 Paul Guyot 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | {deps, [ 22 | uf2tool 23 | ]}. 24 | {escript_main_app, uf2tool}. 25 | -------------------------------------------------------------------------------- /libs/estdlib/src/inet-priv.hrl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2023 Fred Dushin 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -define(GEN_TCP_MONIKER, '$avm_gen_tcp'). 22 | -define(GEN_UDP_MONIKER, '$avm_gen_udp'). 23 | -------------------------------------------------------------------------------- /tests/libs/exavmlib/Some.Submodule.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2024 Davide Bettio 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | defmodule Some.Submodule do 22 | def start do 23 | :ok 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /tests/erlang_tests/modb.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(modb). 22 | 23 | -export([test/0]). 24 | 25 | test() -> 26 | modc:test(moda:test1()). 27 | -------------------------------------------------------------------------------- /tests/libs/alisp/tests.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2021 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(tests). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | etest:test([test_alisp]). 27 | -------------------------------------------------------------------------------- /examples/gleam/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2025 Paul Guyot 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | project(examples_gleam) 22 | 23 | add_subdirectory(hello_atomvm) 24 | add_subdirectory(supervise_actor) 25 | -------------------------------------------------------------------------------- /tests/erlang_tests/modc.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(modc). 22 | 23 | -export([test/1]). 24 | 25 | test(Val) -> 26 | moda:test2(Val * 2, dec). 27 | -------------------------------------------------------------------------------- /examples/erlang/esp32/reformat_nvs.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Fred Dushin 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(reformat_nvs). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | esp:nvs_reformat(). 27 | -------------------------------------------------------------------------------- /libs/exavmlib/.formatter.exs: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2020 Davide Bettio 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | # Used by "mix format" 22 | [ 23 | inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] 24 | ] 25 | -------------------------------------------------------------------------------- /version.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2022-2024 Davide Bettio 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | # Please, keep also in sync src/libAtomVM/atomvm_version.h 22 | set(ATOMVM_BASE_VERSION "0.7.0-dev") 23 | set(ATOMVM_DEV TRUE) 24 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/sim_boards/diagram.esp32c6.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "author": "Uri Shaked", 4 | "editor": "wokwi", 5 | "parts": [ 6 | { 7 | "type": "board-esp32-c6-devkitc-1", 8 | "id": "esp", 9 | "top": 5.29, 10 | "left": 4.12, 11 | "attrs": { "cpuFrequency": "32" } 12 | }, 13 | { 14 | "type": "wokwi-slide-potentiometer", 15 | "id": "pot1", 16 | "top": 105.8, 17 | "left": -245.4, 18 | "rotate": 180, 19 | "attrs": { "travelLength": "30", "value": "512" } 20 | } 21 | ], 22 | "connections": [ 23 | ["esp:TX", "$serialMonitor:RX", "", []], 24 | ["esp:RX", "$serialMonitor:TX", "", []], 25 | ["esp:GND.1", "pot1:GND", "black", ["h-28.8", "v48", "h-211.2"]], 26 | ["esp:3V3", "pot1:VCC", "red", ["v0", "h-38.4", "v144"]], 27 | ["esp:3", "pot1:SIG", "green", ["h0"]] 28 | ], 29 | "dependencies": {} 30 | } 31 | -------------------------------------------------------------------------------- /examples/erlang/hello_world.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(hello_world). 22 | -export([start/0]). 23 | 24 | start() -> 25 | erlang:display(hello_world), 26 | ok. 27 | -------------------------------------------------------------------------------- /src/platforms/emscripten/tests/.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2022 Paul Guyot 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | node_modules 21 | package-lock.json 22 | package.json 23 | cypress/downloads 24 | cypress/screenshots 25 | cypress/videos 26 | -------------------------------------------------------------------------------- /examples/elixir/stm32/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2019 Riccardo Binetti 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | project(examples_elixir_stm32) 22 | 23 | include(BuildElixir) 24 | 25 | pack_runnable(MultiBlink MultiBlink estdlib eavmlib exavmlib) 26 | -------------------------------------------------------------------------------- /examples/gleam/hello_atomvm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2025 Paul Guyot 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | project(hello_atomvm) 22 | 23 | include(BuildGleam) 24 | 25 | pack_gleam_runnable(hello_atomvm hello_atomvm estdlib gleam_avm) 26 | -------------------------------------------------------------------------------- /libs/gleam_avm/manifest.toml: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2025 Paul Guyot 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | # This file was generated by Gleam 22 | # You typically do not need to edit this file 23 | 24 | packages = [ 25 | ] 26 | 27 | [requirements] 28 | -------------------------------------------------------------------------------- /libs/gleam_avm/gleam.toml: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2025 Paul Guyot 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | name = "gleam_avm" 22 | version = "0.1.0" 23 | 24 | description = "Gleam bindings for AtomVM API" 25 | licences = ["Apache-2.0", "LGPL-2.1-or-later"] 26 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_display.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018-2020 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_display). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | true = erlang:display([1, 2, 3, 4]), 27 | 0. 28 | -------------------------------------------------------------------------------- /examples/gleam/supervise_actor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2025 Mikael Karlsson 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | project(supervise_actor) 22 | 23 | include(BuildGleam) 24 | 25 | pack_gleam_runnable(supervise_actor supervise_actor estdlib) 26 | -------------------------------------------------------------------------------- /tests/erlang_tests/len_test.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2017 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(len_test). 22 | 23 | -export([start/0, len/2]). 24 | 25 | start() -> 26 | len("hello", 0). 27 | 28 | len(A, N) -> 29 | length(A) + N. 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/negatives2.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(negatives2). 22 | 23 | -export([start/0, f/2]). 24 | 25 | start() -> 26 | -f(20, 10) * 5. 27 | 28 | f(A, B) -> 29 | (A - B) * 10. 30 | -------------------------------------------------------------------------------- /src/platforms/generic_unix/lib/otp_socket_platform.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2023 by Fred Dushin 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #include "otp_socket_platform.h" 22 | 23 | bool otp_socket_platform_supports_peek(void) 24 | { 25 | return false; 26 | } 27 | -------------------------------------------------------------------------------- /tests/erlang_tests/add.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2017 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(add). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | add(8, 9). 27 | 28 | add(A, B) -> 29 | id(A) + id(B). 30 | 31 | id(I) -> 32 | I. 33 | -------------------------------------------------------------------------------- /tests/erlang_tests/fact.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2017 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(fact). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | factorial(5). 27 | 28 | factorial(0) -> 1; 29 | factorial(N) -> N * factorial(N - 1). 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/raise_if_end.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(raise_if_end). 22 | 23 | -export([do_raise/2]). 24 | 25 | do_raise(A, B) -> 26 | if 27 | A > B -> 1; 28 | A < B -> 2 29 | end. 30 | -------------------------------------------------------------------------------- /tests/libs/exavmlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2024 Davide Bettio 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | project(test_exavmlib) 22 | 23 | include(BuildElixir) 24 | 25 | set(TEST_MODULES 26 | Some.Submodule 27 | ) 28 | 29 | pack_test(Tests Tests ${TEST_MODULES}) 30 | -------------------------------------------------------------------------------- /CMakeModules/FindGleam.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2025 Paul Guyot 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | find_program(GLEAM_EXECUTABLE gleam) 22 | 23 | include(FindPackageHandleStandardArgs) 24 | 25 | find_package_handle_standard_args(Gleam 26 | REQUIRED_VARS GLEAM_EXECUTABLE) 27 | -------------------------------------------------------------------------------- /tests/erlang_tests/match.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(match). 22 | 23 | -export([start/0, f/1, g/1]). 24 | 25 | start() -> 26 | 5 = f(5) - g(6). 27 | 28 | f(A) -> 29 | A * 2. 30 | 31 | g(B) -> 32 | B - 1. 33 | -------------------------------------------------------------------------------- /tests/erlang_tests/nested_list_size0.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(nested_list_size0). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_nested()). 27 | 28 | make_nested() -> 29 | []. 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/nested_list_size1.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(nested_list_size1). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_nested()). 27 | 28 | make_nested() -> 29 | [[]]. 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/tuple_size1.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(tuple_size1). 22 | 23 | -export([start/0, make_tuple/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_tuple()). 27 | 28 | make_tuple() -> 29 | {test}. 30 | -------------------------------------------------------------------------------- /src/platforms/rp2/src/lib/otp_ssl_platform.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2023 by Paul Guyot 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | REGISTER_NIF_COLLECTION(otp_ssl, otp_ssl_init, NULL, otp_ssl_nif_get_nif) 26 | -------------------------------------------------------------------------------- /tests/erlang_tests/nested_list_size2.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(nested_list_size2). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_nested()). 27 | 28 | make_nested() -> 29 | [[[1, 2]]]. 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/tuple_size2.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(tuple_size2). 22 | 23 | -export([start/0, make_tuple/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_tuple()). 27 | 28 | make_tuple() -> 29 | {test, 10}. 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/tuple_size3.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(tuple_size3). 22 | 23 | -export([start/0, make_tuple/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_tuple()). 27 | 28 | make_tuple() -> 29 | {test, [], 20}. 30 | -------------------------------------------------------------------------------- /examples/elixir/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2019 Riccardo Binetti 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | project(examples_elixir) 22 | 23 | include(BuildElixir) 24 | 25 | add_subdirectory(esp32) 26 | add_subdirectory(stm32) 27 | 28 | pack_runnable(HelloWorld HelloWorld estdlib eavmlib exavmlib) 29 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/List.Chars.Integer.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2013-2023 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/commits/v1.17.2/lib/elixir/lib/list/chars.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | defimpl List.Chars, for: Integer do 23 | def to_charlist(term) do 24 | Integer.to_charlist(term) 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /libs/exavmlib/mix.lock: -------------------------------------------------------------------------------- 1 | %{ 2 | "earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm"}, 3 | "ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, 4 | "makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, 5 | "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, 6 | "nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm"}, 7 | } 8 | -------------------------------------------------------------------------------- /src/platforms/rp2/src/lib/otp_crypto_platform.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2023 by Paul Guyot 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | REGISTER_NIF_COLLECTION(otp_crypto, NULL, NULL, otp_crypto_nif_get_nif) 26 | -------------------------------------------------------------------------------- /tests/erlang_tests/raise_badmatch.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(raise_badmatch). 22 | 23 | -export([do_raise/2]). 24 | 25 | do_raise(A, B) -> 26 | A = factorial(B). 27 | 28 | factorial(0) -> 1; 29 | factorial(N) -> N * factorial(N - 1). 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_match.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_match). 22 | 23 | -export([start/0, echo/1]). 24 | 25 | start() -> 26 | Term = {a, b, c}, 27 | Term = echo(Term), 28 | 0. 29 | 30 | echo(Term) -> 31 | Term. 32 | -------------------------------------------------------------------------------- /CMakeModules/FindDialyzer.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2019 Riccardo Binetti 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | find_program(DIALYZER_PATH dialyzer) 22 | 23 | if (DIALYZER_PATH) 24 | set(Dialyzer_FOUND TRUE) 25 | elseif(Dialyzer_FIND_REQUIRED) 26 | message(FATAL_ERROR "dialyzer not found") 27 | endif() 28 | -------------------------------------------------------------------------------- /tests/erlang_tests/code_load/export_test_module.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2023 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(export_test_module). 22 | 23 | -export([exported_func/1]). 24 | 25 | exported_func(0) -> 26 | 1; 27 | exported_func(N) -> 28 | ?MODULE:exported_func(N - 1) * N. 29 | -------------------------------------------------------------------------------- /CMakeModules/FindGraphviz.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2021 Fred Dushin 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | find_program(GRAPHVIZ_PATH dot) 22 | 23 | if (GRAPHVIZ_PATH) 24 | set(GRAPHVIZ_FOUND TRUE) 25 | elseif(GRAPHVIZ_FIND_REQUIRED) 26 | message(FATAL_ERROR "Graphviz command (dot) not found") 27 | endif() 28 | -------------------------------------------------------------------------------- /tests/erlang_tests/tuple_size4.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(tuple_size4). 22 | 23 | -export([start/0, make_tuple/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_tuple()). 27 | 28 | make_tuple() -> 29 | {{a}, {1, 2}, {[], [], []}}. 30 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2022 Davide Bettio 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | idf_component_register(SRCS "test_main.c" 22 | INCLUDE_DIRS ".") 23 | 24 | add_subdirectory(test_erl_sources) 25 | target_link_libraries(${COMPONENT_LIB} esp32_test_modules) 26 | -------------------------------------------------------------------------------- /tests/erlang_tests/simple_list_size0.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(simple_list_size0). 22 | 23 | -export([start/0, make_simple_list/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_simple_list()). 27 | 28 | make_simple_list() -> 29 | [1]. 30 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/List.Chars.Atom.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2013-2023 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/commits/v1.17.2/lib/elixir/lib/list/chars.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | defimpl List.Chars, for: Atom do 23 | def to_charlist(nil), do: ~c"" 24 | 25 | def to_charlist(atom), do: Atom.to_charlist(atom) 26 | end 27 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/List.Chars.List.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2013-2023 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/commits/v1.17.2/lib/elixir/lib/list/chars.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | defimpl List.Chars, for: List do 23 | # Note that same inlining is used for the rewrite rule. 24 | def to_charlist(list), do: list 25 | end 26 | -------------------------------------------------------------------------------- /libs/gleam_avm/src/gleam_avm/atomvm.gleam: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of AtomVM. 3 | // 4 | // Copyright 2025 Paul Guyot 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | // 20 | 21 | pub type Platform { 22 | GenericUnix 23 | Emscripten 24 | Esp32 25 | Pico 26 | Stm32 27 | } 28 | 29 | @external(erlang, "atomvm", "platform") 30 | pub fn platform() -> Platform 31 | -------------------------------------------------------------------------------- /src/libAtomVM/atomvm_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2024 Davide Bettio 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #ifndef _ATOMVM_VERSION_H_ 22 | #define _ATOMVM_VERSION_H_ 23 | 24 | #define ATOMVM_VERSION_MAJOR 0 25 | #define ATOMVM_VERSION_MINOR 6 26 | #define ATOMVM_VERSION_PATCH 999 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /tests/erlang_tests/bigfact.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(bigfact). 22 | 23 | -export([start/0, factorial/1]). 24 | 25 | start() -> 26 | bigfact:factorial(20) div bigfact:factorial(15). 27 | 28 | factorial(0) -> 1; 29 | factorial(N) -> N * factorial(N - 1). 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/bigfact2.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(bigfact2). 22 | 23 | -export([start/0, factorial/1]). 24 | 25 | start() -> 26 | abs(-factorial(20)) rem -(factorial(12) + 1). 27 | 28 | factorial(0) -> 1; 29 | factorial(N) -> N * factorial(N - 1). 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/biggerintegers.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2017 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(biggerintegers). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | add(500, 50). 27 | 28 | add(A, B) -> 29 | id(A) + id(B). 30 | 31 | id(0) -> 32 | 0; 33 | id(I) -> 34 | I. 35 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_make_list.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Fred Dushin 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_make_list). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | length(make_list(a, b, c)). 27 | 28 | make_list(A, B, C) -> 29 | [{foo, "bar"}, {gnu, "gnat"}, {a, A}, {b, B}, {c, C}]. 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/tuple.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2017 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(tuple). 22 | 23 | -export([start/0, maketuple/3, sumtuple/1]). 24 | 25 | start() -> sumtuple(maketuple(1, 2, 3)). 26 | 27 | maketuple(A, B, C) -> {A, B, C}. 28 | 29 | sumtuple({A, B, C}) -> A + B + C. 30 | -------------------------------------------------------------------------------- /libs/estdlib/src/file.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2025 Software Mansion S.A. 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(file). 22 | 23 | -export([native_name_encoding/0, get_cwd/0]). 24 | 25 | -spec native_name_encoding() -> latin1 | utf8. 26 | native_name_encoding() -> 27 | utf8. 28 | 29 | get_cwd() -> 30 | erlang:nif_error(undefined). 31 | -------------------------------------------------------------------------------- /src/libAtomVM/version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2019 Fred Dushin 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #define SYSTEM_NAME "${CMAKE_SYSTEM_NAME}" 22 | #define SYSTEM_VERSION "${CMAKE_SYSTEM_VERSION}" 23 | #define SYSTEM_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}" 24 | #define ATOMVM_VERSION "${ATOMVM_VERSION}" 25 | -------------------------------------------------------------------------------- /src/platforms/rp2/src/lib/gpiodriver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2023 Paul Guyot 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #ifndef _GPIODRIVER_H_ 22 | #define _GPIODRIVER_H_ 23 | 24 | #include "context.h" 25 | #include "nifs.h" 26 | 27 | const struct Nif *gpiodriver_get_nif(const char *nifname); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/whereis_fail.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(whereis_fail). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | result_to_int(whereis(this_is_missing)). 27 | 28 | result_to_int(undefined) -> 29 | 2; 30 | result_to_int(_) -> 31 | 3. 32 | -------------------------------------------------------------------------------- /tools/test/smoke-test/etc/common.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env false 2 | # 3 | # This file is part of AtomVM. 4 | # 5 | # Copyright 2023 Fred Dushin 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 20 | # 21 | 22 | function echo_run() { 23 | local cmd="$@" 24 | echo "# ${cmd}" 25 | ${cmd} 26 | } 27 | 28 | function banner() { 29 | echo "%%" 30 | echo "%% $1" 31 | echo "%%" 32 | } 33 | -------------------------------------------------------------------------------- /tests/erlang_tests/bigfact3.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(bigfact3). 22 | 23 | -export([start/0, factorial/1]). 24 | 25 | start() -> 26 | (factorial(20) - factorial(19)) rem (factorial(10) + 1). 27 | 28 | factorial(0) -> 1; 29 | factorial(N) -> N * factorial(N - 1). 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/negatives.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(negatives). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | op(31420, 8192, -1). 27 | 28 | op(A, B, C) -> 29 | (id(A) + id(B) * 3) * C. 30 | 31 | id(0) -> 32 | 0; 33 | id(I) -> 34 | I. 35 | -------------------------------------------------------------------------------- /tests/erlang_tests/simple_list_size1.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(simple_list_size1). 22 | 23 | -export([start/0, make_simple_list/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_simple_list()). 27 | 28 | make_simple_list() -> 29 | [1, 2, 3, 4, 5]. 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_bitwise2.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_bitwise2). 22 | 23 | -export([start/0, f/3, g/1]). 24 | 25 | start() -> 26 | f(g(18), 2#11, 2#11). 27 | 28 | f(A, B, C) -> 29 | bnot (A) bor (B bxor C). 30 | 31 | g(N) -> 32 | -1 bsr N. 33 | -------------------------------------------------------------------------------- /tests/libs/alisp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2021 Davide Bettio 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | project(test_alisp) 22 | 23 | include(BuildErlang) 24 | 25 | set(ERLANG_MODULES 26 | test_alisp 27 | ) 28 | 29 | pack_archive(test_alisp_lib ${ERLANG_MODULES}) 30 | pack_test(test_alisp estdlib eavmlib alisp etest) 31 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/String.Chars.List.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2013-2023 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/commits/v1.17.2/lib/elixir/lib/string/chars.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | import Kernel, except: [to_string: 1] 23 | 24 | defimpl String.Chars, for: List do 25 | def to_string(charlist), do: List.to_string(charlist) 26 | end 27 | -------------------------------------------------------------------------------- /tests/erlang_tests/erlang_module_loaded.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2025 Tomasz Sobkiewicz 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(erlang_module_loaded). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | true = erlang:module_loaded(?MODULE), 27 | false = erlang:module_loaded(undefined_module), 28 | 0. 29 | -------------------------------------------------------------------------------- /tests/erlang_tests/nested_tuple_size0.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(nested_tuple_size0). 22 | 23 | -export([start/0, make_nested_tuple/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_nested_tuple()). 27 | 28 | make_nested_tuple() -> 29 | {[{1, 2}, {2, 4}]}. 30 | -------------------------------------------------------------------------------- /CMakeModules/FetchUnity.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2023 Paul Guyot 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | include(FetchContent) 22 | 23 | FetchContent_Declare( 24 | unity 25 | GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git 26 | GIT_TAG v2.5.2 27 | GIT_SHALLOW 1 28 | ) 29 | 30 | FetchContent_MakeAvailable(unity) 31 | -------------------------------------------------------------------------------- /tests/erlang_tests/try_noerror.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(try_noerror). 22 | 23 | -export([start/0, f/1]). 24 | 25 | start() -> 26 | f(3). 27 | 28 | f(Value) -> 29 | try 5 div Value of 30 | AnyVal -> AnyVal 31 | catch 32 | _:_ -> error 33 | end. 34 | -------------------------------------------------------------------------------- /tests/erlang_tests/tuples_and_list_size1.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(tuples_and_list_size1). 22 | 23 | -export([start/0, make_tuples_and_list/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_tuples_and_list()). 27 | 28 | make_tuples_and_list() -> 29 | [{a, 10}]. 30 | -------------------------------------------------------------------------------- /doc/graphviz/globalcontext-atoms.dot: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2019-2020 Fred Dushin 3 | // 4 | // SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 5 | // 6 | digraph g { 7 | 8 | graph [ 9 | rankdir = "LR" 10 | ]; 11 | 12 | node [ 13 | fontname = "courier" 14 | fontsize = "16" 15 | shape = "ellipse" 16 | ]; 17 | 18 | edge []; 19 | 20 | "GlobalContext" [ 21 | label = " GlobalContext | ... | atoms_table | atoms_id_table | ..." 22 | shape = "Mrecord" 23 | ]; 24 | 25 | "AtomsTable" [ 26 | label = " AtomsHashtable | {{AtomString | \\x2ok | \\x5error| ...}|{atom_id | 0 | 1 | ...}}" 27 | shape = "Mrecord" 28 | ]; 29 | 30 | "AtomsIDTable" [ 31 | label = " ValuesHashtable | { {atom_id | 0 | 1 | ...} | {AtomString | \\x2ok | \\x5error| ...}}" 32 | shape = "Mrecord" 33 | ]; 34 | 35 | "GlobalContext":at -> "AtomsTable":f0; 36 | "GlobalContext":ait -> "AtomsIDTable":f0; 37 | } 38 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/RuntimeError.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2012-2018 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/tree/v1.7.4/lib/elixir/lib/exception.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | defmodule RuntimeError do 23 | # This avoids crashing the compiler at build time 24 | @compile {:autoload, false} 25 | 26 | defexception message: "runtime error" 27 | end 28 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/qemu_esp32c3_efuse.bin: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /tests/erlang_tests/boxedabs.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(boxedabs). 22 | 23 | -export([start/0, pow/2]). 24 | 25 | start() -> 26 | (abs(pow(-2, 31)) - 1) rem (abs(pow(-2, 27)) - 1). 27 | 28 | pow(N, 0) when is_number(N) -> 29 | 1; 30 | pow(N, M) -> 31 | N * pow(N, M - 1). 32 | -------------------------------------------------------------------------------- /tests/erlang_tests/boxedneg.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(boxedneg). 22 | 23 | -export([start/0, pow/2]). 24 | 25 | start() -> 26 | (-(pow(-2, 31)) - 1) rem (-(pow(-2, 27)) - 1). 27 | 28 | pow(N, 0) when is_number(N) -> 29 | 1; 30 | pow(N, M) -> 31 | N * pow(N, M - 1). 32 | -------------------------------------------------------------------------------- /tests/erlang_tests/compact27bitsinteger.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(compact27bitsinteger). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | op(61591023, 123456). 27 | 28 | op(A, B) -> 29 | id(A) + id(B) * 2. 30 | 31 | id(0) -> 32 | 0; 33 | id(I) -> 34 | I. 35 | -------------------------------------------------------------------------------- /tests/erlang_tests/guards5.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(guards5). 22 | 23 | -export([start/0, do_something/1]). 24 | 25 | start() -> 26 | do_something(true) + do_something(false) * 2. 27 | 28 | do_something(A) when is_boolean(A) -> 29 | 1; 30 | do_something(_A) -> 31 | 0. 32 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/ArgumentError.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2012-2018 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/tree/v1.7.4/lib/elixir/lib/exception.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | defmodule ArgumentError do 23 | # This avoids crashing the compiler at build time 24 | @compile {:autoload, false} 25 | 26 | defexception message: "argument error" 27 | end 28 | -------------------------------------------------------------------------------- /tests/erlang_tests/byte_size_test.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2017 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(byte_size_test). 22 | 23 | -export([start/0, bsize/2]). 24 | 25 | start() -> 26 | bsize(<<"I">>, 0) + bsize(<<"am">>, 0) + bsize(<<"a">>, 0) + bsize(<<"binary">>, 0). 27 | 28 | bsize(Bin, V) -> 29 | byte_size(Bin) + V. 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/ceilint.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(ceilint). 22 | 23 | -export([start/0, id/1]). 24 | 25 | start() -> 26 | to_int(add(id(3), id(-2))). 27 | 28 | add(A, B) -> 29 | id(A) + id(B). 30 | 31 | to_int(A) -> 32 | id(ceil(id(A))). 33 | 34 | id(I) -> 35 | I. 36 | -------------------------------------------------------------------------------- /tests/erlang_tests/guards4.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(guards4). 22 | 23 | -export([start/0, comp/2]). 24 | 25 | start() -> 26 | comp(3, 3) * 5 + comp(1, 3). 27 | 28 | comp(A, B) when A /= B -> 29 | 1; 30 | comp(A, B) when A =/= B -> 31 | 2; 32 | comp(_A, _B) -> 33 | 3. 34 | -------------------------------------------------------------------------------- /tests/erlang_tests/is_ref_test.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(is_ref_test). 22 | 23 | -export([start/0, func/2]). 24 | 25 | start() -> 26 | func(1, make_ref()) + func(0, 9). 27 | 28 | func(A, B) when is_reference(B) -> 29 | A * 2; 30 | func(_A, B) when is_integer(B) -> 31 | 1. 32 | -------------------------------------------------------------------------------- /tests/erlang_tests/large_int_literal.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019-2020 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(large_int_literal). 22 | 23 | -export([start/0, factorial/1]). 24 | 25 | start() -> 26 | (16#7FCAFEBABE02ABCD bxor factorial(10)) rem 7919. 27 | 28 | factorial(0) -> 1; 29 | factorial(N) -> N * factorial(N - 1). 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/roundint.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(roundint). 22 | 23 | -export([start/0, id/1]). 24 | 25 | start() -> 26 | to_int(add(id(3), id(-2))). 27 | 28 | add(A, B) -> 29 | id(A) + id(B). 30 | 31 | to_int(A) -> 32 | round(id(A)). 33 | 34 | id(I) -> 35 | I. 36 | -------------------------------------------------------------------------------- /tests/erlang_tests/truncint.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(truncint). 22 | 23 | -export([start/0, id/1]). 24 | 25 | start() -> 26 | to_int(add(id(3), id(-2))). 27 | 28 | add(A, B) -> 29 | id(A) + id(B). 30 | 31 | to_int(A) -> 32 | trunc(id(A)). 33 | 34 | id(I) -> 35 | I. 36 | -------------------------------------------------------------------------------- /tests/erlang_tests/tuples_and_list_size2.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(tuples_and_list_size2). 22 | 23 | -export([start/0, make_tuples_and_list/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_tuples_and_list()). 27 | 28 | make_tuples_and_list() -> 29 | [{a, 10}, {b, 20}]. 30 | -------------------------------------------------------------------------------- /tests/libs/etest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2024 Paul Guyot 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | project(test_etest) 22 | 23 | include(BuildErlang) 24 | 25 | set(ERLANG_MODULES 26 | test_eunit 27 | ) 28 | 29 | pack_archive(test_etest_lib ERLC_FLAGS -DTEST MODULES ${ERLANG_MODULES}) 30 | pack_eunit(test_etest estdlib eavmlib etest) 31 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/String.Chars.Integer.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2013-2023 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/commits/v1.17.2/lib/elixir/lib/string/chars.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | import Kernel, except: [to_string: 1] 23 | 24 | defimpl String.Chars, for: Integer do 25 | def to_string(term) do 26 | Integer.to_string(term) 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /tests/erlang_tests/floorint.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(floorint). 22 | 23 | -export([start/0, id/1]). 24 | 25 | start() -> 26 | to_int(add(id(3), id(-2))). 27 | 28 | add(A, B) -> 29 | id(A) + id(B). 30 | 31 | to_int(A) -> 32 | id(round(id(A))). 33 | 34 | id(I) -> 35 | I. 36 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/main/test_erl_sources/test_md5.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2023 Paul Guyot 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_md5). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | <<62, 37, 150, 10, 121, 219, 198, 155, 103, 76, 212, 236, 103, 167, 44, 98>> = erlang:md5( 27 | <<"Hello world">> 28 | ), 29 | ok. 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/compact15bitsinteger.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(compact15bitsinteger). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | op(31420, 8192, 48). 27 | 28 | op(A, B, C) -> 29 | (id(A) + id(B) * 3) * (C - 20). 30 | 31 | id(0) -> 32 | 0; 33 | id(I) -> 34 | I. 35 | -------------------------------------------------------------------------------- /tests/erlang_tests/compact23bitsinteger.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(compact23bitsinteger). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | op(5946590, 8192, 28). 27 | 28 | op(A, B, C) -> 29 | (id(A) + id(B) * 3) * (C - 20). 30 | 31 | id(0) -> 32 | 0; 33 | id(I) -> 34 | I. 35 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_list_gc.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Fred Dushin 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_list_gc). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | Self = self(), 27 | Config = [ 28 | {foo, [{bar, Self}]}, 29 | {tapas, 30000} 30 | ], 31 | erlang:display(Config), 32 | length(Config). 33 | -------------------------------------------------------------------------------- /src/platforms/generic_unix/lib/jit_stream_mmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2025 by Paul Guyot 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #ifndef AVM_NO_JIT 22 | 23 | #include "globalcontext.h" 24 | #include "nifs.h" 25 | 26 | const struct Nif *jit_stream_mmap_get_nif(const char *nifname); 27 | void jit_stream_mmap_init(GlobalContext *); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /CMakeModules/FindDoxygen.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2021 Fred Dushin 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | find_program(DOXYGEN_PATH doxygen) 22 | 23 | if (DOXYGEN_PATH) 24 | set(DOXYGEN_FOUND TRUE) 25 | set(DOXYGEN_BUILD_EXECUTABLE "${DOXYGEN_PATH}") 26 | elseif(DOXYGEN_FIND_REQUIRED) 27 | message(FATAL_ERROR "Doxygen command (doxygen) not found") 28 | endif() 29 | -------------------------------------------------------------------------------- /CMakeModules/FindSphinx.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2021 Fred Dushin 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | find_program(SPHINX_PATH sphinx-build) 22 | 23 | if (SPHINX_PATH) 24 | set(SPHINX_FOUND TRUE) 25 | set(SPHINX_BUILD_EXECUTABLE "${SPHINX_PATH}") 26 | elseif(SPHINX_FIND_REQUIRED) 27 | message(FATAL_ERROR "Sphinx command (spinx-build) not found") 28 | endif() 29 | -------------------------------------------------------------------------------- /tests/erlang_tests/compact23bitsneginteger.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(compact23bitsneginteger). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | op(-5946590, 8192, 28). 27 | 28 | op(A, B, C) -> 29 | (id(A) + id(B) * 3) * (C - 20). 30 | 31 | id(0) -> 32 | 0; 33 | id(I) -> 34 | I. 35 | -------------------------------------------------------------------------------- /examples/erlang/esp32/uartecho.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2020 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(uartecho). 22 | -export([start/0]). 23 | 24 | start() -> 25 | UART = uart:open("UART0", []), 26 | loop(UART). 27 | 28 | loop(UART) -> 29 | {ok, B} = uart:read(UART), 30 | uart:write(UART, [<<"Echo: ">>, B, <<"\n">>]), 31 | loop(UART). 32 | -------------------------------------------------------------------------------- /libs/esp32boot/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2023 Davide Bettio 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | project(esp32boot) 22 | 23 | include(BuildErlang) 24 | 25 | if (Elixir_FOUND) 26 | pack_runnable(elixir_esp32boot esp32init esp32devmode eavmlib estdlib alisp exavmlib) 27 | endif() 28 | 29 | pack_runnable(esp32boot esp32init esp32devmode eavmlib estdlib alisp) 30 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/ArithmeticError.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2012-2018 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/tree/v1.7.4/lib/elixir/lib/exception.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | defmodule ArithmeticError do 23 | # This avoids crashing the compiler at build time 24 | @compile {:autoload, false} 25 | 26 | defexception message: "bad argument in arithmetic expression" 27 | end 28 | -------------------------------------------------------------------------------- /tests/erlang_tests/floatabs.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(floatabs). 22 | 23 | -export([start/0, add/2, id/1, to_int/1]). 24 | 25 | start() -> 26 | to_int(abs(add(id(-2.5), id(-0.8)))). 27 | 28 | add(A, B) -> 29 | id(A) + id(B). 30 | 31 | to_int(A) -> 32 | round(A). 33 | 34 | id(I) -> 35 | I. 36 | -------------------------------------------------------------------------------- /tests/erlang_tests/moda.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(moda). 22 | 23 | -export([start/0, test1/0, test2/2]). 24 | 25 | start() -> 26 | modb:test() + 5. 27 | 28 | test1() -> 29 | 20. 30 | 31 | test2(Val, inc) -> 32 | Val + 1; 33 | test2(Val, dec) -> 34 | Val - 1; 35 | test2(_Val, _) -> 36 | 0. 37 | -------------------------------------------------------------------------------- /tests/erlang_tests/complex_struct_size3.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(complex_struct_size3). 22 | 23 | -export([start/0, a/0, b/0, c/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(c()). 27 | 28 | a() -> 29 | [1, 2, 3, 4, 5]. 30 | 31 | b() -> 32 | [5, 4, 3, 2, 1]. 33 | 34 | c() -> 35 | {a(), b()}. 36 | -------------------------------------------------------------------------------- /tests/erlang_tests/spawn_fun2.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Riccardo Binetti 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(spawn_fun2). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | Father = self(), 27 | Fun = fun() -> Father ! 33 end, 28 | spawn_opt(Fun, []), 29 | Result = 30 | receive 31 | Any -> Any 32 | end, 33 | Result. 34 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_element.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_element). 22 | 23 | -export([start/0, f/2, g/1]). 24 | 25 | start() -> 26 | f({1, hello}, g(0)) + f({1, 2, world}, g(2)) + f({4}, g(0)). 27 | 28 | f(X, N) -> 29 | element(N, X). 30 | 31 | g(0) -> 32 | 1; 33 | g(N) -> 34 | g(N - 1) * N. 35 | -------------------------------------------------------------------------------- /tests/erlang_tests/to_hrl.erl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env escript 2 | %% -*- erlang -*- 3 | %%! -sname to_hrl debug verbose 4 | % 5 | % This file is part of AtomVM. 6 | % 7 | % Copyright 2023 Davide Bettio 8 | % 9 | % Licensed under the Apache License, Version 2.0 (the "License"); 10 | % you may not use this file except in compliance with the License. 11 | % You may obtain a copy of the License at 12 | % 13 | % http://www.apache.org/licenses/LICENSE-2.0 14 | % 15 | % Unless required by applicable law or agreed to in writing, software 16 | % distributed under the License is distributed on an "AS IS" BASIS, 17 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | % See the License for the specific language governing permissions and 19 | % limitations under the License. 20 | % 21 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 22 | % 23 | 24 | main([InFile, Name, OutFile]) -> 25 | {ok, In} = file:read_file(InFile), 26 | {ok, Out} = file:open(OutFile, [write]), 27 | io:format(Out, "-define(~s, ~w).", [Name, In]). 28 | -------------------------------------------------------------------------------- /tools/test/smoke-test/etc/esp32.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env false 2 | # 3 | # This file is part of AtomVM. 4 | # 5 | # Copyright 2023 Fred Dushin 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 20 | # 21 | 22 | export ESP32_ESPTOOL="${ESP32_ESPTOOL:-esptool.py}" 23 | export ESP32_CHIP="${ESP32_CHIP:-auto}" 24 | export ESP32_PORT="${ESP32_PORT:-/dev/ttyUSB0}" 25 | export ESP32_BAUD="${ESP32_BAUD:-921600}" 26 | export ESP32_OFFSET="${ESP32_OFFSET:-0x1000}" 27 | -------------------------------------------------------------------------------- /tests/erlang_tests/raise_case_end.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(raise_case_end). 22 | 23 | -export([do_raise/1]). 24 | 25 | do_raise(B) -> 26 | case factorial(B) of 27 | 10 -> -1; 28 | 11 -> -2; 29 | 12 -> -3 30 | end. 31 | 32 | factorial(0) -> 1; 33 | factorial(N) -> N * factorial(N - 1). 34 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_funs0.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_funs0). 22 | 23 | -export([start/0, sumeach/3]). 24 | 25 | start() -> 26 | sumeach(fun(V) -> V * 2 end, [1, 2, 3, 4], 0). 27 | 28 | sumeach(F, [H | T], Acc) -> 29 | R = F(H), 30 | sumeach(F, T, R + Acc); 31 | sumeach(_F, [], Acc) -> 32 | Acc. 33 | -------------------------------------------------------------------------------- /tests/erlang_tests/mutrec.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2017 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(mutrec). 22 | 23 | -export([start/0, rec4/1, willnotbecalled/2]). 24 | 25 | start() -> 26 | rec2(2) + rec3(3). 27 | 28 | rec2(X) -> X + 1. 29 | 30 | rec3(X) -> rec4(X - 1). 31 | 32 | rec4(0) -> 3; 33 | rec4(X) -> rec3(X - 1). 34 | 35 | willnotbecalled(0, O) -> 2 - O. 36 | -------------------------------------------------------------------------------- /tests/erlang_tests/nested_tuple_size1.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(nested_tuple_size1). 22 | 23 | -export([start/0, make_nested_tuple/0]). 24 | 25 | start() -> 26 | erts_debug:flat_size(make_nested_tuple()). 27 | 28 | make_nested_tuple() -> 29 | {[{1, 2}, {2, 4}, {3, 6}], [{1, 2}, {3, 6}, {5, 10}, {7, 14}], [{0, 0}]}. 30 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_funs1.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_funs1). 22 | 23 | -export([start/0, plus5/1, f/2]). 24 | 25 | start() -> 26 | C = f("1", "2"), 27 | plus5(fun() -> C end) + 28 | plus5(fun() -> 0 end) * 100. 29 | 30 | plus5(F) -> 31 | F() + 5. 32 | 33 | f(A, B) -> 34 | list_to_integer(A ++ B). 35 | -------------------------------------------------------------------------------- /tests/libs/eavmlib/tests.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Fred Dushin 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(tests). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | etest:test([ 27 | test_dir, 28 | test_file, 29 | test_http_server, 30 | test_mdns, 31 | test_port, 32 | test_timer_manager, 33 | test_ahttp_client 34 | ]). 35 | -------------------------------------------------------------------------------- /examples/elixir/esp32/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2019 Riccardo Binetti 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | project(examples_elixir_esp32) 22 | 23 | include(BuildElixir) 24 | 25 | pack_runnable(Blink Blink estdlib eavmlib exavmlib) 26 | pack_runnable(Ledc_x4 Ledc_x4 estdlib eavmlib exavmlib) 27 | if(NOT (AVM_DISABLE_FP)) 28 | pack_runnable(SHT31 SHT31 estdlib eavmlib exavmlib) 29 | endif() 30 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/String.Chars.Atom.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2013-2023 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/commits/v1.17.2/lib/elixir/lib/string/chars.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | import Kernel, except: [to_string: 1] 23 | 24 | defimpl String.Chars, for: Atom do 25 | def to_string(nil) do 26 | "" 27 | end 28 | 29 | def to_string(atom) do 30 | Atom.to_string(atom) 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /src/libAtomVM/otp_crypto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2023 Paul Guyot 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #ifndef _OTP_CRYPTO_H_ 22 | #define _OTP_CRYPTO_H_ 23 | 24 | #include 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | const struct Nif *otp_crypto_nif_get_nif(const char *nifname); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_bitwise.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_bitwise). 22 | 23 | -export([start/0, f/3, g/1, h/1]). 24 | 25 | start() -> 26 | f(2#00010 bor g(2) bor h(2), 2#01010, 2#00001). 27 | 28 | f(A, B, C) -> 29 | bnot (A band B) bxor C. 30 | 31 | g(N) -> 32 | 2#1 bsl N. 33 | 34 | h(N) -> 35 | 2#0100 bsr N. 36 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_funs2.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_funs2). 22 | 23 | -export([start/0, sumeach/3]). 24 | 25 | start() -> 26 | sumeach(fun(V, Acc) -> V * 2 + Acc end, [1, 2, 3, 4], 0). 27 | 28 | sumeach(F, [H | T], Acc) -> 29 | R = F(H, Acc), 30 | sumeach(F, T, R + Acc); 31 | sumeach(_F, [], Acc) -> 32 | Acc. 33 | -------------------------------------------------------------------------------- /src/platforms/esp32/tools/flashimage.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # This file is part of AtomVM. 4 | # 5 | # Copyright 2020-2021 Fred Dushin 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 20 | # 21 | 22 | THIS_DIR="$(cd $(dirname $0) && pwd)" 23 | ROOT_DIR="$(cd "${THIS_DIR}/../../../.." && pwd)" 24 | 25 | FLASH_OFFSET="@BOOTLOADER_OFFSET@" ${ROOT_DIR}/src/platforms/esp32/build/flash.sh $@ "${ROOT_DIR}/src/platforms/esp32/build/atomvm-@CONFIG_IDF_TARGET@.img" 26 | -------------------------------------------------------------------------------- /src/platforms/rp2/src/lib/platform_defaultatoms.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2022 Paul Guyot 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #ifndef _PLATFORM_DEFAULTATOMS_H_ 22 | #define _PLATFORM_DEFAULTATOMS_H_ 23 | 24 | #include "defaultatoms.h" 25 | 26 | #define PICO_ATOM_INDEX (PLATFORM_ATOMS_BASE_INDEX + 0) 27 | 28 | #define PICO_ATOM TERM_FROM_ATOM_INDEX(PICO_ATOM_INDEX) 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2020 Davide Bettio 2 | # Copyright 2018-2020 Fred Dushin 3 | # 4 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 5 | 6 | *.avm 7 | *.beam 8 | *.o 9 | build/** 10 | xcode/** 11 | examples/**/build 12 | libs/**/build 13 | src/platforms/esp32/dependencies.lock 14 | src/platforms/esp32/managed_components/** 15 | src/platforms/esp32/build/** 16 | src/platforms/esp32/build/**/*.d 17 | src/platforms/esp32/test/build/** 18 | src/platforms/esp32/test/__pycache__/** 19 | src/platforms/esp32/components/** 20 | src/platforms/esp32/managed_components/** 21 | src/platforms/esp32/sdkconfig 22 | src/platforms/esp32/main/idf_component.yml 23 | src/platforms/esp32/dependencies.lock 24 | !src/platforms/esp32/components/avm_builtins/ 25 | !src/platforms/esp32/components/avm_builtins/** 26 | !src/platforms/esp32/components/avm_sys/ 27 | !src/platforms/esp32/components/avm_sys/** 28 | !src/platforms/esp32/components/libatomvm/ 29 | !src/platforms/esp32/components/libatomvm/** 30 | .idea/** 31 | .vscode/** 32 | .DS_Store 33 | .cache 34 | .clang-tidy 35 | -------------------------------------------------------------------------------- /examples/gleam/hello_atomvm/gleam.toml: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2025 Paul Guyot 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | name = "hello_atomvm" 22 | version = "1.0.0" 23 | 24 | description = "Hello AtomVM example" 25 | licences = ["Apache-2.0", "LGPL-2.1-or-later"] 26 | 27 | [dependencies] 28 | gleam_stdlib = ">= 0.34.0 and < 2.0.0" 29 | # gleam_avm = ">= 0.1.0" 30 | gleam_avm = { path = "../../../libs/gleam_avm" } 31 | -------------------------------------------------------------------------------- /tests/erlang_tests/negovf.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(negovf). 22 | 23 | -export([start/0, negfunc/2, id/1]). 24 | 25 | start() -> 26 | negfunc(id(-134217728), id(1)). 27 | 28 | negfunc(A, B) -> 29 | try -id(A) of 30 | Value -> Value * B 31 | catch 32 | _:_ -> A + B * 10 33 | end. 34 | 35 | id(A) -> 36 | A. 37 | -------------------------------------------------------------------------------- /src/platforms/emscripten/src/lib/websocket_nifs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2025 Paul Guyot 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #ifndef _WEBSOCKET_NIFS_H_ 22 | #define _WEBSOCKET_NIFS_H_ 23 | 24 | #include 25 | #include 26 | 27 | const struct Nif *websocket_get_nif(const char *nifname); 28 | extern const ErlNifResourceTypeInit websocket_resource_type_init; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/platforms/esp32/components/avm_builtins/otp_net_platform.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2023 by Fred Dushin 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | #ifdef CONFIG_AVM_ENABLE_OTP_NET_NIFS 28 | 29 | REGISTER_NIF_COLLECTION(otp_net, otp_net_init, NULL, otp_net_nif_get_nif) 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/platforms/esp32/components/avm_builtins/otp_ssl_platform.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2023 by Paul Guyot 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | #ifdef CONFIG_AVM_ENABLE_OTP_SSL_NIFS 28 | 29 | REGISTER_NIF_COLLECTION(otp_ssl, otp_ssl_init, NULL, otp_ssl_nif_get_nif) 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/platforms/esp32/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2022 Davide Bettio 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | set(MAIN_COMPONENT_SRCS 22 | "main.c" 23 | ) 24 | 25 | idf_component_register(SRCS ${MAIN_COMPONENT_SRCS} 26 | REQUIRES "spi_flash" 27 | PRIV_REQUIRES "libatomvm" "avm_sys") 28 | 29 | target_compile_features(${COMPONENT_LIB} INTERFACE c_std_11) 30 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/main/test_erl_sources/test_list_to_binary.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2023 Fred Dushin 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_list_to_binary). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | ok = test_empty_list_to_binary(), 27 | ok. 28 | 29 | test_empty_list_to_binary() -> 30 | <<"">> = erlang:list_to_binary(id([])), 31 | ok. 32 | 33 | id(X) -> 34 | X. 35 | -------------------------------------------------------------------------------- /tests/erlang_tests/absovf.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(absovf). 22 | 23 | -export([start/0, absfunc/2, id/1]). 24 | 25 | start() -> 26 | absfunc(id(-134217728), id(1)). 27 | 28 | absfunc(A, B) -> 29 | try abs(id(A)) of 30 | Value -> Value * B 31 | catch 32 | _:_ -> A + B * 10 33 | end. 34 | 35 | id(A) -> 36 | A. 37 | -------------------------------------------------------------------------------- /tests/erlang_tests/negdiv.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(negdiv). 22 | 23 | -export([start/0, divfunc/2, id/1]). 24 | 25 | start() -> 26 | divfunc(id(-134217728), id(-1)). 27 | 28 | divfunc(A, B) -> 29 | try id(A) div id(B) of 30 | Value -> Value 31 | catch 32 | _:_ -> A - B * 10 33 | end. 34 | 35 | id(A) -> 36 | A. 37 | -------------------------------------------------------------------------------- /tests/erlang_tests/roundbadarg.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(roundbadarg). 22 | 23 | -export([start/0, id/1]). 24 | 25 | start() -> 26 | to_int(id([id(2)])). 27 | 28 | to_int(A) -> 29 | try round(id(A)) of 30 | Res -> Res 31 | catch 32 | error:badarg -> -1; 33 | _:_ -> 1 34 | end. 35 | 36 | id(I) -> 37 | I. 38 | -------------------------------------------------------------------------------- /tests/erlang_tests/truncbadarg.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(truncbadarg). 22 | 23 | -export([start/0, id/1]). 24 | 25 | start() -> 26 | to_int(id([id(2)])). 27 | 28 | to_int(A) -> 29 | try trunc(id(A)) of 30 | Res -> Res 31 | catch 32 | error:badarg -> -1; 33 | _:_ -> 1 34 | end. 35 | 36 | id(I) -> 37 | I. 38 | -------------------------------------------------------------------------------- /src/platforms/esp32/components/avm_builtins/otp_crypto_platform.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2023 by Paul Guyot 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #ifdef CONFIG_AVM_ENABLE_OTP_CRYPTO_NIFS 27 | 28 | REGISTER_NIF_COLLECTION(otp_crypto, NULL, NULL, otp_crypto_nif_get_nif) 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /tests/erlang_tests/guards1.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(guards1). 22 | 23 | -export([start/0, comp/2]). 24 | 25 | start() -> 26 | comp(3, 3) - comp(1, 2) * 2 + comp(3, 1). 27 | 28 | comp(A, B) when A > B -> 29 | 1; 30 | comp(A, B) when A < B -> 31 | 20; 32 | comp(A, B) when A >= B -> 33 | 300; 34 | comp(A, B) when A =< B -> 35 | 1000. 36 | -------------------------------------------------------------------------------- /tests/erlang_tests/if_test.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(if_test). 22 | 23 | -export([start/0, f/2, g/1]). 24 | 25 | start() -> 26 | 5 = f(5, mul) - g(6). 27 | 28 | f(A, Op) -> 29 | if 30 | (Op == mul) and (A > 0) -> A * 2; 31 | (Op == sub) and (A > 0) -> A - 1; 32 | A == 0 -> 1 33 | end. 34 | 35 | g(B) -> 36 | B - 1. 37 | -------------------------------------------------------------------------------- /tests/erlang_tests/ceilbadarg.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(ceilbadarg). 22 | 23 | -export([start/0, id/1, to_int/1]). 24 | 25 | start() -> 26 | to_int(id([id("2")])). 27 | 28 | to_int([A]) -> 29 | try ceil(id(A)) of 30 | Res -> Res 31 | catch 32 | error:badarg -> -1; 33 | _:_ -> 1 34 | end. 35 | 36 | id(I) -> 37 | I. 38 | -------------------------------------------------------------------------------- /tests/erlang_tests/ceilfloat.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(ceilfloat). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | to_int(id(id([-2.5, 0]))). 27 | 28 | to_int(A) -> 29 | try ceil(id(A)) of 30 | B -> B 31 | catch 32 | error:badarg -> -1; 33 | _:_ -> 1 34 | end. 35 | 36 | id([I | _T]) -> id(I); 37 | id(I) -> I. 38 | -------------------------------------------------------------------------------- /tests/erlang_tests/count_char_bs.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2020 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(count_char_bs). 22 | 23 | -export([start/0, count/3]). 24 | 25 | start() -> 26 | count(<<"Hello">>, $l, 0). 27 | 28 | count(<>, A, N) -> 29 | count(Rest, A, N + 1); 30 | count(<<_Byte, Rest/binary>>, A, N) -> 31 | count(Rest, A, N); 32 | count(<<>>, _A, N) -> 33 | N. 34 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/Collectable.Map.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2012-2018 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/commits/v1.7.4/lib/elixir/lib/collectable.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | defimpl Collectable, for: Map do 23 | def into(original) do 24 | fun = fn 25 | map, {:cont, {k, v}} -> :maps.put(k, v, map) 26 | map, :done -> map 27 | _, :halt -> :ok 28 | end 29 | 30 | {original, fun} 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/List.Chars.Float.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2013-2023 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/commits/v1.17.2/lib/elixir/lib/list/chars.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | defimpl List.Chars, for: Float do 23 | def to_charlist(term) do 24 | # TODO: :short option not yet supported right now, so :decimals+:compact should be replaced 25 | :erlang.float_to_list(term, [{:decimals, 17}, :compact]) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /src/platforms/esp32/components/avm_builtins/otp_socket_platform.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2023 by Fred Dushin 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | #ifdef CONFIG_AVM_ENABLE_OTP_SOCKET_NIFS 28 | 29 | REGISTER_NIF_COLLECTION(otp_socket, otp_socket_init, NULL, otp_socket_nif_get_nif) 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/platforms/rp2/src/lib/otp_net_lwip_raw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2023 by Paul Guyot 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #ifndef _OTP_NET_LWIP_RAW_H_ 22 | #define _OTP_NET_LWIP_RAW_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | 30 | const struct Nif *otp_net_nif_get_nif(const char *nifname); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/platforms/stm32/src/lib/jit_stream_flash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2025 by Paul Guyot 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #ifndef AVM_NO_JIT 22 | 23 | #include "context.h" 24 | #include "jit.h" 25 | #include "term.h" 26 | 27 | ModuleNativeEntryPoint jit_stream_entry_point(Context *ctx, term jit_stream) 28 | { 29 | UNUSED(ctx); 30 | UNUSED(jit_stream); 31 | return NULL; 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tests/erlang_tests/count_char.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2017 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(count_char). 22 | 23 | -export([start/0, count/2]). 24 | 25 | start() -> 26 | count("hello", hd("l")). 27 | 28 | count([A | T], C) -> 29 | one_if(A, C) + count(T, C); 30 | count([], _C) -> 31 | 0. 32 | 33 | one_if(A, B) -> 34 | if 35 | A == B -> 1; 36 | true -> 0 37 | end. 38 | -------------------------------------------------------------------------------- /tests/erlang_tests/floorbadarg.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(floorbadarg). 22 | 23 | -export([start/0, id/1, to_int/1]). 24 | 25 | start() -> 26 | to_int(id([id("2")])). 27 | 28 | to_int([A]) -> 29 | try floor(id(A)) of 30 | Res -> Res 31 | catch 32 | error:badarg -> -1; 33 | _:_ -> 1 34 | end. 35 | 36 | id(I) -> 37 | I. 38 | -------------------------------------------------------------------------------- /tests/erlang_tests/floorfloat.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(floorfloat). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | to_int(id(id([-2.5, 0]))). 27 | 28 | to_int(A) -> 29 | try floor(id(A)) of 30 | B -> B 31 | catch 32 | error:badarg -> -1; 33 | _:_ -> 1 34 | end. 35 | 36 | id([I | _T]) -> id(I); 37 | id(I) -> I. 38 | -------------------------------------------------------------------------------- /tests/erlang_tests/roundfloat.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(roundfloat). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | to_int(id(id([-2.5, 0]))). 27 | 28 | to_int(A) -> 29 | try round(id(A)) of 30 | B -> B 31 | catch 32 | error:badarg -> -1; 33 | _:_ -> 1 34 | end. 35 | 36 | id([I | _T]) -> id(I); 37 | id(I) -> I. 38 | -------------------------------------------------------------------------------- /tests/erlang_tests/truncfloat.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2019 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(truncfloat). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | to_int(id(id([-2.5, 0]))). 27 | 28 | to_int(A) -> 29 | try trunc(id(A)) of 30 | B -> B 31 | catch 32 | error:badarg -> -1; 33 | _:_ -> 1 34 | end. 35 | 36 | id([I | _T]) -> id(I); 37 | id(I) -> I. 38 | -------------------------------------------------------------------------------- /examples/erlang/rp2/picow_blink.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2023 Paul Guyot 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(picow_blink). 22 | -export([start/0]). 23 | 24 | % 0 is CYW43 GPIO for on-board led 25 | % This code will not work on Pico 26 | -define(GPIO_NUM, 0). 27 | 28 | start() -> 29 | loop(0). 30 | 31 | loop(N) -> 32 | pico:cyw43_arch_gpio_put(?GPIO_NUM, N), 33 | timer:sleep(1000), 34 | loop((N + 1) rem 2). 35 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/SystemLimitError.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2012-2018 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/tree/v1.7.4/lib/elixir/lib/exception.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | defmodule SystemLimitError do 23 | # This avoids crashing the compiler at build time 24 | @compile {:autoload, false} 25 | 26 | defexception [] 27 | 28 | @impl true 29 | def message(_) do 30 | "a system limit has been reached" 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /src/platforms/esp32/test/main/test_erl_sources/test_esp_timer_get_time.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2025 schnittchen 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_esp_timer_get_time). 22 | 23 | -export([start/0]). 24 | 25 | start() -> 26 | T = esp:timer_get_time(), 27 | test_non_neg_int(T). 28 | 29 | test_non_neg_int(X) when is_integer(X) andalso X >= 0 -> 30 | ok; 31 | test_non_neg_int(_X) -> 32 | error. 33 | -------------------------------------------------------------------------------- /tests/erlang_tests/morelabels.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2017 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(morelabels). 22 | 23 | -export([start/0, rec4/1, willnotbecalled/2]). 24 | 25 | start() -> 26 | rec2(2) + rec3(3). 27 | 28 | rec2(X) -> X + 1. 29 | 30 | rec3(X) -> rec4(X - 1). 31 | 32 | rec4(0) -> 3; 33 | rec4(X) -> rec3(X - 1). 34 | 35 | willnotbecalled(0, O) -> 2 - O; 36 | willnotbecalled(N, O) -> N - O. 37 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_concat_badarg.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_concat_badarg). 22 | 23 | -export([start/0, f/2]). 24 | 25 | start() -> 26 | f("Hello", "World") + f(5, "List"). 27 | 28 | f(A, B) -> 29 | try A ++ B of 30 | L when is_list(L) -> 1; 31 | _L -> 2 32 | catch 33 | error:badarg -> 3; 34 | _:_ -> 4 35 | end. 36 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_func_info2.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_func_info2). 22 | 23 | -export([start/0, id/1, f/1]). 24 | 25 | start() -> 26 | try f(5) of 27 | AnyVal -> AnyVal 28 | catch 29 | error:function_clause -> 1; 30 | _:_ -> 0 31 | end. 32 | 33 | id(X) -> 34 | X. 35 | 36 | f(N) when N > 0 -> 37 | N * f(N - 1). 38 | -------------------------------------------------------------------------------- /libs/jit/rebar.conf: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2020 Paul Guyot 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | {erl_opts, [debug_info]}. 22 | {deps, []}. 23 | {plugins, [rebar3_ex_doc]}. 24 | 25 | {shell, [ 26 | {apps, [jit]} 27 | ]}. 28 | {ex_doc, [ 29 | {version, "0.1.0"}, 30 | {source_url, "https://github.com/atomvm/AtomVM"}, 31 | {extras, []}, 32 | {main, "atomvm"}, 33 | {output, "doc"}, 34 | {api_reference, true} 35 | ]}. 36 | -------------------------------------------------------------------------------- /tests/erlang_tests/test_func_info3.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(test_func_info3). 22 | 23 | -export([start/0, id/1, f/1]). 24 | 25 | start() -> 26 | id(f(id(5))). 27 | 28 | id(X) -> 29 | X. 30 | 31 | f(N) when N > 0 -> 32 | try f(N - 1) of 33 | AnyVal -> N * AnyVal 34 | catch 35 | error:function_clause -> 1; 36 | _:_ -> 0 37 | end. 38 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/Collectable.List.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2012-2018 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/commits/v1.7.4/lib/elixir/lib/collectable.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | defimpl Collectable, for: List do 23 | def into(original) do 24 | fun = fn 25 | list, {:cont, x} -> [x | list] 26 | list, :done -> original ++ :lists.reverse(list) 27 | _, :halt -> :ok 28 | end 29 | 30 | {[], fun} 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /src/platforms/esp32/components/avm_sys/jit_stream_flash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AtomVM. 3 | * 4 | * Copyright 2025 by Paul Guyot 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | */ 20 | 21 | #ifndef AVM_NO_JIT 22 | 23 | #include "context.h" 24 | #include "jit.h" 25 | #include "term.h" 26 | 27 | ModuleNativeEntryPoint jit_stream_entry_point(Context *ctx, term jit_stream) 28 | { 29 | UNUSED(ctx); 30 | UNUSED(jit_stream); 31 | return NULL; 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tests/erlang_tests/make_garbage5.erl: -------------------------------------------------------------------------------- 1 | % 2 | % This file is part of AtomVM. 3 | % 4 | % Copyright 2018 Davide Bettio 5 | % 6 | % Licensed under the Apache License, Version 2.0 (the "License"); 7 | % you may not use this file except in compliance with the License. 8 | % You may obtain a copy of the License at 9 | % 10 | % http://www.apache.org/licenses/LICENSE-2.0 11 | % 12 | % Unless required by applicable law or agreed to in writing, software 13 | % distributed under the License is distributed on an "AS IS" BASIS, 14 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | % See the License for the specific language governing permissions and 16 | % limitations under the License. 17 | % 18 | % SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | % 20 | 21 | -module(make_garbage5). 22 | 23 | -export([start/0, det/1]). 24 | 25 | start() -> 26 | det({{2, 2, 3}, {1, 1, 3}, {2, 0, 1}}). 27 | 28 | det({{A, B}, {C, D}}) -> 29 | A * D - B * C; 30 | det({{A, B, C}, {D, E, F}, {G, H, I}}) -> 31 | A * det({{E, F}, {H, I}}) - B * det({{D, F}, {G, I}}) + C * det({{D, E}, {G, H}}). 32 | -------------------------------------------------------------------------------- /CMakeModules/FindElixir.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2019 Riccardo Binetti 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | if (NOT DEFINED Elixir_FOUND) 22 | find_program(ELIXIRC_PATH elixirc) 23 | 24 | if (ELIXIRC_PATH) 25 | message("Found Elixir") 26 | set(Elixir_FOUND TRUE) 27 | elseif(Elixir_FIND_REQUIRED) 28 | message(FATAL_ERROR "Elixir compiler not found") 29 | set(Elixir_FOUND FALSE) 30 | endif() 31 | endif() 32 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/CondClauseError.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of elixir-lang. 3 | # 4 | # Copyright 2012-2018 Elixir Contributors 5 | # https://github.com/elixir-lang/elixir/tree/v1.7.4/lib/elixir/lib/exception.ex 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # SPDX-License-Identifier: Apache-2.0 20 | # 21 | 22 | defmodule CondClauseError do 23 | # This avoids crashing the compiler at build time 24 | @compile {:autoload, false} 25 | 26 | defexception [] 27 | 28 | @impl true 29 | def message(_exception) do 30 | "no cond clause evaluated to a true value" 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /libs/exavmlib/lib/Module.ex: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of AtomVM. 3 | # 4 | # Copyright 2021 Davide Bettio 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later 19 | # 20 | 21 | defmodule Module do 22 | @compile {:autoload, false} 23 | 24 | def concat(a, b) when is_atom(a) and is_atom(b) do 25 | a_string = :erlang.atom_to_binary(a, :latin1) 26 | <<"Elixir.", b_string::binary>> = :erlang.atom_to_binary(b, :latin1) 27 | 28 | :erlang.binary_to_atom(a_string <> "." <> b_string, :latin1) 29 | end 30 | end 31 | --------------------------------------------------------------------------------