The ISO C function time() is not specified to set the global
errno variable, so remove that in case there are side-effects.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Added support for mixed array types in JSON by introducing a new type -
json_mixed_arr_descr. Added APIs for mixed array type parsing and
encoding.
Signed-off-by: Sanjay Vallimanalan <sanjay@linumiz.com>
Add a new macro NET_BUF_POOL_VAR_ALIGN_DEFINE() which can be
used to create a pool with aligned data where both the start
of the data and the length of the data is aligned.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Some toolchains may define CLOCK_REALTIME and
CLOCK_MONOTONIC in their libc headers
with values that differ from Zephyr's internal
SYS_CLOCK_REALTIME and SYS_CLOCK_MONOTONIC.
To ensure consistent behavior across all boards and
toolchains, Introduce a helper function to map
CLOCK_REALTIME and CLOCK_MONOTONIC to Zephyr's internal
clock IDs (SYS_CLOCK_REALTIME and SYS_CLOCK_MONOTONIC).
This prevents mismatched clock IDs being passed to
the kernel, avoiding invalid clockid errors when using
functions like clock_gettime().
Signed-off-by: Mohamed Moawad <moawad@synopsys.com>
After removing NATIVE_APPLICATION, only NATIVE_LIBRARY is
possible with NATIVE_BUILD.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
CONFIG_NATIVE_APPLICATION, which represents the way in which
native_posix and its kin were built, was deprecated in 4.1 after the
introduction of native_sim and CONFIG_NATIVE_LIBRARY.
We remove support for it now for 4.3.
Let's remove the kconfig option and all dependencies in the kconfig
tree.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Fix for CID 529870, where Coverity found an issue where `timespec.tv_sec`
is never greater than `UINT64_MAX / NSEC_PER_SEC` (18446744073).
This is naturally true when `time_t` is only 32-bit, which is actually
never the case for any Zephyr platform aside from `native_sim/native/32`.
When `time_t` is a signed 64-bit value, at some point in the future, but
maybe not in our lifetimes, `timespec.tv_sec` could exceed 18446744073,
since `INT64_MAX > UINT64_MAX / NSEC_PER_SEC`.
We should not see coverity issues errors like this in the future, once we
have a consistent `time_t` representation across all Zephyr platforms.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
A segmentation fault occurs when a zero initialized struct with a string
field (JSON_TOK_STRING) is encoded. Encode a string null pointer as an
empty JSON string "".
Signed-off-by: Christoph Winklhofer <cj.winklhofer@gmail.com>
Some of the locks are created in supervisor mode (i.e. stdout one),
but should be accessed from user mode too. Unfortunately, there is
no way to distinguish these locks, so grant the access to all of them
as the actual reads and writes should end up as syscalls anyway.
Signed-off-by: Ilya Tagunov <Ilya.Tagunov@synopsys.com>
The ARC MWDT C library puts some constructors into .ctors section
to initialize its internal stdio locks. Enable the initializers
to make sure these constructors are actually executed.
Signed-off-by: Ilya Tagunov <Ilya.Tagunov@synopsys.com>
When built with the minimal libc while using POSIX clocks, Zephyr
compilation breaks with "error: unknown type name 'clockid_t'." Use
int instead of clockid_t to eliminate the dependency.
Suggested-by: Chris Friedt <cfriedt@tenstorrent.com>
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
The allocated_bytes were missing the allocation metadata. Because of that
the sum of free_bytes and allocated_bytes doesn't remain constant after
each allocation. This convention doesn't match glibc's behavior. This
commit changes the chunksz_to_bytes function to include the metadata in the
calculation. The analysis of the mallinfo2 function from glibc has been
done in #92392 Pull Request.
Signed-off-by: Krzysztof Sychla <ksychla@antmicro.com>
This was caught by UBSAN:
zvfs_select.c:70:2: runtime error: left shift of 1 by 31 places
cannot be represented in type 'int'
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Removed duplicate assignment of ctx->executing under
CONFIG_SMF_ANCESTOR_SUPPORT.
Also replaced #ifndef with #ifdef to align with the positive logic
used elsewhere in this file.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
The compiler requires that much of the C library be built without using LTO
so that various symbols are available for use by generated code, including
things like memset and memcpy.
Add the "prohibit_lto" CMake target compiler property to avoid LTO when
activated.
Signed-off-by: Matthias Plöger <matthias.ploeger@phoenixcontact.com>
Update CMakeLists.txt to conditionally include address translation
support based on Kconfig options.
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Add NXP-specific address translation table to support memory-mapped
translations between driver and device.
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
There are SoCs that have different memory maps for device and driver.
Therefore the shared memory between them has different values and we
need to convert the addresses.
This commit introduces address translation support for OpenAMP:
- implements the address translation functions;
- returns the I/O operations used for address translation.
The ops can be used in Libmetal (see metal_io_init()).
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Coverity regularly raised a CID with every release that it found
`sizeof(char **)` confusing and somehow nonportable.
With every release, it needed to be marked as a false positive.
Change `sizeof(char **)` to `sizeof(void *)` to silence the
CID warnings.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Remove using `swap()` which was using VLA and replace it
with `byteswp()`.
Reduce the scope of local variables in `heapify_up/down` to
the smallest necessary block.
Replace `while(true)` loop in `heapify_down()` with a bounded `for`
loop.
Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
Implement NXP-specific support for the remote processor
resource table, including custom definitions and initialization
logic to meet NXP's communication requirements.
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Modify the build system to conditionally compile
vendor-specific resource table support based on configuration.
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Introduce macros to define initialization
routines for OpenAMP resource table entries.
This will allow to extend the default OpenAMP
resource table with vendor-specific data structures.
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Enhance flexibility by allowing vendors to define their own
resource tables. This is achieved by moving the vdev and vring
functions into the source file, requiring each vendor to
implement these functions within their specific resource
table definitions.
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Switching to void allows greater flexibility in supporting
vendor-specific resource tables.
This change reverts commit 39863b66bd, and adds some fixes.
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Use the newly added sys_clock API in lib/os for
* clock_gettime()
* clock_settime()
* clock_nanosleep() and nanosleep()
* gettimeofday()
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Use the implementation of time() from the common libc, since there
it no longer pulls in POSIX.
Use is implied for minimal, newlib, and picolibc, and selected
for IAR.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Remove POSIX clock_gettime() from the common libc time implementation,
since POSIX should not be a dependency for ISO C.
Instead, use the newly added lib/os sys_clock API.
Specifically, sys_clock_gettime().
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Additional entries for the sys_clock API, comprised of:
* sys_clock_gettime()
* sys_clock_settime()
* sys_clock_nanosleep()
along with the constants
* SYS_CLOCK_REALTIME
* SYS_CLOCK_MONOTONIC
* SYS_TIMER_ABSTIME
The primary motivation for this API is so that libc and other
libraries have a familiar-enough API to reach to when POSIX
is not available, since POSIX is optional in Zephyr.
By adding this API to lib/os, we also eliminate dependency cycles
between libc and posix, as lib/os is a mutual dependency.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Previously, log messages would generate warnings (escalated to errors
in CI) when CONFIG_TIMEOUT_64BIT=n.
For example,
```
west build -p auto -b qemu_cortex_m0 -t run tests/posix/timers/ \
-- -DCONFIG_TIMEOUT_64BIT=n
..
warning: format '%llx' expects argument of type \
'long long unsigned int', but argument 3 has type 'k_ticks_t' \
{aka 'unsigned int'}
```
Use portable print specifiers and cast the argument to int64_t.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Update the str_out function signature to match the expected
cbprintf_cb_local type:
typedef int (*cbprintf_cb_local)(int c, void *ctx);
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
See Discussion https://github.com/zephyrproject-rtos/zephyr/discussions/83659
for information about the purpose of this change.
Modifies run actions of hierarchical state machines
to return a value indicating if the event was handled
by the run action or should be propagated up to the
parent run action. Flat state machines are not affected,
and their run action returns void.
smf_set_handled() has been removed and replaced by
this return value. smf_set_state() will not propagate
events regardless of the return value as the transition
is considered to have occurred.
Documentation, tests, samples, has been updated.
USB-C and hawkBit use SMF and have been updated to use
the new return codes.
Signed-off-by: Glenn Andrews <glenn.andrews.42@gmail.com>
The hex2char() calls in bin2hex() can never fail since buf[i] >> 4
and buf[i] & 0xf always produce values in range 0-15.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Add a dedicated symbol for including the POSIX system headers path
directly into the include path, enabling (for example)
`#include <time.h>` instead of `#include <zephyr/posix/time.h>`.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Introduce a binary min-heap implementation as a generic data structure
for use in kernel and application code. A min-heap always maintains
the smallest element at the root, making insertion and removal of the
minimum element efficient (O(log n)).
The API allows both static and dynamic initialization, supports custom
comparators.
Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
Updates the heap code to ensure that when converting the requested
number of bytes to chunks, we do not return a value that exceeds
the number of chunks in the heap.
Fixes#90306
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>