mirror of
https://github.com/Dasharo/zephyr.git
synced 2026-03-06 14:57:20 -08:00
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.
Most of these changes were automated using coccinelle with the following
script:
@@
@@
- void
+ int
main(...) {
...
- return;
+ return 0;
...
}
Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.
Signed-off-by: Keith Packard <keithp@keithp.com>
.. _system_hashmap:
System Hashmap
##############
Overview
********
This is a simple example that repeatedly
* inserts up to ``CONFIG_TEST_LIB_HASH_MAP_MAX_ENTRIES``
* replaces up to the same number that were previously inserted
* removes all previously inserted keys
Building
********
This application can be built on native_posix as follows:
.. zephyr-app-commands::
:zephyr-app: samples/basic/hash_map
:host-os: unix
:board: native_posix
:goals: build
:compact:
To build for another board, change "native_posix" above to that board's name.
Additionally, it is possible to use one of the other Hashmap implementations by specifying
* ``CONFIG_SYS_HASH_MAP_CHOICE_SC=y`` (Separate Chaining)
* ``CONFIG_SYS_HASH_MAP_CHOICE_OA_LP=y`` (Open Addressing / Linear Probe)
* ``CONFIG_SYS_HASH_MAP_CHOICE_CXX=y`` (C Wrapper around the C++ ``std::unordered_map``)
To stress the Hashmap implementation, adjust ``CONFIG_TEST_LIB_HASH_MAP_MAX_ENTRIES``.
Running
*******
Run ``build/zephyr/zephyr.exe``
Sample Output
*************
.. code-block:: console
System Hashmap sample
[00:00:11.000,000] <inf> hashmap_sample: n_insert: 118200 n_remove: 295500 n_replace: 329061 n_miss: 0 n_error: 0 max_size: 118200
[00:00:11.010,000] <inf> hashmap_sample: success