zephyr/include
Andy Ross 7832738ae9 kernel/timeout: Make timeout arguments an opaque type
Add a k_timeout_t type, and use it everywhere that kernel API
functions were accepting a millisecond timeout argument.  Instead of
forcing milliseconds everywhere (which are often not integrally
representable as system ticks), do the conversion to ticks at the
point where the timeout is created.  This avoids an extra unit
conversion in some application code, and allows us to express the
timeout in units other than milliseconds to achieve greater precision.

The existing K_MSEC() et. al. macros now return initializers for a
k_timeout_t.

The K_NO_WAIT and K_FOREVER constants have now become k_timeout_t
values, which means they cannot be operated on as integers.
Applications which have their own APIs that need to inspect these
vs. user-provided timeouts can now use a K_TIMEOUT_EQ() predicate to
test for equality.

Timer drivers, which receive an integer tick count in ther
z_clock_set_timeout() functions, now use the integer-valued
K_TICKS_FOREVER constant instead of K_FOREVER.

For the initial release, to preserve source compatibility, a
CONFIG_LEGACY_TIMEOUT_API kconfig is provided.  When true, the
k_timeout_t will remain a compatible 32 bit value that will work with
any legacy Zephyr application.

Some subsystems present timeout (or timeout-like) values to their own
users as APIs that would re-use the kernel's own constants and
conventions.  These will require some minor design work to adapt to
the new scheme (in most cases just using k_timeout_t directly in their
own API), and they have not been changed in this patch, instead
selecting CONFIG_LEGACY_TIMEOUT_API via kconfig.  These subsystems
include: CAN Bus, the Microbit display driver, I2S, LoRa modem
drivers, the UART Async API, Video hardware drivers, the console
subsystem, and the network buffer abstraction.

k_sleep() now takes a k_timeout_t argument, with a k_msleep() variant
provided that works identically to the original API.

Most of the changes here are just type/configuration management and
documentation, but there are logic changes in mempool, where a loop
that used a timeout numerically has been reworked using a new
z_timeout_end_calc() predicate.  Also in queue.c, a (when POLL was
enabled) a similar loop was needlessly used to try to retry the
k_poll() call after a spurious failure.  But k_poll() does not fail
spuriously, so the loop was removed.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
..
app_memory kernel: fix k_mem_partition data types 2019-12-12 14:48:42 -08:00
arch arm: AArch64: Add support for nested exception handlers 2020-03-31 19:24:48 +02:00
audio doc: reference: Add pages for audio 2020-03-18 11:47:24 +01:00
bluetooth Bluetooth: host: Fix high-duty cycle directed extended advertising 2020-03-31 12:48:19 +03:00
canbus doc: doxygen: add missing groups and categorise 2020-03-14 13:01:03 -04:00
cmsis_rtos_v1
cmsis_rtos_v2 global: Remove leading/trailing blank lines in files 2019-12-11 19:17:27 +01:00
console
crypto docs: crypto: crypto API documentation 2020-03-14 13:01:03 -04:00
data treewide: avoid address-of-compound-literal idiom in headers 2019-12-18 21:53:17 +01:00
debug include: debug: remove old stack functions 2020-03-14 13:10:19 -04:00
devicetree devicetree: Rename spi cs gpio macros 2020-03-26 12:24:23 -05:00
dfu DFU: add init function with area id as parameter 2020-03-10 15:07:27 +02:00
disk doc: reference: Add disk access API 2020-03-18 11:47:24 +01:00
display
drivers kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
dt-bindings gpio: restore missing legacy devicetree direction flag 2020-02-13 22:50:45 +02:00
fs fs: remove NFFS subsystem 2020-01-21 15:32:47 +01:00
linker kernel: add sys init level for SMP 2020-03-25 19:07:28 -04:00
logging logging: Fix LOG_LEVEL_SET macro 2020-03-26 08:04:02 -04:00
mgmt subsys/mgmt: Enabling mynewt-core version of tinycbor 2020-03-17 11:58:18 +01:00
net net: Expose a way to know if the network interface is suspended or not 2020-03-27 14:48:30 +02:00
posix pthread: add setname/getname glibc extensions 2020-03-10 15:15:34 +02:00
power power: add system power management direct force mode. 2020-01-24 21:37:40 -05:00
random doc: doxygen: add missing groups and categorise 2020-03-14 13:01:03 -04:00
settings doc: doxygen: add missing groups and categorise 2020-03-14 13:01:03 -04:00
shell global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT() 2020-03-31 07:18:06 +02:00
stats
storage doc: fix flash_area_get_sectors doc 2019-10-25 16:40:12 -05:00
sys kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
toolchain toolchain: common: Merge build assert macros 2020-03-31 07:18:06 +02:00
tracing tracing: move headers under include/tracing 2020-02-07 15:58:05 -05:00
usb usb: make usb descriptor power options configurable 2019-12-20 19:46:16 -05:00
zephyr include: Remove compat include headers 2019-12-10 08:39:37 -05:00
cache.h
device.h device: Provide a dummy macro for device_pm_control_nop on disabled PM 2020-03-27 14:48:30 +02:00
devicetree.h devicetree.h: fix typo in docstring 2020-03-29 09:10:04 -05:00
exc_handle.h kernel: rename z_arch_ to arch_ 2019-11-07 15:21:46 -08:00
fatal.h doc: fix misspelling in API doxygen comments 2019-10-29 06:00:14 +01:00
generated_dts_board.h dts: Add include/generated_dts_board.h for backwards compatibility 2020-01-17 17:57:59 +01:00
init.h kernel: add sys init level for SMP 2020-03-25 19:07:28 -04:00
irq_nextlevel.h include: respect line limit in api pointer initialization 2019-12-16 21:14:08 -05:00
irq_offload.h kernel: sychronize irq_offload() access 2019-11-08 15:16:43 -08:00
irq.h api: irq: Add Multi-level IRQ utility functions 2020-03-28 07:12:30 -04:00
kernel_includes.h headers: Refactor kernel and arch headers. 2019-11-06 16:07:32 -08:00
kernel_structs.h kernel/userspace: Move syscall_frame field to thread struct 2020-02-08 08:51:04 -05:00
kernel_version.h
kernel.h kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
ptp_clock.h scripts: Replace hard-coded subsystem list with __subsystem annotations. 2020-03-11 17:13:39 +02:00
sched_priq.h
shared_irq.h include: respect line limit in api pointer initialization 2019-12-16 21:14:08 -05:00
spinlock.h global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT() 2020-03-31 07:18:06 +02:00
sw_isr_table.h
sys_clock.h kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
syscall_handler.h kernel: rename struct _k_object 2020-03-17 20:11:27 +02:00
syscall.h global: Remove leading/trailing blank lines in files 2019-12-11 19:17:27 +01:00
timeout_q.h kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
toolchain.h toolchain: Fix for off-tree toolchains 2019-10-08 17:09:23 -04:00
wait_q.h headers: Refactor kernel and arch headers. 2019-11-06 16:07:32 -08:00
zephyr.h