When CONFIG_LOG_USE_TAGGED_ARGUMENTS is enabled, and
CONFIG_CBPRINTF_COMPLETE is also enabled, we should not be
blindly skipping tags when processing the tagged package
for output. The issue is that if there is a "%%" in
the format string, the specifier is considered invalid but
the code blindly skips ahead in the argument list as if
it is a valid specifier (think "%s"), which resulting in
the next valid specifier using incorrect argument in
the list. So fix it by skipping ahead if and only if
the specifier is not invalid.
Fixes#68271
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This change mitigates the following cmake warning
No SOURCES given to Zephyr library: lib__posix__options
without needing to have a separate interface library
(as we do not need private headers exposed).
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Newlib doesn't have Zephyr support, so we need to define these functions
when the application doesn't ask for the right level of POSIX support.
Signed-off-by: Keith Packard <keithp@keithp.com>
Implement `sched_rr_get_interval()` POSIX APIs
as a part of PSE53 `_POSIX_PRIORITY_SCHEDULING` option group.
Functions is actually placeholders and just return `ENOSYS`
since Zephyr does not yet support processes or process scheduling.
signed-off-by: Gaetan Perrot <gaetanperrotpro@gmail.com>
In case the read index points to the end of the packet buffer and thus
wraps around, we must not invalidate the cache, otherwise we draw
outside of the lines and purge data outside of our responsibility.
Signed-off-by: Patrick Wildt <pwildt@google.com>
The CONFIG_APP_LINK_WITH_POSIX_SUBSYS option was originally
present so that internal POSIX implementation headers would be
on the include path.
There is no implicit need for any app or library to include
private POSIX headers. Instead, the standard POSIX API should
be used.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Previously, the POSIX shell utilities were intermixed with the
POSIX API implementation.
The POSIX shell utilities only depend on the public POSIX API,
so it makes sense to keep them in a separate subdirectory.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
add resource enumeration and acpi method shell commands such as
retrieve mmio and interrupt resources.
Signed-off-by: Najumon B.A <najumon.ba@intel.com>
Implement `sched_setparam()` and `sched_setscheduler()` POSIX APIs
as a part of PSE53 `_POSIX_PRIORITY_SCHEDULING` option group.
Both functions are actually placeholders and just return `ENOSYS`
since Zephyr does not yet support processes or process scheduling.
signed-off-by: Gaetan Perrot <gaetanperrotpro@gmail.com>
The patch introduces basic implementation of sysconf() function.
It's based on macro - that means that every function call is resolved
at compile time - and is not fully complient with POSIX standard
(the errno value is not handled and passing invalid name argument
results in compilation error). Treat this commit as a starting point
for proper sysconf() implementation. The one introduced in the patch
could stay as a defult implementation.
sysconf() documentation:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.htmlhttps://man7.org/linux/man-pages/man3/sysconf.3.htmlFixes#56670
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Previously timer.c was only built with CONFIG_POSIX_CLOCK=y even
though it has had its own Kconfig symbol (CONFIG_TIMER) for a
very long time.
Make POSIX_CLOCK imply TIMER rather than control whether it is
built, and adjust Kconfig / CMake as necessary.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Two functions can be used with relative ease to convert between
Zephyr and POSIX priorities and policies. Namely,
uint32_t zephyr_to_posix_priority(int32_t z_prio, int *policy)
int32_t posix_to_zephyr_priority(uint32_t priority, int policy)
These are not necessarily public API, but they helped with the
POSIX Philosophers Sample, which is in a subsequent commit.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
* initialize posix_thread and __pthread_cleanup ptrs to NULL
* check ret is zero before finalizing a thread in pthread_cancel()
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
This was necessary to get Picolibc to expose the whole Zephyr C library
API, but current versions of the SDK use a version of Picolibc with
built-in Zephyr support.
Signed-off-by: Keith Packard <keithp@keithp.com>
Create getter and setter functions for setting internal pthread
states to READY, RUN, or DONE queues.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
There may be race conditions when calling to_posix_thread()
from multiple threads.
Ensuing that the pthread pool lock is held when
to_posix_thread() is called will prevent those races.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Rather than shadowing most of the fields from pthread_attr_t
(struct posix_thread_attr) inside of struct posix_thread, just
embed the structure itself.
Additionally, use pthread_attr_init() to allocate a thread
stack and pthread_attr_destroy() to destroy a thread stack,
dramatically simplifying pthread_create().
A fair bit of rework was needed already to mitigate bitrot
issues in the testsuite. More should probably be done later.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
The default pthread cancellation type is deferred.
Check that the canceltype is asynchronous (with
respect to cancellation points) before cancelling
a thread.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Add a small wrapper to check if a pthread_attr_t has been
properly initialized (i.e. ready to pass to
pthread_create()).
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Export the minimal set of ztest_test_* symbols to llexts so that the
zassert_* macros can be used by the extension code to affect test
execution. Calling these also requires vprintk() to be exported.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
The function was the last missing piece of the `_POSIX_MESSAGE_PASSING`
option group. Due to lack of signal subsystem in the Zephyr RTOS
the `sigev_notify` member of the `sigevent` structure that describes
the notification cannot be set to `SIGEV_SIGNAL` - this notification
type is not implemented, the function will return -1 and set `errno`
to `ENOSYS`.
`mq_notify` documentation:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_notify.htmlFixes#66958
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add a top-level menu to prevent POSIX API options from
cluttering the menuconfig view under
"Additional libraries".
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Previously, Zephyr's POSIX API did not differentiate between
deferred and asynchronous pthread cancellation. In fact all
pthread cancellation was asynchronous. According to the spec,
all pthreads should be created with deferred cancellation by
default.
Note: PTHREAD_CANCEL_ASYNCHRONOUS means cancel asynchronously
with respect to cancellation points (but synchronously with
respect to the thread that callse pthread_cancel(), which is
perhaps unintuitive).
The POSIX timer relied on this non-standard convention.
Oddly, this change prevents what would have otherwise been a
regression that would have been caused by fixing pthread
behaviour (in a separate commit).
We are effectively uncovering bugs which were probably always
present in the pthread.c and timer.c implementations going
back quite a few years.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
There is no requirement that says e.g. CLOCK_REALTIME cannot be
used for timer_create(). In fact, the spec explicitly requires
it. It might not be ideal, but users should still be able to
use it.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Use the existing `is_posix_policy_prio_valid()` function to
verify the POSIX's priority in the conversion functions.
Changed the `priority` arg of `is_posix_policy_prio_valid` to
`int` since that is the output of `sched_get_priority_min` &
`sched_get_priority_max`.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Made the conversion functions non-static and added ztests for
them to make sure that they work across the full range of
Zephyr priorities.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Changed the variable type of the priority in the args and the
return type of the conversion functions to `int`, as both
Zephyr's priority & POSIX's `sched_priority` has type `int`.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
If `z_prio` is negative and we want to make sure that it is
within `[-CONFIG_NUM_COOP_PRIORITIES, -1]`, we should invert
its sign and make sure that it is `<=`
`CONFIG_NUM_COOP_PRIORITIES` instead of `<`.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Added a top level `posix` shell command for other POSIX
commands. Currently only `uname` is supported.
New POSIX commands can be added by including the
`posix_shell.h` header and use the `POSIX_CMD_ADD` helper
macro.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Relocate the `uname` shell implementation from uname sample, so
that it can be reused by other application and the uname sample
only uses POSIX APIs.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
The POSIX standard doesn't specify if the argument to store
previous state/type in
`pthread_setcancelstate`/`pthread_setcancelstate` can be
`NULL`, but threading implementations in Linux & Apache NuttX
permit the arguments to be `NULL`.
This commit changes Zephyr's implementation to mimic that of
Linux & NuttX, so that user do not get caught off-guard by
NULL pointer dereferencing when porting code over from those
OSes.
Updated test accordingly.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Make sure that the POSIX clock base is reset after every
testsuite so that the initial time is the same for every test.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Instead of relying on a fault occurring when NULL
parameters are passed in, explicitly check and return
EINVAL.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Initial implementation of `sched_getparam()` and `sched_getscheduler()`
POSIX APIs as a part of PSE53 `_POSIX_PRIORITY_SCHEDULING` option group.
Both functions are actually placeholders and just return `ENOSYS`
since Zephyr does not yet support processes or process scheduling.
Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
- Regroup refcount decrement and semaphore destruction by making the
linked state into a counted reference for it. This allows for
simplifying the code and cleanly adding a few assertions in a common
location.
- Remove redundant initialization to NULL on memory about to be freed
and local pointer in nsem_cleanup().
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Improve a depends on the host libC.
It is technically correct, but NATIVE_LIBC
is shorter and clearer than "ARCH_POSIX && EXTERNAL_LIBC"
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Let's try to use the host unistd.h when building with
the host library only, instead of assuming
that the native boards are always built with it.
This fixes a build error when building for native boards
using minimal libc.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
We try to implement Zephyr's POSIX API as regular library
functions, so remove the __syscall annotation from
clock_gettime() and implement the syscall portion of it under
the hood.
This also adds a bit of a micro-optimization in that
we can do a lot of processing outside of the system call.
In fact, processing CLOCK_MONOTONIC likely does not
require any syscall other than k_uptime_ticks().
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
The clock_settime() function should not accept an input timespec
with nanosecond values < 0 or >= NSEC_PER_SEC.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Added CRC4 and CRC4_TI to the supported crc_types[] array.
On some SoCs, like ESP32-S3, missing values can cause hardfaults
due to attempts to access the zero address.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
This makes sure the heap posix_timer_slab provides objects aligned
compatible with the type timer_obj. It was previously set to align at 4
bytes. One example where this failed was on the SPARC which requires
access to int64_t to be 8-byte aligned.
In particular, struct timer_obj contains fields of type k_timer_t and
struct _timeout.
With this commit we now get the information on required alignment for
struct timer_obj from the compiler by using __alignof__().
Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
There was some discussion about whether it was suitable to have
an architecture-specific workaround in mqueue.c after that
workaround was copied to a different source file in a PR.
The original issue was that newlib and picolibc declare mode_t
to be unsigned short instead of unsigned long when __svr4__
is not defined along with __sparc__. This is specifically
impactful, because va_arg() deals (mainly) with 32-bit and
64-bit values that are all naturally aligned to 4 bytes.
#if defined(__sparc__) && !defined(__sparc_v9__)
#ifdef __svr4__
typedef unsigned long __mode_t;
#else
typedef unsigned short __mode_t;
#endif
A uint16_t is naturally aligned to 2 bytes, so not only would
a 16-bit mode_t be corrupted, it would also generate a warning
with recent gcc versions which is promoted to error (rightfully
so) when run through CI.
mqueue.c:61:35: error: 'mode_t' {aka 'short unsigned int'} is
promoted to 'int' when passed through '...' [-Werror]
61 | mode = va_arg(va, mode_t);
Instead of using an architecture-specific workaround, simply
add a build assert that the size of mode_t is less than or
equal to the size of an int, and use an int to retrieve it
via va_arg().
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Fri Dec 29 10:06:44 2023 -0500
#
# On branch posix-mqueue-always-use-int-for-mode-t-va-arg
# Changes to be committed:
# modified: lib/posix/mqueue.c
# modified: tests/posix/common/testcase.yaml
#
Use the __fallthrough directive on the switch fallthrough case and drop
the comment instead. This informs the compiler that the fallthrough is
intentional and silence any possible warning about it.
Drop the not reached case as I think that that part can actually be
reached since there are breaks in some of the cases.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
In theory one may want to build the POSIX compability shim
with a different C library than one provided with Zephyr,
so let's not prevent it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This reverts commit 6342aa3cc0.
This commit should never have been merged.
Apart from the fact that this change was rejected in previous
review,
this change is wrong, for 2 reasons:
1. The POSIX_API (POSIX compatibility shim) cannot be
built if the host libC is used.
2. The Zephyr libC CMake files were guarded so they
would not be dragged when CONFIG_EXTERNAL_LIBC was selected.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
* remove unneeded line of code that duplicated the first part
of the SYS_SLIST_FOR_EACH_NODE() expansion.
* return NULL if pthread_self() is not a valid pthread
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
When package contained RO string positions and flag indicates that
they shall not be kept, length was miscalculated which could lead
to failures (e.g. memory corruption).
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Previously it was not possible to link to Zephyr's
POSIX API under lib/posix when building with
`CONFIG_EXTERNAL_LIBC=y`.
This small change allows that to work as expected.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
A previous size optimization capped the pthread_attr_t stacksize
property at 65536. Some Zephyr users felt that was not large
enough for specific use cases.
Modify struct pthread_attr to support large stack sizes by
default with the flexibility to allow users to vary the number
of bits used for both stacksizes and guardsizes.
The default guardsize remains zero sinze Zephyr's stack
allocators already pad stacks with a guard area based on other
config parameters, and since Zephyr is already designed to
support both SW and HW stack protection at the kernel layer.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Move various utilities out of lib into own folder for better assignement
and management in the maintainer file. lib/os has become another dumping
ground for everything and it the Kconfig and contents in that folder
became difficult to manage, configure and test.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Implement pthread_getguardsize() and pthread_setguardsize().
pthread_getguardsize() and pthread_setguardsize() are required
by the POSIX_THREADS_EXT Option Group as detailed in Section
E.1 of IEEE-1003.1-2017. However, they were formerly part of
XSI_THREADS_EXT.
The XSI_THREADS_EXT Option Group was required for PSE51, PSE52,
PSE53, and PSE54 conformance.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
This change reduces the space occupied by struct pthread_attr
which is the internal type used for pthread_attr_t.
We cap the stack size at 16 bits (so up to 65536 bytes) and
since a stack size of 0 is invalid, we can encode the stack
size by simply subtracting 1 or adding 1 when setting or
getting.
The schedpolicy is capped at 2 bits and initialized,
cancellable, and detached are given 1 bit.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Use the new HEAP_MEM_POOL_ADD_SIZE_ prefix to construct a minimum
requirement for posix message queue usage. This way we can remove the
"special case" default values from the HEAP_MEM_POOL_SIZE Kconfig
definition.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
All x86 boards have so far set a custom heap memory pool size because of
their dependency on ACPI. It makes more sense to introduce a new
ACPI-specific option, utilizing the recently added
HEAP_MEM_POOL_ADD_SIZE_ Kconfig option prefix, and adjust the default
value as necessary for each board.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add function walking though all DMAR subtables, at the moment only
first subtable is taking into account, which causes bugs for some
boards.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Since pthread_once() is both the initializer and executor of
pthread_once_t, it can have maximally two states. Since the
implementation in Zephyr previously aimed to maximize libc
compatibility, we opted to use the definition of pthread_once_t
from newlib, which is a structure with two ints.
It does not make sense to use 64 bits to manage 2 possible
states. The control for that should effectively be a bool.
We maintain compatibility with newlib by asserting (at build
time), that newlib's pthread_once_t is larger than Zephyr's
new struct pthread_once (which just contains a bool).
This allows us to delete the non-standard pthread_key.h
header file (finally).
Reuse the pthread_pool_lock in order to synchronize the related
init function (so that it is only called maximally once from any
thread). The spinlock is only used to test the state and the
init function is not called with the spinlock held.
The alternative was to use an atomic inside of
struct pthread_once. But again, that could be up to 64-bits with
Zephyr's atomics implementation.
Ideally we would use C11 generics or something to support atomics
on 8, 16, 32, and 64-bit primitives.
Lastly, also update declarations for C11 threads as they mostly
mirror our pthread implementation.
This needed to be done as a single commit in order to ensure
continuity of build.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Split heap-validate.c into smaller chunks. We have been adding all kind
of new APIs under this file and building it unconditionally whether
those APIs are needed/used or not. Many of those APIs have nothing to do
with the validation part.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The string "" is of type '(const char *)', so add a cast over to
'(char *)' to clean up source code.
Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
pthread_sigmask() is required by the POSIX_THREADS_BASE
Option Group as detailed in Section E.1 of IEEE-1003.1-2017.
The POSIX_THREADS_BASE Option Group is required for PSE51,
PSE52, PSE53, and PSE54 conformance, and is otherwise mandatory
for any POSIX conforming system as per Section A.2.1.3 of
IEEE-1003-1.2017.
Currently, setting a pthread signal mask has no effect.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
When CONFIG_POSIX_SIGNAL=n, default CONFIG_POSIX_RTSIG_MAX to
0 so that the `sigset_t` type can be defined.
Also define RTSIG_MAX.
This allows native_sim and other platforms to build without
error.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Export some symbols for loadable modules. Also add an
EXPORT_SYSCALL() helper macro for exporting system calls by their
official names.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
To align with other supported POSIX features, add logging to
pthread key to provide better error reporting and diagnostics.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
pthread_cleanup_push() and pthread_cleanup_pop() are required
by the POSIX_THREADS_BASE Option Group as detailed in Section
E.1 of IEEE-1003.1-2017.
The POSIX_THREADS_BASE Option Group is required for PSE51,
PSE52, PSE53, and PSE54 conformance, and is otherwise mandatory
for any POSIX conforming system as per Section A.2.1.3 of
IEEE-1003-1.2017.
In this change, we require the addition of a dedicated
pthread_key_t that will not be available for applilcation usage.
Rather than including that as part of
CONFIG_MAX_PTHREAD_KEY_COUNT, we increase the storage by 1 in
order to be least invasive from the application perspective.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Initialize the variable to zero. I don't think there is any way
out of this function without it being initialized, so IMHO it's
a false positive.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Zephyr must support all functionality of the XSI_THREADS_EXT
subprofiling option group in order to claim it supports that
subprofiling option group.
The XSI_THREADS_EXT option group is critical to be able to
run POSIX threads with statically allocated thread stacks, which
has been a feature of the implementation since it was initially
added.
The pthread_getconcurrency() and pthread_setconcurrency()
functions are the only remaining, unimplemented functions of
the XSI_THREADS_EXT option group.
Implement pthread_getconcurrency() and pthread_setconcurrency()
via the more "posixly correct" interpretation of the
specification.
I.e. as the pthread_t:k_thread relationship is 1:1 and not M:N,
Zephyr does not support multiplexing of user threads on top of
schedulable kernel entities (i.e. "user threads" are directly
mapped to native threads, just like linuxthreads or NPTL are in
Linux).
For that reason, to be "posixly correct", we should save the
provided value via pthread_setconcurrency(), in the absense of
errors, and also return that same value back via
pthread_getconcurrency(), even though that serves zero purpose
in Zephyr for the foreseeable future.
Note: the specification also states
"an implementation can always ignore any calls to
pthread_setconcurrency() and return a constant for
pthread_getconcurrency()."
For that reason, the implementation may be revisited at a later
time when when considering optimizations and when there is a
better system in place for documenting deviations.
Any such optimization should be explicitly controlled via
Kconfig.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
pthread_setcanceltype() is required by the POSIX_THREADS_BASE
Option Group as detailed in Section E.1 of IEEE-1003.1-2017.
The POSIX_THREADS_BASE Option Group is required for PSE51,
PSE52, PSE53, and PSE54 conformance, and is otherwise mandatory
for any POSIX conforming system as per Section A.2.1.3 of
IEEE-1003-1.2017.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
_PTHREAD_CANCEL_POS is an implementation detail and should not
be defined in the global scope. Furthermore, _PTHREAD_CANCEL_POS
uses a reserved identifier (underscore followed by capital
letter).
Adjust definitions so that the implementation detail is only
used in the implementation and not in the interface.
Additionally, modify naming so that the non-standard macro does
not use a reserved identifier.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
* "identity" functions grouped more closely
* posix_thread_pool_init() should be adjacent to the SYS_INIT()
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Previously, `pthread_key_delete()` was only ever deleting key 0
rather than the key corresponding to the provided argument.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
pthread_atfork() is required by the POSIX_THREADS_BASE
Option Group as detailed in Section E.1 of IEEE-1003.1-2017.
The POSIX_THREADS_BASE Option Group is required for PSE51,
PSE52, PSE53, and PSE54 conformance, and is otherwise
mandatory for any POSIX conforming system as per Section
A.2.1.3 of IEEE-1003-1.2017.
Since Zephyr does not yet support processes and (by extension)
fork(), this implementation includes a deviation and should be
categorized as producing undefined behaviour.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Add a Kconfig option to tell whether or not using thread
local storage to store current thread.
The function using it can be called from ISR and using
TLS variables in this context may (should ???) not be
allowed
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Picolibc's 'minimal' printf mode reduces functionality and size even more
than the 'integer' mode. Use this where memory is at a premium and where
the application knows that it does not require exact printf semantics.
1.8.5 adds two more printf variants, 'long long' and 'minimal'. The 'long
long' variant is the same as the 'integer' variant but with long long
support enabled. The 'minimal' variant reduces functionality and size even
more than the 'integer' mode. Applications can use this where memory is at
a premium and where the application does not require exact printf
semantics.
With these two added variants, the SDK has enough options so that all of
the cbprintf modes can be supported with the pre-compiled bits:
1. CBPRINTF_NANO - picolibc's 'minimal' variant
2. CBPRINTF_REDUCED_INTEGRAL - picolibc's 'integer' variant
3. CBPRINTF_FULL_INTEGRAL - picolibc's 'long long' variant
4. CBPRINTF_FB_SUPPORT - picolibc's 'double' variant
This patch makes the cbprintf Kconfig values drive the default picolibc
variant, disables picolibc variants not capable of supporting the required
cbprintf level, but allows applications to select more functionality in
picolibc than cbprintf requires.
Note that this depends on the SDK including picolibc 1.8.5. Without that,
selecting the 'minimal' or 'long long' variant in Zephyr will end up with
the default variant from picolibc, which is the full version with floating
point support. When using the module things will work as specified.
Signed-off-by: Keith Packard <keithp@keithp.com>
This option in picolibc switches the assert macro between a chatty version
and one which provides no information at all. This latter mode avoids
placing the associated strings in memory.
The Zephyr option is PICOLIBC_ASSERT_VERBOSE and it is disable by default.
Signed-off-by: Keith Packard <keithp@keithp.com>
CBPRINTF_FULL_INTEGRAL doesn't happen to explicitly conflict with
CBPRINTF_NANO, but when CBPRINTF_NANO is enabled, there's no long long I/O
support provided.
Allow picolibc long-long I/O support to also be elided when CBPRINTF_NANO
is enabled to save similar amounts of space.
Signed-off-by: Keith Packard <keithp@keithp.com>