Commit graph

395 commits

Author SHA1 Message Date
Chris Friedt 2d4346ba53 posix: implement mprotect()
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>
2024-06-14 14:01:05 -04:00
Chris Friedt 64f336c251 posix: tie page size to mmu page size
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>
2024-06-14 14:01:05 -04:00
Chris Friedt 5346306261 posix: add support for shared memory objects
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>
2024-06-14 14:01:05 -04:00
Chris Friedt 5e99e13b4c posix: add support for mlockall() and munlockall()
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>
2024-06-14 14:01:05 -04:00
Chris Friedt d949c9c8b8 posix: add support for mlock() and munlock()
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>
2024-06-14 14:01:05 -04:00
Chris Friedt 73394a8390 posix: add implementation of mmap(), msync(), and munmap()
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>
2024-06-14 14:01:05 -04:00
Chris Friedt 156eaab70e posix: move ioctl() from fdtable to posix
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>
2024-06-14 14:01:05 -04:00
Chris Friedt 50fc010f0f posix + fdtable: move zvfs_ftruncate() to fdtable.c
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>
2024-06-14 14:01:05 -04:00
Chris Friedt 1f9ca63b93 posix: fs: implement fstat() via zvfs_fstat()
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>
2024-06-14 14:01:05 -04:00
Hess Nathan 974bad6242 coding guidelines: comply with MISRA Rule 12.1.
-added parentheses verifying lack of ambiguities

Signed-off-by: Hess Nathan <nhess@baumer.com>
2024-06-13 20:28:23 -04:00
Chris Friedt 8b61b71818 posix: streams: add stub for missing putpmsg() function
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>
2024-06-13 05:35:31 -04:00
Chris Friedt 598b2e11b2 posix: conditionally generate posix_clock syscall header
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>
2024-06-11 20:27:32 -05:00
Fabio Baltieri c250c330c6 posix: re-introduce PTHREAD_RWLOCK_INITIALIZER
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>
2024-06-05 19:31:59 -04:00
Chris Friedt fe1e7f8d37 doc: release: posix: deprecate non-normative POSIX Kconfig
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 0fa97326c7 posix: create kconfig options for pse51, pse52, pse53
Create Kconfig "shortcuts" for PSE51, PSE52, and PSE53.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Chris Friedt 487a8756c3 posix: eventfd: fix dependency cycle between net and posix
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>
2024-06-04 16:27:12 -05:00
Chris Friedt b3e36ad6e8 posix: eventfd: remove deprecated eventfd macros
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 3949e89330 posix: net: update for POSIX_NETWORKING
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>
2024-06-04 16:27:12 -05:00
Chris Friedt b051bcee25 posix: move getpid() to Kconfig.procN and doc MULTI_PROCESS
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 2e429f1b9d posix: reword aio and sched options. add experimental
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 3f29b17bd1 posix: deprecate POSIX_SIGNAL in favour of POSIX_SIGNALS
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 2642eaa4e9 posix: relocate Kconfig.eventfd to Kconfig.compat
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>
2024-06-04 16:27:12 -05:00
Chris Friedt fcebe60090 posix: deprecate PTHREAD_IPC _MUTEX _COND and _KEY
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 2f2cad742e posix: deprecate POSIX_PUTMSG for XOPEN_STREAMS
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 0711d603f7 posix: deprecate POSIX_SYSLOG for XSI_SYSTEM_LOGGING
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 842a7b7ba1 posix: deprecate SEM_VALUE_MAX and SEM_NAMELEN_MAX
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 9f6590c7b7 posix: deprecate POSIX_FS for POSIX_FILE_SYSTEM
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 2bc722a97e posix: deprecate POSIX_FNMATCH GETOPT GETENTROPY
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 70e2b02c8e posix: deprecate PTHREAD_RWLOCK for POSIX_READER_WRITER_LOCKS
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>
2024-06-04 16:27:12 -05:00
Chris Friedt f270de7362 posix: deprecate POSIX_MQUEUE in favour of POSIX_MESSAGE_PASSING
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 4e181f7031 posix: deprecate PTHREAD_SPINLOCK for POSIX_SPIN_LOCKS
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 2fe9d6cd68 posix: deprecate POSIX_ENV _CONFSTR _SYSCONF and _UNAME
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>
2024-06-04 16:27:12 -05:00
Chris Friedt b639604833 posix: deprecate PTHREAD_BARRIER for POSIX_BARRIERS
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>
2024-06-04 16:27:12 -05:00
Chris Friedt bc4374b5fe posix: deprecate POSIX_MAX_FDS and add POSIX_DEVICE_IO
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 3f469665f4 posix: fd_mgmt: add fd_mgmt option group
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>
2024-06-04 16:27:12 -05:00
Chris Friedt 4a5c4e5f73 posix: timers: deprecate CONFIG_POSIX_CLOCK and TIMER
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>
2024-06-04 16:27:12 -05:00
Chris Friedt e2fc78af23 posix: signals: deprecate CONFIG_POSIX_LIMITS_RTSIG_MAX
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>
2024-06-04 16:27:12 -05:00
Chris Friedt feb841a0f7 posix: add Kconfig.deprecated
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>
2024-06-04 16:27:12 -05:00
Chris Friedt aa6a472355 posix: sysconf: define z sysconf macros with COND_CODE_1
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>
2024-06-04 16:27:12 -05:00
Yong Cong Sin bbe5e1e6eb build: namespace the generated headers with zephyr/
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>
2024-05-28 22:03:55 +02:00
Pisit Sawangvonganan 557ad8e45c shell: devmem: address cmd_dump multiple call problem
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>
2024-05-15 10:13:23 +02:00
Alberto Escolar Piedras 7c8d538982 posix: env: Fix 2 build warnings
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>
2024-05-14 13:25:33 +02:00
Chris Friedt b1e2e4ac2c posix: fs: create a separate Kconfig option for fsync
Create CONFIG_POSIX_FSYNC to match the spec.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-05-07 21:22:56 -04:00
Yong Cong Sin 4363a787b1 posix: uname: increase version name length
to 70 to prevent overflowing the char array.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-04-29 17:40:16 +01:00
Patryk Duda ef258166ba posix: Introduce getentropy() function
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>
2024-04-29 11:46:06 +01:00
Chris Friedt cdb1193f3e posix: add stubs for asynchronous io
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>
2024-04-29 11:02:11 +02:00
Alberto Escolar Piedras 60d5ce452e libC kconfig: Introduce a new option to avoid the native libC
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>
2024-04-24 09:53:36 +02:00
Alberto Escolar Piedras 84e7107b32 Revert "posix: use sys_sem instead of k_spinlock for pool synch"
This reverts commit 6e66aa1f7c.

And fixes an indentation issue in the original code,
which triggers checkpatch.

This PR:
https://github.com/zephyrproject-rtos/zephyr/pull/71718
introduced a regression breaking CI:
https://github.com/zephyrproject-rtos/zephyr/issues/71814
Let's just revert it until a better fix is done.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-04-23 11:51:44 -04:00
Chris Friedt 6e66aa1f7c posix: use sys_sem instead of k_spinlock for pool synch
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>
2024-04-23 07:01:25 -04:00
Karthikeyan Krishnasamy cc06c2b21f lib: posix: fs: fix errno handling
ftruncate should return -1 on errors and it needs to
set appropriate error values in errno

Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
2024-04-22 04:33:16 -07:00