Skip to content

Commit

Permalink
posix: timers: deprecate the non-standard option POSIX_CLOCK
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Chris Friedt committed May 22, 2024
1 parent 3422357 commit 7f91781
Show file tree
Hide file tree
Showing 35 changed files with 305 additions and 172 deletions.
2 changes: 1 addition & 1 deletion cmake/toolchain/armclang/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ choice LIBC_IMPLEMENTATION
config ARMCLANG_STD_LIBC
bool "ARM Compiler C library"
select COMMON_LIBC_STRNLEN
select COMMON_LIBC_TIME if POSIX_CLOCK
select COMMON_LIBC_TIME if POSIX_TIMERS
help
Use the full Arm Compiler runtime libraries.
A reduced Zephyr minimal libc will be used for library functionality
Expand Down
2 changes: 1 addition & 1 deletion doc/connectivity/networking/api/lwm2m.rst
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ engine.

Data caches depends on one of the SenML data formats
:kconfig:option:`CONFIG_LWM2M_RW_SENML_CBOR_SUPPORT` or
:kconfig:option:`CONFIG_LWM2M_RW_SENML_JSON_SUPPORT` and needs :kconfig:option:`CONFIG_POSIX_CLOCK`
:kconfig:option:`CONFIG_LWM2M_RW_SENML_JSON_SUPPORT` and needs :kconfig:option:`CONFIG_POSIX_TIMERS`
so it can request a timestamp from the system and :kconfig:option:`CONFIG_RING_BUFFER` for ring
buffer.

