If it is not possible to create a timer in timer_create(),
then the timer_obj associated with the timer must be freed.
However, the address of the pointer was mistakenly being
passed to k_mem_slab_free() rather than simply the
the pointer.
This caused a crash in tests which can easily be avoided
by passing the pointer rather than the address of the
pointer.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Remove deprecated Kconfig options. These were given an extra
release cycle of soak time, but generally were OK to remove
after Zephyr v4.0.0 was released.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
MAX_PTHREAD_COUNT was deprecated in favour of
POSIX_THREAD_THREADS_MAX prior to v3.7.0.
Use CONFIG_POSIX_THREAD_THREADS_MAX going forward.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
When a queue has been unlinked but not removed the name pointer is set to
NULL. The queue is still in the list when adding new queues and the name
pointer is passed to strcmp.
Signed-off-by: Jari Tervonen <jari.tervonen@nordicsemi.no>
With MMU being converted to a non-user-configurable option, we can
rely on that exclusively to know whether arch_mem_map() and
arch_mem_unmap() are available and we can remove the workarounds
in POSIX at the Kconfig level.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add a POSIX Option Group called XSI_REALTIME (with Kconfig
option CONFIG_XSI_REALTIME).
When XSI_REALTIME is selected (or when required POSIX Options
are enabled), define _XOPEN_REALTIME to be something other
than -1 (_XOPEN_VERSION seemed appropriate).
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Since XSI is composed of several distinct POSIX Option Groups
split Kconfig.xsi into separate files - one for each Option
Group.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
For the REALTIME_MINIMAL Application Environment Profile, uncomment
the POSIX_MEMLOCK, POSIX_MEMLOCK_RANGE, POSIX_MEMORY_PROTECTION,
POSIX_MAPPED_FILES, and POSIX_SHARED_MEMORY_OBJECTS options.
These should have been uncommented back when Kconfig options for
those features were added, so this can probably be called a
Kconfig bug.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Although it's quite unlikely that we will see shared memory
objects in practice that are greater than 2GiB, there is a
possibility of integer overflow when comparing intptr_t and
size_t, since the former is signed and the latter is unsigned.
Explicitly check to ensure that the addend is less than
INTPTR_MAX before subtraction.
This fixes CID 487734
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The nsem_list_unlock() static inline function looks as though it
was designed to always ignore the return value of
k_mutex_unlock(), presumably for performance reasons.
A quick audit of the code looks as though the call should
always succeed.
Prepend (void) to the call to avoid the coverity defect in the
future.
CID 444386
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Utilize a code spell-checking tool to scan for and correct spelling errors
in various files within the `lib` directory.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Originally, when the POSIX_SHARED_MEMORY_OBJECTS option was
added, the O_TRUNC flag was not consistently available.
Now that it is consistently available, ensure it is used
within the shm_open() function.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Boot time initialization functions and data used there must be
available at boot. With demand paging, these may not exist in
memory when they are being used, resulting in page faults.
So pin these functions and data in linker sections to make
sure they are in memory at boot time.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The Xtensa linker scripts seem to be injecting syntax errors when
MMU is enabled. Disable the implication in Kconfig.mem for Xtensa
until linker issues are resolved.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Declare _POSIX_C_SOURCE in a consistent way for both the
posix/options library as well as the tests/posix/fs
testsuite.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Do not set TC_PROVIDES_POSIX_C_LANG_SUPPORT_R as the default in
lib/posix/options/Kconfig.c_lang_r . TC_PROVIDES options are
only intended to be set by C libraries that implement parts of
the POSIX standard.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Oddly, even though CI passed when the file_system_r change was
merged, now CI has encountered a build error because MIN() was
not defined.
Include `<zephyr/sys/util.h>` to pull in the definition.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
A copy-paste error propogated this typo to a few different
Kconfig files.
Correct 'informnation' to 'information'.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Move the functionality of POSIX_FILE_SYSTEM_R to its own
compilation unit and remove the unnecessary dependency on
POSIX_FILE_SYSTEM.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Many out of the POSIX subsystem configs are enabled automatically
when merely CONFIG_POSIX_API is enabled, which is a prerequisite for
many networking samples. This causes a massive experimental warning
printout when building with warnings enabled.
Since the new POSIX Kconfig configuration options are already present
in Zephyr for 2 release cycles and seem settled, I suggest we move
them out of experimental phase.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
These functions can be used to join pthreads in a non-standard way.
The function pthread_tryjoin will not block and simply test whether the
thread has exited already. The function pthread_timed_join will only block
until the specified time. The functions are wrappers for calling the
k_thread_join with timeout K_NO_WAIT and with a specific timeout as opposed
to calling it with K_FOREVER.
Signed-off-by: Cla Galliard <clamattia@gmail.com>
As k_sleep returns int32_t, there is a possibility for integer overflow
during conversion from milliseconds to nanoseconds.
Signed-off-by: Ilya Tagunov <Ilya.Tagunov@synopsys.com>
Nanosecond time calculation overflows if the libc has 32-bit time_t.
One such libc is the classic ARC MWDT one, but there might be others.
Signed-off-by: Ilya Tagunov <Ilya.Tagunov@synopsys.com>
For SIGEV_SIGNAL, the function zephyr_timer_wrapper() is the handler
between kernel and posix layer.
Here, for one-time timer, reload is equal to 0 and function returns.
As a consequence, handler function was never called.
Signed-off-by: Noemie Gillet <ngillet@sequans.com>
Several help prompts for non-user-selectable Kconfig options
included the phrase "select 'y' here", which does not make
any sense in this situation.
Adjust the help sections to use more appropriate language.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Move the implementation of zsock_select() to zvfs_select(). This
allows other types of file descriptors to also make use of
select() functionality even when the network subsystem is not
enabled.
Additionally, it partially removes a dependency cycle between
posix and networking by moving functionality into a mutual
dependency.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Move the implementation of zsock_poll to zvfs_poll. This allows
other types of file descriptors to also make use of poll()
functionality even when the network subsystem is not enabled.
Additionally, it partially removes a dependency cycle between
posix and networking by moving functionality into a mutual
dependency.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add pread() and pwrite() implementations, which are nearly
identical to read() and write() but differ in that they do not
update the file-descriptor offset and instead read from a
specific file offset.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The POSIX_DEVICE_IO Option Group requires a number of c89
functions mainly from stdio.h .
Namely,
clearerr(), fclose(), feof(), ferror(), fflush(), fetc(),
fgets(), fprintf(), fputc(), fputs(), fread(), freopen(),
fscanf(), fwrite(), getc(), getchar(), gets(), perror(),
printf(), putc(), putchar(), puts(), scanf(), setbuf(),
setvbuf(), ungetc(), vfprintf(), vfscanf(), vfprintf(), and
vscanf().
Additionally, symbols stdin, stdout, and stderr should be
provided.
These should be provided by any conformant C library
(not by the POSIX API).
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Based on Andy's talk at eoss 2024, use the sys/sem.h api instead
of the spinlock.h api to synchronize pooled elements since it
has minimal overhead like semaphores but also works from
userspace.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
We need to add _POSIX_C_SOURCE to this file as it uses POSIX values from
limits.h including IOV_MAX, CHILD_MAX and ARG_MAX.
Signed-off-by: Keith Packard <keithp@keithp.com>
options/fs.c and options/timer.c both use POSIX-only functions. To ensure
those symbols are visible from the underlying C library, define
_POSIX_C_SOURCE.
Signed-off-by: Keith Packard <keithp@keithp.com>