The `SIGNO_WORD_IDX` & `SIGNO_WORD_BIT` macros should have
used its own argument `_signo` instead of `signo`. It didn't
cause and error because the function's argument has `signo`.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
If both `smf_set_state()` and `smf_set_handled()` are called in
a run action, the `internal->handled` bit would not be reset.
This could cause an issue on the next run action by not
propagating events to parents.
Signed-off-by: Glenn Andrews <glenn.andrews.42@gmail.com>
The following heap-related Kconfigs shared by the picolibc &
minimal libc have been deprecated for more than 2 releases,
remove them and update the Kconfigs accordingly:
- `CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE`
- `CONFIG_MINIMAL_LIBC_REALLOCARRAY`
Cleanup the handling to support the deprecated malloc arena
size configuration values.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
The following Kconfigs have been deprecated for more than 2
releases, remove them:
- `CONFIG_SUPPORT_MINIMAL_LIBC`
- `CONFIG_MINIMAL_LIBC_MALLOC`
- `CONFIG_MINIMAL_LIBC_CALLOC`
- `CONFIG_MINIMAL_LIBC_REALLOCARRAY`
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
These Kconfigs should have been deprecated for more than 2
releases, remove them:
- `CONFIG_CPP_MAIN`
- `CONFIG_CPLUSPLUS`
- `CONFIG_LIB_CPLUSPLUS`
- `CONFIG_EXCEPTIONS`
- `CONFIG_RTTI`
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
If `sys_reboot` is called during testing, the standard dump when `main`
returns will never be executed. Failing to dump at this point means any
coverage information gathered will be lost upon reboot.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Both Clang [1] and (recently) GCC [2] support this flag to enable
additional codesize optimizations beyond -Os, possibly at the expense of
performance.
This tradeoff is worthwhile for some (and, Clang's -Oz seems to be
closer to GCC's -Os currently), so add a new abstraction for this flag
so users can select it as appropriate.
[1] https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-O0
[2] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-Oz
Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
Provide a stub for mprotect() to satisfy the requirement for the
base definitions / system interfaces and subsequently PSE51,
PSE52, PSE52, etc.
Currently, Zephyr's virtual memory-management API does not seem
to support modifying memory protection bits after pages have
already been mapped.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Make POSIX_PAGE_SIZE_BITS not user-configurable and tie it to
CONFIG_MMU_PAGE_SIZE if there is an MMU. Otherwise, simply
default it to something small.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Implement shm_open() and shm_unlink() to complete support for
the _POSIX_SHARED_MEMORY_OBJECTS Option.
Since mmap() support is not yet implemented in Zephyr, I/O is
limited to read(), write(), ftruncate(), lseek(), close(), for now.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
File offset actually varies on a per-file-descriptor basis,
and not with the resource that is abstracted behind the file
descriptor.
This is consistent with both the POSIX model and also the
ISO C/C++ model, so Zephyr should follow suit.
This is very work-around-y, but it's necessary to ensure
that shared memory objects, block devices, files and
directories all behave consistently.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add a mode field for struct fd_entry, as well as a new
initializer, z_finalize_typed_fd().
The constants ZVFS_MODE_* may be used to differentiate
between fifo, character device, message queues, directories,
semaphores, block devices, shared memory objects, regular files,
symbolic links, and sockets.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add support for mlockall() and munlockall(). These two functions
comprise the _POSIX_MEMLOCK Option which is required by PSE51,
PSE52, PSE53, and PSE54.
Zephyr's on-demand paging API does not yet support pinning and
unpinning *all* virtual memory regions, so these functions are
expected to fail, setting errno to ENOSYS. Any other usage is
currently categorized as undefined behaviour.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add support for mlock() and munlock(). These two functions
comprise the _POSIX_MEMLOCK_RANGE Option which is
required by PSE51, PSE52, PSE53, and PSE54.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add stubs for mmap(), msync(), and munmap() as required by the
_POSIX_MAPPED_FILES Option and POSIX_MAPPED_FILES and
Option Group of IEEE 1003.1-2017.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The ioctl() call should be a part of the _XOPEN_STREAMS
Option in posix, so move it there.
Create a zephyr-native zvfs_ioctl() in the layer below.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Move the zvfs_ftruncate() call from fs.c to fdtable.c, as file
types other than regular files can also be truncated.
Instead of hard-wiring zvfs_ftruncate() to fs_truncate(),
add a new ZVFS_IOCTL_TRUNCATE so that the operation can be
handled with other ioctl() operations.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Route the fstat() call (part of POSIX_FILE_SYSTEM) to
zvfs_fstat() so that other types of file descriptors can also
supply file status information.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
In some function in bitarray.c, we should check the pointer
of bitarry before taking bitarray lock.
In this patch, we move the null-check assert before the use of
the struct to provide better validation than a crash.
Signed-off-by: TaiJu Wu <tjwu1217@gmail.com>
The putpmsg() function was left unimplemented when other
functions in the _XOPEN_STREAMS Option.
Add a stub to complete the Option.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
If POSIX_TIMERS is not configured, there is no reason to
generate syscall headers from posix_clock.h .
Make header generation conditional on POSIX_TIMERS in
this case.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Use `do { ... } while (false)' instead of `do { ... } while (0)'.
Use comparisons with zero instead of implicitly testing integers.
Use comparisons with NULL instead of implicitly testing pointers.
Use comparisons with NUL instead of implicitly testing plain chars.
Use `bool' instead of `int' to represent Boolean values.
Use `while (true)' instead of `while (1)' to express infinite loops.
Signed-off-by: frei tycho <tfrei@baumer.com>
Rename the POSIX_RWLOCK_INITIALIZER back to PTHREAD_RWLOCK_INITIALIZER.
This was changed in 70e2b02c8e, but PTHREAD_RWLOCK_INITIALIZER is the
standard name used by external libraries.
Change it back to restore compatibility.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add release notes for the deprecation of a number of POSIX
Kconfig options. These have been deprecated so that we can
use more normative Kconfig variable identifiers, based on
the Options and Option Groups of IEEE 1003.1-2017.
To simplify migration, use
python $ZEPHYR_BASE/scripts/utils/migrate_posix_kconfigs.py \
-r root_path
Additionally, document the removal of PTHREAD_BARRIER_DEFINE(),
EFD_IN_USE, EFD_FLAGS_SET, which were previously deprecated
>= 2 release cycles before.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Until recently, the posix api was purely a consumer of the
network subsystem. However, a dependency cycle was added as
a stop-gap solution for challenges with the native platform.
Specifically,
1. eventfd symbols conflict with those of the host
2. eventfd was excluded from native libc builds via cmake
If any part of the posix were then to select the network
subsystem (which is a legitimate use case, given that networking
is a part of the posix api), we would get a build error due to
the Kconfig dependency cycle.
As usual, with dependency cycles, the cycle can be broken
via a third, mutual dependency.
What is the third mutual dependency? Naturally, it is ZVFS
which was planned some time ago. ZVFS will be where we
collect file-descriptor and FILE-pointer APIs so that we can
ensure consistency for Zephyr users.
This change deprecates EVENTFD_MAX in favour of
ZVFS_EVENTFD_MAX.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Remove the EFD_IN_USE and EFD_FLAGS_SET macros as they were not
part of the public API.
Rename the internal versions, accordingly.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add a link to the Kconfig option CONFIG_POSIX_NETWORKING in
the documentation.
Additionally, add Kconfig options for other Network
dependencies in an effort to make POSIX Kconfig options
consistent with the specification.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Create a Kconfig option for POSIX_MULTI_PROCESS Option Group
and mark it as experimental.
Currently, Zephyr has two functions that belong to this
Option Group:
- sleep()
- getpid()
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The asynchronous I/O and (process) scheduling options needed
minor rewording.
Additionally, add the experimental flag to each of them since
they are not yet supported.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This change deprecates CONFIG_POSIX_SIGNAL in favour of
the plural CONFIG_POSIX_SIGNALS, which maps directly to the
name of the standard POSIX Option Group POSIX_SIGNALS.
Additionally, mark signals as experimental.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
While event file descriptors (eventfd) are extremely useful, the
API has still not been formalized as part of the POSIX
specification.
Therefore, move this to a separate Kconfig menu for "compat"
(compatibility) features.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Zephyr's POSIX API is moving toward using the standard
nomenclature from IEEE 1003.1-2017 for as much as possible. In
particular, we want to have consistent naming between Zephyr's
POSIX API Kconfig options and the naming for POSIX Options and
Option Groups.
The Kconfig option CONFIG_PTHREAD_IPC has been (ab)used for a
very long time for a variety of different purposes. However,
the standard Option / feature test macro for POSIX Threads is,
intuitively _POSIX_THREADS. There is a corresponding sysconf()
key named _SC_POSIX_THREADS.
Annoyingly, the POSIX Option Group that corresponds to the
Option is POSIX_THREADS_BASE, which is a minor inconsistency
in the standard.
The _POSIX_THREADS Option already includes mutexes, condition
variables, and thread-specific storage (keys). So with this
change, we also deprecate the redundant Kconfig variables that
do not have a corresponding match in the standard.
- CONFIG_PTHREAD_IPC
- CONFIG_PTHREAD
- CONFIG_PTHREAD_COND
- CONFIG_PTHREAD_MUTEX
- CONFIG_PTHREAD_KEY
Additionally, create Kconfig variables for those configurables
which we are lacking:
- CONFIG_POSIX_THREADS_EXT
- CONFIG_POSIX_THREAD_ATTR_STACKSIZE
- CONFIG_POSIX_THREAD_ATTR_STACKADDR
- CONFIG_POSIX_THREAD_PRIORITY_SCHEDULING
- CONFIG_POSIX_THREAD_PRIO_INHERIT
- CONFIG_POSIX_THREAD_PRIO_PROTECT
- CONFIG_POSIX_THREAD_SAFE_FUNCTIONS
Some Kconfig variables were renamed to more properly match the spec:
- CONFIG_MAX_PTHREAD_COUNT -> CONFIG_POSIX_THREAD_THREADS_MAX
- CONFIG_MAX_PTHREAD_KEY_COUNT -> CONFIG_POSIX_THREAD_KEYS_MAX
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This change deprecates CONFIG_POSIX_PUTMSG and introduces a new
Kconfig option CONFIG_XOPEN_STREAMS which maps directly to the
standard POSIX Option, _XOPEN_STREAMS.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This change deprecates the CONFIG_POSIX_SYSLOG Kconfig
variable for CONFIG_XSI_SYSTEM_LOGGING, which has a
direct mapping to the POSIX Option Group XSI_SYSTEM_LOGGING.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This change deprecates CONFIG_SEM_VALUE_MAX in favour of
CONFIG_POSIX_SEM_VALUE_MAX which maps directly to
_POSIX_SEM_VALUE_MAX.
Additionally, we add the Kconfig option
CONFIG_POSIX_SEMAPHORES which maps directly to the
POSIX Option _POSIX_SEMAPHORES.
For consistence, deprecate CONFIG_SEM_NAMELEN_MAX
in favour of CONFIG_POSIX_SEM_NAMELEN_MAX.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This change deprecates CONFIG_POSIX_FS in favour of
CONFIG_POSIX_FILE_SYSTEM, which maps directly to the name of the
standard POSIX Option Group.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The functions fnmatch(), getopt(), getentropy()
and others are grouped into the standard Option Group
POSIX_C_LIB_EXT.
The getentropy() function is currently in-draft for
Issue 8 as of 2021.
https://www.opengroup.org/austin/docs/austin_1110.pdf
Not surprisingly, the POSIX_C_LIB_EXT Option Group
also includes the highly debated strnlen() function.
Moving that function will be deferred until later.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This change deprecates CONFIG_PTHREAD_RWLOCK in favour of
CONFIG_POSIX_READER_WRITER_LOCKS, which maps directly to the
name of the standard POSIX Option.
Annoyingly, the POSIX_RW_LOCKS Option Group is inconsistently
named. However, it is more convenient for us to use the Option
name since it is also the format used by the sysconf() variable
(_SC_READER_WRITER_LOCKS).
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This change deprecates CONFIG_POSIX_MQUEUE in favour of
CONFIG_POSIX_MESSAGE_PASSING, which maps directly to the name of the
standard POSIX Option.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This change deprecates CONFIG_PTHREAD_SPINLOCK in favour of
CONFIG_POSIX_SPIN_LOCKS, which maps directly to the name of the
standard POSIX Option Group.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This change deprecates the following Kconfig options
* CONFIG_POSIX_ENV
* CONFIG_POSIX_CONFSTR
* CONFIG_POSIX_SYSCONF
* CONFIG_POSIX_UNAME
and instead groups them into a single Kconfig option that maps
directly to the standard. Namely, CONFIG_POSIX_SINGLE_PROCESS.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The standard specifies _POSIX_BARRIERS as an Option so let's
use CONFIG_POSIX_BARRIERS for consistence.
This change deprecates CONFIG_PTHREAD_BARRIER. Users should
instead choose CONFIG_POSIX_BARRIERS.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The POSIX_MAX_FDS option does not correspond to any standard
POSIX option. It was used to define the size of the file
descriptor table, which is by no means exclusively used by
POSIX (also net, fs, ...).
POSIX_MAX_FDS is being deprecated in order to ensure that
Zephyr's POSIX Kconfig variables correspond to those defined in
the specification, as of IEEE 1003.1-2017. Namely,
POSIX_OPEN_MAX. CONFIG_POSIX_MAX_OPEN_FILES is being deprecated
for the same reason.
To mitigate any possible layering violations, that option is
not user selectable. It tracks the newly added
CONFIG_ZVFS_OPEN_MAX option, which is native to Zephyr.
With this deprecation, we introduce the following Kconfig
options that map directly to standard POSIX Option Groups by
simply removing "CONFIG_":
* CONFIG_POSIX_DEVICE_IO
Similarly, with this deprecation, we introduce the following
Kconfig options that map directly to standard POSIX Options by
simply removing "CONFIG":
* CONFIG_POSIX_OPEN_MAX
In order to maintain parity with the current feature set, we
introduce the following Kconfig options.
* CONFIG_POSIX_DEVICE_IO_ALIAS_CLOSE
* CONFIG_POSIX_DEVICE_IO_ALIAS_OPEN
* CONFIG_POSIX_DEVICE_IO_ALIAS_READ
* CONFIG_POSIX_DEVICE_IO_ALIAS_WRITE
Gate open(), close(), read(), and write() via the
CONFIG_POSIX_DEVICE_IO Kconfig option and move
implementations into device_io.c, to be conformant with the
spec.
Lastly, stage function names for upcoming ZVFS work, to be
completed as part of the LTSv3 Roadmap (e.g. zvfs_open(), ..).
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
With this change, we collect implementations of functions that are
part of the POSIX_FD_MGMT Option Group into one compilation unit
(fd_mgmt.c) and provide a matching Kconfig symbol that is
reflective of the standard.
Additionally, provide Kconfig options for aliases of those functions
since Newlib-based toolchains internally use an underscore-prefixed
alias for many POSIX functions (in this case _lseek).
Prefix Zephyr-native implementations with zvfs_ to prepare for the
up-coming changes in that area.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The POSIX_CLOCK option does not correspond to any standard
option. It was used to active features of several distinct
POSIX Options and Option Groups, which complicated API and
application configuration as a result.
POSIX_CLOCK is being deprecated in order to ensure that Zephyr's
POSIX Kconfig variables correspond to those defined in the
specification, as of IEEE 1003.1-2017.
Additionally, CONFIG_TIMER is being deprecated because it does
not match the corresponding POSIX Option (_POSIX_TIMERS).
With this deprecation, we introduce the following Kconfig
options that map directly to standard POSIX Option Groups by
simply removing "CONFIG_":
* CONFIG_POSIX_TIMERS
Similarly, we introduce the following Kconfig options that
map directly to standard POSIX Options by simply removing
"CONFIG":
* CONFIG_POSIX_CLOCK_SELECTION
* CONFIG_POSIX_CPUTIME
* CONFIG_POSIX_DELAYTIMER_MAX
* CONFIG_POSIX_MONOTONIC_CLOCK
* CONFIG_POSIX_TIMEOUTS
* CONFIG_POSIX_TIMER_MAX
In order to maintain parity with the current feature set, we
introduce the following Kconfig options that map directly to
standard POSIX Option Groups by simply removing "CONFIG_":
* CONFIG_POSIX_MULTI_PROCESS - sleep()
Similarly, in order to maintain parity with the current feature
set, we introduce the following additional Kconfig options that
map directly to standard POSIX Options by simply removing
"CONFIG":
* CONFIG_XSI_SINGLE_PROCESS - gettimeofday()
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
There were two Kconfig constants defined for (effectively) the
same thing in Zephyr. Namely, RTSIG_MAX - the highest valued
real-time signal.
Deprecate CONFIG_POSIX_LIMITS_RTSIG_MAX in favour of
CONFIG_POSIX_RTSIG_MAX since the latter more closely matches
convention.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
There will be some POSIX Kconfig symbols that will be deprecated
in favour of Kconfig symbols that are exact matches for those in
the POSIX specification (1003.1-2017).
Create the empty Kconfig file now, and then incrementally add to
it as non-standard POSIX Kconfig options are replaced with
standard-like POSIX Kconfig options.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
It's sort of more conventient to do the opposite of what was
done with the __z_sysconf_ macros, and use them for both the
full implementation and the macro implementation.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
There is no point in having heap validation enabled but without asserts,
as nothing is reported to the user.
Add this dependency to make sure this option is useful.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.
Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.
Updated the includes path of in-tree sources accordingly.
Most of the changes here are scripted, check the PR for more
info.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
The type of the resource table is known, casting to and from void* only
hides this type which can prevent the compiler from giving helpful
warnings. One warning would have been the accidental use of
"st_resource_table" in a cast, a struct which does not exist.
Use the fw_resource_table type when dealing with resource tables.
Signed-off-by: Andrew Davis <afd@ti.com>
This structure is shared between cores which may have different type
widths. Use fixed width types when defining the structure. We can
also use struct resource_table to help as it is already defined with
fixed width types and removes the need to redefine these elements.
Signed-off-by: Andrew Davis <afd@ti.com>
Modify the SMF such that state transitions from parent states choose the
correct Least Common Ancestor based on the transition source rather than
the current state.
SMF set as experimental.
Signed-off-by: Glenn Andrews <glenn.andrews.42@gmail.com>
This is part one of several changes to add more methods to the bitarray api
so that it can be used for broader usecases, specifically LoRaWAN forward
error correction.
Signed-off-by: Lucas Romero <luqasn@gmail.com>
This is part one of several changes to add more methods to the bitarray api
so that it can be used for broader usecases, specifically LoRaWAN forward
error correction.
Signed-off-by: Lucas Romero <luqasn@gmail.com>
This is part one of several changes to add more methods to the bitarray api
so that it can be used for broader usecases, specifically LoRaWAN forward
error correction.
Signed-off-by: Lucas Romero <luqasn@gmail.com>
Zephyr minimal libc implements integer constant macros using internal
headers provided by GCC, for example INT64_C(x) is just a __INT64_C(x)
which is implemented by the GCC.
Clang compiler doesn't provide these definitions, so we define them
(__INT64_C() and INT64_C()) in zephyr/toolchain/llvm.h, but it looks
like INT64_C() definition doesn't come from llvm.h, but from stdlib.h
despite of checking if __GNUC__ is defined.
This is because Clang sometimes pretends to be GNU compiler:
$ x86_64-pc-linux-gnu-clang -dM -E - < /dev/null | grep "GNU"
#define __GNUC_MINOR__ 2
#define __GNUC_PATCHLEVEL__ 1
#define __GNUC_STDC_INLINE__ 1
#define __GNUC__ 4
Let's keep the integer constant macros in stdlib.h and their
actual implementation in llvm.h. Also define these macros if __clang__
is defined, just in case.
Signed-off-by: Patryk Duda <patrykd@google.com>
Call `getopt_init()` to reset `state->optind` instead of directly setting
`optind = 1`. The `getopt()` function uses `getopt_state` from
`getopt_state_get` for state handling, so `getopt_init()` should be called
to correctly run the command again.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Fix 2 build warnings in posix/options/env:
The maximum length given to strncpy() matches the input
string length, which makes the call equivalent to strcpy().
As the destination buffer size has been ensured sufficient
(in the first case by chechking just before,
in the second case by allocating it big enough),
let's just use strcpy() instead.
lib/posix/options/env.c: In function 'getenv_r':
lib/posix/options/env.c:109:17: error: 'strncpy' specified bound
depends on the length of the source argument
[-Werror=stringop-truncation]
109 | strncpy(buf, val, vsize);
| ^~~~~~~~~~~~~~~~~~~~~~~~
lib/posix/options/env.c:104:25: note: length computed here
104 | vsize = strlen(val) + 1;
| ^~~~~~~~~~~
lib/posix/options/env.c: In function 'setenv':
lib/posix/options/env.c:191:17: error: 'strncpy' output truncated
before terminating nul copying as many bytes from a string as its
length [-Werror=stringop-truncation]
191 | strncpy(environ[ret], name, nsize);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/posix/options/env.c:128:51: note: length computed here
128 | const size_t nsize = (name == NULL) ? 0 : strlen(name);
| ^~~~~~~~~~~~
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Allow Picolibc to get build from module, if the toolchain does not
include a bundled picolibc.
This should always be possible, except for native applications and
if libcpp is required.
Signed-off-by: David Schneider <david.schneider@chargepoint.com>
This aligns abort() and exit() definitions with other libc.
Without 'noreturn' attribute, compilers have to assume that we will
return from these functions which can lead to surprising errors like
'error: non-void function does not return a value'.
Signed-off-by: Patryk Duda <patrykd@google.com>
The function writes random data to the provided buffer. Maximum
permitted buffer size is 256 bytes. On success the function returns 0,
otherwise it returns -1 and sets errno to appropriate value.
Signed-off-by: Patryk Duda <patrykd@google.com>
Add stubs for POSIX asynchronous io that return -1 and set
errno to ENOTSUP.
The functions and structures in aio.h are required by the
_POSIX_ASYNCHRONOUS_IO Option as detailed in Section E.1 of
IEEE-1003.1-2017.
The _POSIX_ASYNCHRONOUS_IO interface 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: Chris Friedt <cfriedt@tenstorrent.com>
Let's introduce a new option so components which cannot
be used with the native libC can select it.
And at this point let's already have POSIX_API select it
instead of being used in the libC choice default.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
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>
ftruncate should return -1 on errors and it needs to
set appropriate error values in errno
Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
Commit e6eb0a705b ("posix: eventfd: revise locking, signaling, and
allocation") introduced a regression where the internal flags of an
event file descriptor would be erased when calling the F_SETFL ioctl
operation.
This includes the flag EFD_IN_USE_INTERNAL which determines whether
this file descriptor has been opened, thus effectively closing the
eventfd whenever one tries to change a flag.
Signed-off-by: Celina Sophie Kalus <hello@celinakalus.de>
The `BUILD_VERSION` can be defined but empty when built
without git, causing version to be missing from the uname
version string:
```
*** Booting Zephyr OS build 3.5.0 ***
Printing everything in utsname...
sysname[7]: Zephyr
nodename[7]: zephyr
release[13]: 3.5.0
version[61]: Apr 1 2024 23:48:30
machine[8]: riscv64
uart:~$
```
Let's check if it is empty before using it, so that
`KERNEL_VERSION_STRING`, which is generated independently
with cmake can be used as a fallback:
```
*** Booting Zephyr OS build 3.5.0 ***
Printing everything in utsname...
sysname[7]: Zephyr
nodename[7]: zephyr
release[13]: 3.5.0
version[61]: 3.5.0 Apr 1 2024 23:53:48
machine[8]: riscv64
uart:~$
```
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
With CONFIG_NET_POSIX_NAMES being deprecated, convert static
inlines in headers to prototypes, and move implementations
to lib/posix/options/net.c .
Since select and poll should technically also operate on
non-socket file descriptors, these may be relocated in the
future.
Below are some reasons for this change.
1. So posix calls are regular symbols and not directly inlined
as syscalls. This is also the most portable linkage type.
2. Many posix calls are cancellation points and additional
checks are necessary within the implementation.
3. The more we add to an inline call, the less sense it makes
for that call to be inline.
4. When the implementation of a posix function changes, the
interface for it should still remain consistent.
Note: the same principles have been applied in Zephyr's
posix implementation already, e.g. clock_gettime(), so this
is nothing new.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Implement `pthread_attr_setinheritsched()` and
`pthread_attr_getinheritsched()`are required
as part of _POSIX_THREAD_PRIORITY_SCHEDULING Option Group.
signed-off-by: Gaetan Perrot <gaetanperrotpro@gmail.com>
Implement if_indextoname(), if_freenameindex(), if_nameindex(),
and if_nametoindex() by wrapping around networking subystem
calls.
Signed-off-by: Chris Friedt <chrisfriedt@gmail.com>