Expand Down
2 changes: 1 addition & 1 deletion doc/services/portability/posix/aep/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The *Minimal Realtime System Profile* (PSE51) includes all of the
:ref:`_POSIX_FSYNC <posix_option_fsync>`, 200809L, :kconfig:option:`CONFIG_POSIX_FSYNC`
:ref:`_POSIX_MEMLOCK <posix_option_memlock>`, -1,
:ref:`_POSIX_MEMLOCK_RANGE <posix_option_memlock_range>`, -1,
:ref:`_POSIX_MONOTONIC_CLOCK <posix_option_monotonic_clock>`, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
:ref:`_POSIX_MONOTONIC_CLOCK <posix_option_monotonic_clock>`, 200809L, :kconfig:option:`CONFIG_POSIX_MONOTONIC_CLOCK`
:ref:`_POSIX_SHARED_MEMORY_OBJECTS <posix_shared_memory_objects>`, -1,
:ref:`_POSIX_SYNCHRONIZED_IO <posix_option_synchronized_io>`, -1,
:ref:`_POSIX_THREAD_ATTR_STACKADDR<posix_option_thread_attr_stackaddr>`, 200809L, :kconfig:option:`CONFIG_PTHREAD`
Expand Down
10 changes: 5 additions & 5 deletions doc/services/portability/posix/conformance/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ POSIX System Interfaces
_POSIX_VERSION, 200809L,
:ref:`_POSIX_ASYNCHRONOUS_IO<posix_option_asynchronous_io>`, 200809L, :ref:`†<posix_undefined_behaviour>`
:ref:`_POSIX_BARRIERS<posix_option_group_barriers>`, 200809L, :kconfig:option:`CONFIG_PTHREAD_BARRIER`
:ref:`_POSIX_CLOCK_SELECTION<posix_option_group_clock_selection>`, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
:ref:`_POSIX_CLOCK_SELECTION<posix_option_group_clock_selection>`, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK_SELECTION`
_POSIX_MAPPED_FILES, -1, :ref:`†<posix_undefined_behaviour>`
_POSIX_MEMORY_PROTECTION, -1, :ref:`†<posix_undefined_behaviour>`
:ref:`_POSIX_READER_WRITER_LOCKS<posix_option_reader_writer_locks>`, 200809L, :kconfig:option:`CONFIG_PTHREAD_IPC`
Expand All @@ -72,22 +72,22 @@ POSIX System Interfaces
:ref:`_POSIX_SPIN_LOCKS<posix_option_group_spin_locks>`, 200809L, :kconfig:option:`CONFIG_PTHREAD_SPINLOCK`
:ref:`_POSIX_THREAD_SAFE_FUNCTIONS<posix_thread_safe_functions>`, -1,
:ref:`_POSIX_THREADS<posix_option_group_threads_base>`, -1, :kconfig:option:`CONFIG_PTHREAD_IPC`
:ref:`_POSIX_TIMEOUTS<posix_option_timeouts>`, 200809L, :kconfig:option:`CONFIG_PTHREAD_IPC`
:ref:`_POSIX_TIMERS<posix_option_group_timers>`, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
:ref:`_POSIX_TIMEOUTS<posix_option_timeouts>`, 200809L, :kconfig:option:`CONFIG_POSIX_TIMEOUTS`
:ref:`_POSIX_TIMERS<posix_option_group_timers>`, 200809L, :kconfig:option:`CONFIG_POSIX_TIMERS`
_POSIX2_C_BIND, 200809L,

.. csv-table:: POSIX System Interfaces (Optional)
:header: Symbol, Support, Remarks
:widths: 50, 10, 50

_POSIX_ADVISORY_INFO, -1,
_POSIX_CPUTIME, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
_POSIX_CPUTIME, 200809L, :kconfig:option:`CONFIG_POSIX_CPUTIME`
:ref:`_POSIX_FSYNC<posix_option_fsync>`, 200809L, :kconfig:option:`CONFIG_POSIX_FSYNC`
_POSIX_IPV6, 200809L, :kconfig:option:`CONFIG_NET_IPV6`
_POSIX_MEMLOCK, -1,
_POSIX_MEMLOCK_RANGE, -1,
:ref:`_POSIX_MESSAGE_PASSING<posix_option_message_passing>`, 200809L, :kconfig:option:`CONFIG_POSIX_MQUEUE`
:ref:`_POSIX_MONOTONIC_CLOCK<posix_option_monotonic_clock>`, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK`
:ref:`_POSIX_MONOTONIC_CLOCK<posix_option_monotonic_clock>`, 200809L, :kconfig:option:`CONFIG_POSIX_MONOTONIC_CLOCK`
_POSIX_PRIORITIZED_IO, -1,
:ref:`_POSIX_PRIORITY_SCHEDULING<posix_option_priority_scheduling>`, 200809L, :kconfig:option:`CONFIG_POSIX_PRIORITY_SCHEDULING`
_POSIX_RAW_SOCKETS, 200809L, :kconfig:option:`CONFIG_NET_SOCKETS_PACKET`
Expand Down
2 changes: 0 additions & 2 deletions doc/services/portability/posix/kconfig/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ implementation of the POSIX API.
* :kconfig:option:`CONFIG_NET_SOCKETS`
* :kconfig:option:`CONFIG_NET_SOCKETS_POLL_MAX`
* :kconfig:option:`CONFIG_POSIX_API`
* :kconfig:option:`CONFIG_POSIX_CLOCK`
* :kconfig:option:`CONFIG_POSIX_FS`
* :kconfig:option:`CONFIG_POSIX_MAX_FDS`
* :kconfig:option:`CONFIG_POSIX_MAX_OPEN_FILES`
Expand All @@ -46,4 +45,3 @@ implementation of the POSIX API.
* :kconfig:option:`CONFIG_PTHREAD_RECYCLER_DELAY_MS`
* :kconfig:option:`CONFIG_PTHREAD_SPINLOCK`
* :kconfig:option:`CONFIG_SEM_VALUE_MAX`
* :kconfig:option:`CONFIG_TIMER`
12 changes: 7 additions & 5 deletions include/zephyr/posix/posix_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
#define _POSIX_BARRIERS _POSIX_VERSION
#endif

#ifdef CONFIG_POSIX_CLOCK
#ifdef CONFIG_POSIX_CLOCK_SELECTION
#define _POSIX_CLOCK_SELECTION _POSIX_VERSION
#endif

/* #define _POSIX_CPUTIME (-1L) */
#ifdef CONFIG_POSIX_CPUTIME
#define _POSIX_CPUTIME _POSIX_VERSION
#endif

#ifdef CONFIG_POSIX_FSYNC
#define _POSIX_FSYNC _POSIX_VERSION
Expand All @@ -55,7 +57,7 @@
#define _POSIX_MESSAGE_PASSING _POSIX_VERSION
#endif

#ifdef CONFIG_POSIX_CLOCK
#ifdef CONFIG_POSIX_MONOTONIC_CLOCK
#define _POSIX_MONOTONIC_CLOCK _POSIX_VERSION
#endif

Expand Down Expand Up @@ -124,11 +126,11 @@
#endif
#endif

#ifdef CONFIG_POSIX_CLOCK
#ifdef CONFIG_POSIX_TIMEOUTS
#define _POSIX_TIMEOUTS _POSIX_VERSION
#endif

#ifdef CONFIG_POSIX_CLOCK
#ifdef CONFIG_POSIX_TIMERS
#define _POSIX_TIMERS _POSIX_VERSION
#endif

Expand Down
118 changes: 68 additions & 50 deletions include/zephyr/posix/sys/sysconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,55 +141,73 @@ enum {
_SC_TZNAME_MAX,
};

#define __z_posix_sysconf_SC_ADVISORY_INFO _POSIX_ADVISORY_INFO
#define __z_posix_sysconf_SC_ASYNCHRONOUS_IO _POSIX_ASYNCHRONOUS_IO
#define __z_posix_sysconf_SC_BARRIERS _POSIX_BARRIERS
#define __z_posix_sysconf_SC_CLOCK_SELECTION _POSIX_CLOCK_SELECTION
#define __z_posix_sysconf_SC_CPUTIME _POSIX_CPUTIME
#define __z_posix_sysconf_SC_FSYNC _POSIX_FSYNC
#define __z_posix_sysconf_SC_IPV6 _POSIX_IPV6
#define __z_posix_sysconf_SC_JOB_CONTROL _POSIX_JOB_CONTROL
#define __z_posix_sysconf_SC_MAPPED_FILES _POSIX_MAPPED_FILES
#define __z_posix_sysconf_SC_MEMLOCK _POSIX_MEMLOCK
#define __z_posix_sysconf_SC_MEMLOCK_RANGE _POSIX_MEMLOCK_RANGE
#define __z_posix_sysconf_SC_MEMORY_PROTECTION _POSIX_MEMORY_PROTECTION
#define __z_posix_sysconf_SC_MESSAGE_PASSING _POSIX_MESSAGE_PASSING
#define __z_posix_sysconf_SC_MONOTONIC_CLOCK _POSIX_MONOTONIC_CLOCK
#define __z_posix_sysconf_SC_PRIORITIZED_IO _POSIX_PRIORITIZED_IO
#define __z_posix_sysconf_SC_PRIORITY_SCHEDULING _POSIX_PRIORITY_SCHEDULING
#define __z_posix_sysconf_SC_RAW_SOCKETS _POSIX_RAW_SOCKETS
#define __z_posix_sysconf_SC_RE_DUP_MAX _POSIX_RE_DUP_MAX
#define __z_posix_sysconf_SC_READER_WRITER_LOCKS _POSIX_READER_WRITER_LOCKS
#define __z_posix_sysconf_SC_REALTIME_SIGNALS _POSIX_REALTIME_SIGNALS
#define __z_posix_sysconf_SC_REGEXP _POSIX_REGEXP
#define __z_posix_sysconf_SC_SAVED_IDS _POSIX_SAVED_IDS
#define __z_posix_sysconf_SC_SEMAPHORES _POSIX_SEMAPHORES
#define __z_posix_sysconf_SC_SHARED_MEMORY_OBJECTS _POSIX_SHARED_MEMORY_OBJECTS
#define __z_posix_sysconf_SC_SHELL _POSIX_SHELL
#define __z_posix_sysconf_SC_SPAWN _POSIX_SPAWN
#define __z_posix_sysconf_SC_SPIN_LOCKS _POSIX_SPIN_LOCKS
#define __z_posix_sysconf_SC_SPORADIC_SERVER _POSIX_SPORADIC_SERVER
#define __z_posix_sysconf_SC_SS_REPL_MAX _POSIX_SS_REPL_MAX
#define __z_posix_sysconf_SC_SYNCHRONIZED_IO _POSIX_SYNCHRONIZED_IO
#define __z_posix_sysconf_SC_THREAD_ATTR_STACKADDR _POSIX_THREAD_ATTR_STACKADDR
#define __z_posix_sysconf_SC_THREAD_ATTR_STACKSIZE _POSIX_THREAD_ATTR_STACKSIZE
#define __z_posix_sysconf_SC_THREAD_CPUTIME _POSIX_THREAD_CPUTIME
#define __z_posix_sysconf_SC_THREAD_PRIO_INHERIT _POSIX_THREAD_PRIO_INHERIT
#define __z_posix_sysconf_SC_THREAD_PRIO_PROTECT _POSIX_THREAD_PRIO_PROTECT
#define __z_posix_sysconf_SC_THREAD_PRIORITY_SCHEDULING _POSIX_THREAD_PRIORITY_SCHEDULING
#define __z_posix_sysconf_SC_THREAD_PROCESS_SHARED _POSIX_THREAD_PROCESS_SHARED
#define __z_posix_sysconf_SC_THREAD_ROBUST_PRIO_INHERIT _POSIX_THREAD_ROBUST_PRIO_INHERIT
#define __z_posix_sysconf_SC_THREAD_ROBUST_PRIO_PROTECT _POSIX_THREAD_ROBUST_PRIO_PROTECT
#define __z_posix_sysconf_SC_THREAD_SAFE_FUNCTIONS _POSIX_THREAD_SAFE_FUNCTIONS
#define __z_posix_sysconf_SC_THREAD_SPORADIC_SERVER _POSIX_THREAD_SPORADIC_SERVER
#define __z_posix_sysconf_SC_THREADS _POSIX_THREADS
#define __z_posix_sysconf_SC_TIMEOUTS _POSIX_TIMEOUTS
#define __z_posix_sysconf_SC_TIMERS _POSIX_TIMERS
#define __z_posix_sysconf_SC_TRACE _POSIX_TRACE
#define __z_posix_sysconf_SC_TRACE_EVENT_FILTER _POSIX_TRACE_EVENT_FILTER
#define __z_posix_sysconf_SC_TRACE_EVENT_NAME_MAX _POSIX_TRACE_EVENT_NAME_MAX
#define __z_posix_sysconf_SC_TRACE_INHERIT _POSIX_TRACE_INHERIT
#define __z_posix_sysconf_SC_TRACE_LOG _POSIX_TRACE_LOG
#define __z_posix_sysconf_SC_ADVISORY_INFO (-1L)
#define __z_posix_sysconf_SC_ASYNCHRONOUS_IO \
COND_CODE_1(CONFIG_POSIX_ASYNCHRONOUS_IO, (_POSIX_ASYNCHRONOUS_IO), (-1L))
#define __z_posix_sysconf_SC_BARRIERS COND_CODE_1(CONFIG_PTHREAD_BARRIER, (_POSIX_BARRIERS), (-1L))
#define __z_posix_sysconf_SC_CLOCK_SELECTION \
COND_CODE_1(CONFIG_POSIX_CLOCK_SELECTION, (_POSIX_CLOCK_SELECTION), (-1L))
#define __z_posix_sysconf_SC_CPUTIME \
COND_CODE_1(CONFIG_POSIX_CPUTIME, (_POSIX_CPUTIME), (-1L))
#define __z_posix_sysconf_SC_FSYNC \
COND_CODE_1(CONFIG_POSIX_FSYNC, (_POSIX_FSYNC), (-1L))
#define __z_posix_sysconf_SC_IPV6 COND_CODE_1(CONFIG_NET_IPV6, (_POSIX_IPV6), (-1L))
#define __z_posix_sysconf_SC_JOB_CONTROL (-1L)
#define __z_posix_sysconf_SC_MAPPED_FILES (-1L)
#define __z_posix_sysconf_SC_MEMLOCK (-1L)
#define __z_posix_sysconf_SC_MEMLOCK_RANGE (-1L)
#define __z_posix_sysconf_SC_MEMORY_PROTECTION (-1L)
#define __z_posix_sysconf_SC_MESSAGE_PASSING \
COND_CODE_1(CONFIG_POSIX_MQUEUE, (_POSIX_MESSAGE_PASSING), (-1L))
#define __z_posix_sysconf_SC_MONOTONIC_CLOCK \
COND_CODE_1(CONFIG_POSIX_MONOTONIC_CLOCK, (_POSIX_MONOTONIC_CLOCK), (-1L))
#define __z_posix_sysconf_SC_PRIORITIZED_IO (-1L)
#define __z_posix_sysconf_SC_PRIORITY_SCHEDULING \
COND_CODE_1(CONFIG_POSIX_PRIORITY_SCHEDULING, (_POSIX_PRIORITY_SCHEDULING), (-1L))
#define __z_posix_sysconf_SC_RAW_SOCKETS \
COND_CODE_1(CONFIG_NET_SOCKETS_PACKET, (_POSIX_RAW_SOCKETS), (-1L))
#define __z_posix_sysconf_SC_RE_DUP_MAX _POSIX_RE_DUP_MAX
#define __z_posix_sysconf_SC_READER_WRITER_LOCKS \
COND_CODE_1(CONFIG_PTHREAD_IPC, (_POSIX_READER_WRITER_LOCKS), (-1L))
#define __z_posix_sysconf_SC_REALTIME_SIGNALS (-1L)
#define __z_posix_sysconf_SC_REGEXP (-1L)
#define __z_posix_sysconf_SC_SAVED_IDS (-1L)
#define __z_posix_sysconf_SC_SEMAPHORES \
COND_CODE_1(CONFIG_PTHREAD_IPC, (_POSIX_SEMAPHORES), (-1L))
#define __z_posix_sysconf_SC_SHARED_MEMORY_OBJECTS (-1L)
#define __z_posix_sysconf_SC_SHELL (-1L)
#define __z_posix_sysconf_SC_SPAWN (-1L)
#define __z_posix_sysconf_SC_SPIN_LOCKS \
COND_CODE_1(CONFIG_PTHREAD_SPINLOCK, (_POSIX_SPIN_LOCKS), (-1L))
#define __z_posix_sysconf_SC_SPORADIC_SERVER (-1L)
#define __z_posix_sysconf_SC_SS_REPL_MAX _POSIX_SS_REPL_MAX
#define __z_posix_sysconf_SC_SYNCHRONIZED_IO (-1L)
#define __z_posix_sysconf_SC_THREAD_ATTR_STACKADDR \
COND_CODE_1(CONFIG_PTHREAD_IPC, (_POSIX_THREAD_ATTR_STACKADDR), (-1))
#define __z_posix_sysconf_SC_THREAD_ATTR_STACKSIZE \
COND_CODE_1(CONFIG_PTHREAD_IPC, (_POSIX_THREAD_ATTR_STACKSIZE), (-1L))
#define __z_posix_sysconf_SC_THREAD_CPUTIME (-1L)
#define __z_posix_sysconf_SC_THREAD_PRIO_INHERIT \
COND_CODE_1(CONFIG_PTHREAD_IPC, (_POSIX_THREAD_PRIO_INHERIT), (-1L))
#define __z_posix_sysconf_SC_THREAD_PRIO_PROTECT (-1L)
#define __z_posix_sysconf_SC_THREAD_PRIORITY_SCHEDULING (-1L)
#define __z_posix_sysconf_SC_THREAD_PROCESS_SHARED (-1L)
#define __z_posix_sysconf_SC_THREAD_ROBUST_PRIO_INHERIT (-1L)
#define __z_posix_sysconf_SC_THREAD_ROBUST_PRIO_PROTECT (-1L)
#define __z_posix_sysconf_SC_THREAD_SAFE_FUNCTIONS \
COND_CODE_1(CONFIG_PTHREAD_IPC, (_POSIX_THREAD_SAFE_FUNCTIONS), (-1L))
#define __z_posix_sysconf_SC_THREAD_SPORADIC_SERVER (-1L)
#define __z_posix_sysconf_SC_THREADS \
COND_CODE_1(CONFIG_PTHREAD_IPC, (_POSIX_THREADS), (-1L))
#define __z_posix_sysconf_SC_TIMEOUTS \
COND_CODE_1(CONFIG_POSIX_TIMEOUTS, (_POSIX_TIMEOUTS), (-1L))
#define __z_posix_sysconf_SC_TIMERS \
COND_CODE_1(CONFIG_POSIX_TIMEOUTS, (_POSIX_TIMERS), (-1))
#define __z_posix_sysconf_SC_TRACE (-1L)
#define __z_posix_sysconf_SC_TRACE_EVENT_FILTER (-1L)
#define __z_posix_sysconf_SC_TRACE_EVENT_NAME_MAX _POSIX_TRACE_NAME_MAX
#define __z_posix_sysconf_SC_TRACE_INHERIT (-1L)
#define __z_posix_sysconf_SC_TRACE_LOG (-1L)
#define __z_posix_sysconf_SC_TRACE_NAME_MAX _POSIX_TRACE_NAME_MAX
#define __z_posix_sysconf_SC_TRACE_SYS_MAX _POSIX_TRACE_SYS_MAX
#define __z_posix_sysconf_SC_TRACE_USER_EVENT_MAX _POSIX_TRACE_USER_EVENT_MAX
Expand All @@ -211,7 +229,7 @@ enum {
#define __z_posix_sysconf_SC_2_C_DEV _POSIX2_C_DEV
#define __z_posix_sysconf_SC_2_CHAR_TERM (-1L)
#define __z_posix_sysconf_SC_COLL_WEIGHTS_MAX _POSIX2_COLL_WEIGHTS_MAX
#define __z_posix_sysconf_SC_DELAYTIMER_MAX _POSIX2_DELAYTIMER_MAX
#define __z_posix_sysconf_SC_DELAYTIMER_MAX _POSIX_DELAYTIMER_MAX
#define __z_posix_sysconf_SC_EXPR_NEST_MAX _POSIX2_EXPR_NEST_MAX
#define __z_posix_sysconf_SC_2_FORT_DEV (-1L)
#define __z_posix_sysconf_SC_2_FORT_RUN (-1L)
Expand Down
4 changes: 2 additions & 2 deletions lib/libc/minimal/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ config MINIMAL_LIBC_RAND

config MINIMAL_LIBC_TIME
bool "Time functions"
select COMMON_LIBC_TIME if POSIX_CLOCK
select COMMON_LIBC_TIME if POSIX_TIMERS
select COMMON_LIBC_GMTIME_R
default y
help
Enable time() and gmtime_r() for the minimal libc.

time() requires CONFIG_POSIX_CLOCK=y because it relies on the POSIX
time() requires CONFIG_POSIX_TIMERS=y because it relies on the POSIX
clock_gettime() function.

In order to make use of the non-reentrant gmtime(), it is necessary
Expand Down
2 changes: 1 addition & 1 deletion lib/libc/newlib/libc-hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void *_sbrk_r(struct _reent *r, int count)

int _gettimeofday(struct timeval *__tp, void *__tzp)
{
#ifdef CONFIG_POSIX_CLOCK
#ifdef CONFIG_XSI_SINGLE_PROCESS
return gettimeofday(__tp, __tzp);
#else
/* Non-posix systems should not call gettimeofday() here as it will
Expand Down
13 changes: 8 additions & 5 deletions lib/posix/options/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if(CONFIG_POSIX_SIGNAL)
)
endif()

if(CONFIG_POSIX_API OR CONFIG_PTHREAD_IPC OR CONFIG_POSIX_CLOCK OR
if(CONFIG_POSIX_API OR CONFIG_PTHREAD_IPC OR CONFIG_POSIX_TIMERS OR
CONFIG_POSIX_MQUEUE OR CONFIG_POSIX_FS OR CONFIG_EVENTFD OR CONFIG_GETOPT)
# This is a temporary workaround so that Newlib declares the appropriate
# types for us. POSIX features to be formalized as part of #51211
Expand All @@ -39,18 +39,22 @@ zephyr_library_sources_ifdef(CONFIG_FNMATCH fnmatch.c)
zephyr_library_sources_ifdef(CONFIG_GETENTROPY getentropy.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_API perror.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_ASYNCHRONOUS_IO aio.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK clock.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK nanosleep.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK sleep.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_CONFSTR confstr.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_ENV env.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_FS fs.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_MQUEUE mqueue.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_MULTI_PROCESS
sleep.c
)
zephyr_library_sources_ifdef(CONFIG_POSIX_NETWORKING net.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_PUTMSG stropts.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_SIGNAL signal.c ${STRSIGNAL_TABLE_H})
zephyr_library_sources_ifdef(CONFIG_POSIX_SYSCONF_IMPL_FULL sysconf.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_SYSLOG syslog.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_TIMERS
clock.c
timer.c
)
zephyr_library_sources_ifdef(CONFIG_POSIX_UNAME uname.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC _common.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_BARRIER barrier.c)
Expand All @@ -62,7 +66,6 @@ zephyr_library_sources_ifdef(CONFIG_PTHREAD_RWLOCK rwlock.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_PRIORITY_SCHEDULING sched.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC semaphore.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_SPINLOCK spinlock.c)
zephyr_library_sources_ifdef(CONFIG_TIMER timer.c)

zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
Expand Down
8 changes: 3 additions & 5 deletions lib/posix/options/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,17 @@ config POSIX_API
Enable mostly-standards-compliant implementations of
various POSIX (IEEE 1003.1) APIs.

if POSIX_CLOCK

config PTHREAD_IPC
bool "POSIX pthread IPC API"
default y if POSIX_API
depends on POSIX_TIMERS
help
This enables a mostly-standards-compliant implementation of
the pthread mutex, condition variable and barrier IPC
mechanisms.

endif # POSIX_CLOCK

rsource "Kconfig.aio"
rsource "Kconfig.barrier"
rsource "Kconfig.clock"
rsource "Kconfig.cond"
rsource "Kconfig.confstr"
rsource "Kconfig.env"
Expand All @@ -41,6 +37,7 @@ rsource "Kconfig.key"
rsource "Kconfig.mqueue"
rsource "Kconfig.mutex"
rsource "Kconfig.net"
rsource "Kconfig.procN"
rsource "Kconfig.pthread"
rsource "Kconfig.rwlock"
rsource "Kconfig.sched"
Expand All @@ -52,6 +49,7 @@ rsource "Kconfig.sysconf"
rsource "Kconfig.syslog"
rsource "Kconfig.timer"
rsource "Kconfig.uname"
rsource "Kconfig.xsi"

rsource "Kconfig.deprecated"

Expand Down
11 changes: 0 additions & 11 deletions lib/posix/options/Kconfig.clock

This file was deleted.

Loading

0 comments on commit 7f91781

Please sign in to comment.