zpp
Zephyr C++20 Framework
zpp Namespace Reference

Namespaces

 internal
 
 this_thread
 provide functions that access the current thread of execution.
 

Classes

class  atomic_bitset
 class wrapping an atomic_var_t array More...
 
class  atomic_var
 class wrapping an atomic_var_t More...
 
class  uptime_clock
 Clock measuring elapsed time since the system booted. More...
 
class  cycle_clock
 Clock representing the system’s hardware clock. More...
 
class  condition_variable_base
 A condition variable CRTP base class. More...
 
class  condition_variable
 A condition variable class. More...
 
class  condition_variable_ref
 A class using a reference to another native condition variable or zpp::condition_variable. More...
 
class  fifo_base
 Fifo CRTP base class. More...
 
class  fifo
 fifo that manages a k_fifo object More...
 
class  fifo_ref
 fifo that references a k_fifo object More...
 
class  futex_base
 A CRTP futex base class. More...
 
class  futex
 A futex class. More...
 
class  futex_ref
 A futex class referencing another futex object. More...
 
class  base_heap
 Heap memory allocater CRTP base class. More...
 
class  heap
 heap class More...
 
class  heap_ref
 heap reference class More...
 
class  lock_guard
 lock_guard using zpp::mutex as a lock. More...
 
class  mem_slab_base
 Allocator that uses k_mem_slab for memory. More...
 
class  mem_slab
 A memory slab class. More...
 
class  mem_slab_ref
 A mem_slab class referencing another mem slab object. More...
 
class  mutex_base
 A recursive mutex CRTP base class. More...
 
class  mutex
 A recursive mutex class. More...
 
class  mutex_ref
 A recursive mutex class borrowing the native mutex. More...
 
class  poll_event
 wrapper class around a k_poll_event More...
 
class  poll_event_set
 A set of poll events. More...
 
class  poll_signal_base
 CRTP base class for poll_signals. More...
 
class  poll_signal
 class owning a k_poll_signal More...
 
class  poll_signal_ref
 class wrapping a k_poll_signal More...
 
class  error_result
 helper class for error result More...
 
class  result
 result class More...
 
class  result< void, T_Error >
 result class More...
 
class  sched_lock_guard
 Guard to automatically lock/unlock scheduler. More...
 
class  sem_base
 Counting semaphore base class. More...
 
class  sem
 A counting semaphore class. More...
 
class  sem_ref
 A counting semaphore class borrowing the native sem. More...
 
class  sys_mutex_base
 A userspace mutex class. More...
 
class  sys_mutex
 A recursive mutex class. More...
 
class  sys_mutex_ref
 A recursive mutex class borrowing the native mutex. More...
 
class  thread
 The class thread repecents a single Zephyr thread. More...
 
struct  thread_start_delay
 
class  thread_attr
 Thread creation attributes. More...
 
class  thread_data
 thread_data holds the stack and thread control block memory More...
 
class  thread_id
 Thead ID. More...
 
class  thread_prio
 Thread priority. More...
 
class  thread_stack
 thread_stack holds the stack and thread control block memory More...
 
class  timer_base
 base class for the timer class More...
 
class  timer
 timer class with expire and stop callbacks More...
 
class  basic_timer
 timer class with only an expire callback More...
 
class  sync_timer
 timer class with no callbacks used for syncing only More...
 
class  unique_lock
 zpp::unique_lock using zpp::mutex as a lock. More...
 

Enumerations

enum class  error_code {
  k_perm = EPERM , k_noent = ENOENT , k_srch = ESRCH , k_intr = EINTR ,
  k_io = EIO , k_nxio = ENXIO , k_2big = E2BIG , k_noexec = ENOEXEC ,
  k_badf = EBADF , k_child = ECHILD , k_again = EAGAIN , k_nomem = ENOMEM ,
  k_acces = EACCES , k_fault = EFAULT , k_notblk = ENOTBLK , k_busy = EBUSY ,
  k_exits = EEXIST , k_xdev = EXDEV , k_nodev = ENODEV , k_notdir = ENOTDIR ,
  k_isdir = EISDIR , k_inval = EINVAL , k_nfile = ENFILE , k_mfile = EMFILE ,
  k_notty = ENOTTY , k_txtbsy = ETXTBSY , k_fbig = EFBIG , k_nospc = ENOSPC ,
  k_spipe = ESPIPE , k_rofs = EROFS , k_mlink = EMLINK , k_pipe = EPIPE ,
  k_dom = EDOM , k_range = ERANGE , k_nomsg = ENOMSG , k_deadlk = EDEADLK ,
  k_nolck = ENOLCK , k_nostr = ENOSTR , k_nodata = ENODATA , k_time = ETIME ,
  k_nosr = ENOSR , k_proto = EPROTO , k_badmsg = EBADMSG , k_nosys = ENOSYS ,
  k_notempty = ENOTEMPTY , k_nametoolong = ENAMETOOLONG , k_loop = ELOOP , k_opnotsupp = EOPNOTSUPP ,
  k_pfnosupport = EPFNOSUPPORT , k_connreset = ECONNRESET , k_nobufs = ENOBUFS , k_afnosupport = EAFNOSUPPORT ,
  k_prototype = EPROTOTYPE , k_notsock = ENOTSOCK , k_noprotoopt = ENOPROTOOPT , k_shutdown = ESHUTDOWN ,
  k_connrefused = ECONNREFUSED , k_addrinuse = EADDRINUSE , k_connaborted = ECONNABORTED , k_netunreach = ENETUNREACH ,
  k_netdown = ENETDOWN , k_timeout = ETIMEDOUT , k_hostdown = EHOSTDOWN , k_hostunreach = EHOSTUNREACH ,
  k_inprogress = EINPROGRESS , k_already = EALREADY , k_destaddrreq = EDESTADDRREQ , k_msgsize = EMSGSIZE ,
  k_protonosupport = EPROTONOSUPPORT , k_socktnosupport = ESOCKTNOSUPPORT , k_addrnotavail = EADDRNOTAVAIL , k_netreset = ENETRESET ,
  k_isconn = EISCONN , k_notconn = ENOTCONN , k_toomanyrefs = ETOOMANYREFS , k_notsup = ENOTSUP ,
  k_ilseq = EILSEQ , k_overflow = EOVERFLOW , k_canceled = ECANCELED , k_wouldblock = EWOULDBLOCK
}
 enum with zephyr error codes More...
 
enum class  thread_suspend { yes , no }
 
enum class  thread_essential { yes , no }
 
enum class  thread_user { yes , no }
 
enum class  thread_inherit_perms { yes , no }
 
enum class  thread_fp_regs { yes , no }
 
enum class  thread_sse_regs { yes , no }
 

Functions

template<class T_Rep , class T_Period >
constexpr k_ticks_t to_tick (const std::chrono::duration< T_Rep, T_Period > &d) noexcept
 convert a duration to tick More...
 
template<class T_Rep , class T_Period >
constexpr k_timeout_t to_timeout (const std::chrono::duration< T_Rep, T_Period > &d) noexcept
 convert a duration to tick More...
 
constexpr error_code to_error_code (int v) noexcept
 
template<class ... T_Args>
void print (const char *fmt, T_Args &&... args) noexcept
 simple typesafe print function More...
 
template<class... T_Args>
 poll_event_set (T_Args &&... t) noexcept -> poll_event_set< sizeof...(T_Args)>
 try poll events waiting for e certain time More...
 
template<typename T_Ok , typename T_Error >
constexpr bool operator== (const result< T_Ok, T_Error > &lhs, bool rhs) noexcept
 compare result with bool More...
 
template<typename T_Ok , typename T_Error >
constexpr bool operator== (bool lhs, const result< T_Ok, T_Error > &rhs) noexcept
 compare result with bool More...
 
template<typename T_Ok , typename T_Error >
constexpr bool operator!= (const result< T_Ok, T_Error > &lhs, bool rhs) noexcept
 compare result with bool More...
 
template<typename T_Ok , typename T_Error >
constexpr bool operator!= (bool lhs, const result< T_Ok, T_Error > &rhs) noexcept
 compare result with bool More...
 
void sched_lock () noexcept
 Lock the scheduler. More...
 
void sched_unlock () noexcept
 Unlock the scheduler. More...
 
template<class T >
std::decay< T >::type decay_copy (T &&v) noexcept
 
constexpr bool operator== (const thread_id &lhs, const thread_id &rhs) noexcept
 Compare if two ID are equal. More...
 
constexpr bool operator!= (const thread_id &lhs, const thread_id &rhs) noexcept
 Compare if two ID are not equal. More...
 
void print_arg (thread_id id) noexcept
 Helper to output the ID with zpp::print("{}", id) More...
 
constexpr bool operator== (const thread_prio &lhs, const thread_prio &rhs) noexcept
 Compare if two priorities are equal. More...
 
constexpr bool operator!= (const thread_prio &lhs, const thread_prio &rhs) noexcept
 Compare if two priorities are not equal. More...
 
constexpr thread_prio operator- (thread_prio lhs, int rhs) noexcept
 Reduce priority by rhs. More...
 
constexpr thread_prio operator+ (thread_prio lhs, int rhs) noexcept
 Increase priority by rhs. More...
 
void print_arg (thread_prio prio) noexcept
 Helper to output the priority with zpp::print("{}", prio) More...
 
auto make_timer () noexcept
 create sync_timer object More...
 
template<class T_ExpireCallback >
auto make_timer (T_ExpireCallback &&ecb) noexcept
 create basic_timer object More...
 
template<class T_ExpireCallback , class T_StopCallback >
auto make_timer (T_ExpireCallback &&ecb, T_StopCallback &&scb) noexcept
 create timer object More...
 
template<class T_LHS , class T_RHS >
constexpr bool operator== (const T_LHS &lhs, const T_RHS &rhs) noexcept
 check if the instances refere to the same native zephyr object handle. More...
 
template<class T_LHS , class T_RHS >
constexpr bool operator!= (const T_LHS &lhs, const T_RHS &rhs) noexcept
 check if the arguments refere to different native zephyr object handles. More...
 
consteval uint32_t power_of_two (uint32_t power) noexcept
 calculate a power of 2 More...
 
consteval bool is_power_of_two (uint32_t value) noexcept
 check if a value is a power of two More...
 
consteval bool is_multiple_of (uint32_t value, uint32_t base)
 Check if a value is a multiple of another value. More...
 

Detailed Description

Copyright (c) 2021 Erwin Rol erwin.nosp@m.@erw.nosp@m.inrol.nosp@m..com

SPDX-License-Identifier: Apache-2.0

Copyright (c) 2019 Erwin Rol erwin.nosp@m.@erw.nosp@m.inrol.nosp@m..com

SPDX-License-Identifier: Apache-2.0

Enumeration Type Documentation

◆ error_code

enum zpp::error_code
strong

enum with zephyr error codes

Enumerator
k_perm 

Not owner.

k_noent 

No such file or directory.

k_srch 

No such context.

k_intr 

Interrupted system call.

k_io 

I/O error.

k_nxio 

No such device or address.

k_2big 

Arg list too long.

k_noexec 

Exec format error.

k_badf 

Bad file number.

k_child 

No children.

k_again 

No more contexts.

k_nomem 

Not enough core.

k_acces 

Permission denied.

k_fault 

Bad address.

k_notblk 

Block device required.

k_busy 

Mount device busy.

k_exits 

File exists.

k_xdev 

Cross-device link.

k_nodev 

No such device.

k_notdir 

Not a directory.

k_isdir 

Is a directory.

k_inval 

Invalid argument.

k_nfile 

File table overflow.

k_mfile 

Too many open files.

k_notty 

Not a typewriter.

k_txtbsy 

Text file busy.

k_fbig 

File too large.

k_nospc 

No space left on device.

k_spipe 

Illegal seek.

k_rofs 

Read-only file system.

k_mlink 

Too many links.

k_pipe 

Broken pipe.

k_dom 

Argument too large.

k_range 

Result too large.

k_nomsg 

Unexpected message type.

k_deadlk 

Resource deadlock avoided.

k_nolck 

No locks available.

k_nostr 

STREAMS device required.

k_nodata 

Missing expected message data.

k_time 

STREAMS timeout occurred.

k_nosr 

Insufficient memory.

k_proto 

Generic STREAMS error.

k_badmsg 

Invalid STREAMS message.

k_nosys 

Function not implemented.

k_notempty 

Directory not empty.

k_nametoolong 

File name too long.

k_loop 

Too many levels of symbolic links.

k_opnotsupp 

Operation not supported on socket.

k_pfnosupport 

Protocol family not supported.

k_connreset 

Connection reset by peer.

k_nobufs 

No buffer space available.

k_afnosupport 

Addr family not supported.

k_prototype 

Protocol wrong type for socket.

k_notsock 

Socket operation on non-socket.

k_noprotoopt 

Protocol not available.

k_shutdown 

Can’t send after socket shutdown.

k_connrefused 

Connection refused.

k_addrinuse 

Address already in use.

k_connaborted 

Software caused connection abort.

k_netunreach 

Network is unreachable.

k_netdown 

Network is down.

k_timeout 

Connection timed out.

k_hostdown 

Host is down.

k_hostunreach 

No route to host.

k_inprogress 

Operation now in progress.

k_already 

Operation already in progress.

k_destaddrreq 

Destination address required.

k_msgsize 

Message size.

k_protonosupport 

Protocol not supported.

k_socktnosupport 

Socket type not supported.

k_addrnotavail 

Can’t assign requested address.

k_netreset 

Network dropped connection on reset.

k_isconn 

Socket is already connected.

k_notconn 

Socket is not connected.

k_toomanyrefs 

Too many references: can’t splice.

k_notsup 

Unsupported value.

k_ilseq 

Illegal byte sequence.

k_overflow 

Value overflow.

k_canceled 

Operation canceled.

k_wouldblock 

Operation would block.

Definition at line 19 of file error_code.hpp.

19  {
20  k_perm = EPERM,
21  k_noent = ENOENT,
22  k_srch = ESRCH,
23  k_intr = EINTR,
24  k_io = EIO,
25  k_nxio = ENXIO,
26  k_2big = E2BIG,
27  k_noexec = ENOEXEC,
28  k_badf = EBADF,
29  k_child = ECHILD,
30  k_again = EAGAIN,
31  k_nomem = ENOMEM,
32  k_acces = EACCES,
33  k_fault = EFAULT,
34  k_notblk = ENOTBLK,
35  k_busy = EBUSY,
36  k_exits = EEXIST,
37  k_xdev = EXDEV,
38  k_nodev = ENODEV,
39  k_notdir = ENOTDIR,
40  k_isdir = EISDIR,
41  k_inval = EINVAL,
42  k_nfile = ENFILE,
43  k_mfile = EMFILE,
44  k_notty = ENOTTY,
45  k_txtbsy = ETXTBSY,
46  k_fbig = EFBIG,
47  k_nospc = ENOSPC,
48  k_spipe = ESPIPE,
49  k_rofs = EROFS,
50  k_mlink = EMLINK,
51  k_pipe = EPIPE,
52  k_dom = EDOM,
53  k_range = ERANGE,
54  k_nomsg = ENOMSG,
55  k_deadlk = EDEADLK,
56  k_nolck = ENOLCK,
57  k_nostr = ENOSTR,
58  k_nodata = ENODATA,
59  k_time = ETIME,
60  k_nosr = ENOSR,
61  k_proto = EPROTO,
62  k_badmsg = EBADMSG,
63  k_nosys = ENOSYS,
64  k_notempty = ENOTEMPTY,
65  k_nametoolong = ENAMETOOLONG,
66  k_loop = ELOOP,
67  k_opnotsupp = EOPNOTSUPP,
68  k_pfnosupport = EPFNOSUPPORT,
69  k_connreset = ECONNRESET,
70  k_nobufs = ENOBUFS,
71  k_afnosupport = EAFNOSUPPORT,
72  k_prototype = EPROTOTYPE,
73  k_notsock = ENOTSOCK,
74  k_noprotoopt = ENOPROTOOPT,
75  k_shutdown = ESHUTDOWN,
76  k_connrefused = ECONNREFUSED,
77  k_addrinuse = EADDRINUSE,
78  k_connaborted = ECONNABORTED,
79  k_netunreach = ENETUNREACH,
80  k_netdown = ENETDOWN,
81  k_timeout = ETIMEDOUT,
82  k_hostdown = EHOSTDOWN,
83  k_hostunreach = EHOSTUNREACH,
84  k_inprogress = EINPROGRESS,
85  k_already = EALREADY,
86  k_destaddrreq = EDESTADDRREQ,
87  k_msgsize = EMSGSIZE,
88  k_protonosupport = EPROTONOSUPPORT,
89  k_socktnosupport = ESOCKTNOSUPPORT,
90  k_addrnotavail = EADDRNOTAVAIL,
91  k_netreset = ENETRESET,
92  k_isconn = EISCONN,
93  k_notconn = ENOTCONN,
94  k_toomanyrefs = ETOOMANYREFS,
95  k_notsup = ENOTSUP,
96  k_ilseq = EILSEQ,
97  k_overflow = EOVERFLOW,
98  k_canceled = ECANCELED,
99  k_wouldblock = EWOULDBLOCK,
100 };
@ k_again
No more contexts.
@ k_canceled
Operation canceled.
@ k_toomanyrefs
Too many references: can’t splice.
@ k_wouldblock
Operation would block.
@ k_notsup
Unsupported value.
@ k_time
STREAMS timeout occurred.
@ k_inval
Invalid argument.
@ k_netreset
Network dropped connection on reset.
@ k_protonosupport
Protocol not supported.
@ k_xdev
Cross-device link.
@ k_pipe
Broken pipe.
@ k_shutdown
Can’t send after socket shutdown.
@ k_busy
Mount device busy.
@ k_dom
Argument too large.
@ k_badf
Bad file number.
@ k_exits
File exists.
@ k_nostr
STREAMS device required.
@ k_nolck
No locks available.
@ k_ilseq
Illegal byte sequence.
@ k_nametoolong
File name too long.
@ k_hostunreach
No route to host.
@ k_notty
Not a typewriter.
@ k_nfile
File table overflow.
@ k_badmsg
Invalid STREAMS message.
@ k_range
Result too large.
@ k_isconn
Socket is already connected.
@ k_addrnotavail
Can’t assign requested address.
@ k_opnotsupp
Operation not supported on socket.
@ k_intr
Interrupted system call.
@ k_proto
Generic STREAMS error.
@ k_nosr
Insufficient memory.
@ k_deadlk
Resource deadlock avoided.
@ k_fault
Bad address.
@ k_nomsg
Unexpected message type.
@ k_prototype
Protocol wrong type for socket.
@ k_notsock
Socket operation on non-socket.
@ k_msgsize
Message size.
@ k_noexec
Exec format error.
@ k_child
No children.
@ k_already
Operation already in progress.
@ k_notblk
Block device required.
@ k_txtbsy
Text file busy.
@ k_overflow
Value overflow.
@ k_perm
Not owner.
@ k_socktnosupport
Socket type not supported.
@ k_2big
Arg list too long.
@ k_spipe
Illegal seek.
@ k_mlink
Too many links.
@ k_nospc
No space left on device.
@ k_loop
Too many levels of symbolic links.
@ k_connaborted
Software caused connection abort.
@ k_isdir
Is a directory.
@ k_afnosupport
Addr family not supported.
@ k_connreset
Connection reset by peer.
@ k_rofs
Read-only file system.
@ k_notempty
Directory not empty.
@ k_addrinuse
Address already in use.
@ k_notdir
Not a directory.
@ k_timeout
Connection timed out.
@ k_io
I/O error.
@ k_nosys
Function not implemented.
@ k_noent
No such file or directory.
@ k_noprotoopt
Protocol not available.
@ k_nobufs
No buffer space available.
@ k_connrefused
Connection refused.
@ k_acces
Permission denied.
@ k_nodata
Missing expected message data.
@ k_nomem
Not enough core.
@ k_nxio
No such device or address.
@ k_fbig
File too large.
@ k_notconn
Socket is not connected.
@ k_hostdown
Host is down.
@ k_mfile
Too many open files.
@ k_netdown
Network is down.
@ k_netunreach
Network is unreachable.
@ k_destaddrreq
Destination address required.
@ k_nodev
No such device.
@ k_pfnosupport
Protocol family not supported.
@ k_srch
No such context.
@ k_inprogress
Operation now in progress.

◆ thread_essential

enum zpp::thread_essential
strong
Enumerator
yes 
no 

Definition at line 21 of file thread_attr.hpp.

◆ thread_fp_regs

enum zpp::thread_fp_regs
strong
Enumerator
yes 
no 

Definition at line 24 of file thread_attr.hpp.

24 { yes, no };

◆ thread_inherit_perms

Enumerator
yes 
no 

Definition at line 23 of file thread_attr.hpp.

23 { yes, no };

◆ thread_sse_regs

enum zpp::thread_sse_regs
strong
Enumerator
yes 
no 

Definition at line 25 of file thread_attr.hpp.

25 { yes, no };

◆ thread_suspend

enum zpp::thread_suspend
strong
Enumerator
yes 
no 

Definition at line 20 of file thread_attr.hpp.

20 { yes, no };

◆ thread_user

enum zpp::thread_user
strong
Enumerator
yes 
no 

Definition at line 22 of file thread_attr.hpp.

22 { yes, no };

Function Documentation

◆ decay_copy()

template<class T >
std::decay<T>::type zpp::decay_copy ( T &&  v)
noexcept

Definition at line 139 of file thread.hpp.

140 {
141  return std::forward<T>(v);
142 }

Referenced by zpp::thread::thread().

◆ is_multiple_of()

consteval bool zpp::is_multiple_of ( uint32_t  value,
uint32_t  base 
)

Check if a value is a multiple of another value.

Parameters
valuethe value to check
basethe base the value should be a multiple of
Returns
true if value is a multiple of base

Definition at line 117 of file utils.hpp.

118 {
119  if (value == 0 || base == 0) {
120  return false;
121  } else {
122  return (value % base) == 0;
123  }
124 }

◆ is_power_of_two()

consteval bool zpp::is_power_of_two ( uint32_t  value)
noexcept

check if a value is a power of two

Parameters
valuethe value to check
Returns
true if value is a power of two

Definition at line 97 of file utils.hpp.

98 {
99  uint32_t power {0};
100  uint32_t calc_val;
101 
102  do {
103  calc_val = power_of_two(power++);
104  } while (calc_val < value);
105 
106  return calc_val == value;
107 }
consteval uint32_t power_of_two(uint32_t power) noexcept
calculate a power of 2
Definition: utils.hpp:79

References power_of_two().

◆ make_timer() [1/3]

auto zpp::make_timer ( )
inlinenoexcept

create sync_timer object

Returns
sync_timer object

Definition at line 233 of file timer.hpp.

234 {
235  return sync_timer();
236 }

Referenced by ZTEST().

◆ make_timer() [2/3]

template<class T_ExpireCallback >
auto zpp::make_timer ( T_ExpireCallback &&  ecb)
inlinenoexcept

create basic_timer object

Parameters
ecbthe expire callback
Returns
basic_timer object

Definition at line 246 of file timer.hpp.

247 {
248  return basic_timer(std::forward<T_ExpireCallback>(ecb));
249 }

◆ make_timer() [3/3]

template<class T_ExpireCallback , class T_StopCallback >
auto zpp::make_timer ( T_ExpireCallback &&  ecb,
T_StopCallback &&  scb 
)
inlinenoexcept

create timer object

Parameters
ecbthe expire callback
scbthe stop callback
Returns
timer object

Definition at line 260 of file timer.hpp.

261 {
262  return timer(std::forward<T_ExpireCallback>(ecb), std::forward<T_StopCallback>(scb));
263 }

◆ operator!=() [1/5]

template<typename T_Ok , typename T_Error >
constexpr bool zpp::operator!= ( bool  lhs,
const result< T_Ok, T_Error > &  rhs 
)
constexprnoexcept

compare result with bool

Parameters
lhsthe bool value
rhsthe result value
Returns
true if lhs is not equal to rhs

Definition at line 694 of file result.hpp.

694  {
695  return bool(lhs) != bool(rhs);
696 }

◆ operator!=() [2/5]

template<typename T_Ok , typename T_Error >
constexpr bool zpp::operator!= ( const result< T_Ok, T_Error > &  lhs,
bool  rhs 
)
constexprnoexcept

compare result with bool

Parameters
lhsthe result value
rhsthe bool value
Returns
true if lhs is not equal to rhs

Definition at line 681 of file result.hpp.

681  {
682  return bool(lhs) != bool(rhs);
683 }

◆ operator!=() [3/5]

template<class T_LHS , class T_RHS >
constexpr bool zpp::operator!= ( const T_LHS &  lhs,
const T_RHS &  rhs 
)
constexprnoexcept

check if the arguments refere to different native zephyr object handles.

Returns
true if they refer to different native zephyr objects.

Definition at line 50 of file utils.hpp.

51 {
52  if constexpr (std::is_pointer_v<T_LHS> && std::is_pointer_v<T_RHS>) {
53  return lhs != rhs;
54  }
55 
56  if constexpr (std::is_pointer_v<T_LHS> && !std::is_pointer_v<T_RHS>) {
57  return lhs != rhs.native_handle();
58  }
59 
60  if constexpr (!std::is_pointer_v<T_LHS> && std::is_pointer_v<T_RHS>) {
61  return lhs.native_handle() != rhs;
62  }
63 
64  if constexpr (!std::is_pointer_v<T_LHS> && !std::is_pointer_v<T_RHS>) {
65  return lhs.native_handle() != rhs.native_handle();
66  }
67 
68  static_assert(true, "should never be reached");
69  return false;
70 }

◆ operator!=() [4/5]

constexpr bool zpp::operator!= ( const thread_id lhs,
const thread_id rhs 
)
constexprnoexcept

Compare if two ID are not equal.

Parameters
lhsLeft hand side for comparison
rhsRight hand side for comparison
Returns
true is lhs and rhs are not equal

Definition at line 98 of file thread_id.hpp.

99 {
100  return (lhs.native_handle() != rhs.native_handle());
101 }

◆ operator!=() [5/5]

constexpr bool zpp::operator!= ( const thread_prio lhs,
const thread_prio rhs 
)
constexprnoexcept

Compare if two priorities are not equal.

Parameters
lhsLeft hand side for comparison
rhsRight hand side for comparison
Returns
true is lhs and rhs are not equal

Definition at line 219 of file thread_prio.hpp.

220 {
221  return (lhs.native_value() != rhs.native_value());
222 }

◆ operator+()

constexpr thread_prio zpp::operator+ ( thread_prio  lhs,
int  rhs 
)
constexprnoexcept

Increase priority by rhs.

Parameters
lhsLeft hand side for the operation
rhsRight hand side for the operation
Returns
A priority value that is rhs more prior than lhs

Definition at line 247 of file thread_prio.hpp.

248 {
249  return thread_prio(lhs.native_value() - rhs);
250 }

◆ operator-()

constexpr thread_prio zpp::operator- ( thread_prio  lhs,
int  rhs 
)
constexprnoexcept

Reduce priority by rhs.

Parameters
lhsLeft hand side for the operation
rhsRight hand side for the operation
Returns
A priority value that is rhs less prior than lhs

Definition at line 233 of file thread_prio.hpp.

234 {
235  return thread_prio(lhs.native_value() + rhs);
236 }

◆ operator==() [1/5]

template<typename T_Ok , typename T_Error >
constexpr bool zpp::operator== ( bool  lhs,
const result< T_Ok, T_Error > &  rhs 
)
constexprnoexcept

compare result with bool

Parameters
lhsthe bool value
rhsthe result value
Returns
true if lhs is equal to rhs

Definition at line 668 of file result.hpp.

668  {
669  return bool(lhs) == bool(rhs);
670 }

◆ operator==() [2/5]

template<typename T_Ok , typename T_Error >
constexpr bool zpp::operator== ( const result< T_Ok, T_Error > &  lhs,
bool  rhs 
)
constexprnoexcept

compare result with bool

Parameters
lhsthe result value
rhsthe bool value
Returns
true if lhs is equal to rhs

Definition at line 655 of file result.hpp.

655  {
656  return bool(lhs) == bool(rhs);
657 }

◆ operator==() [3/5]

template<class T_LHS , class T_RHS >
constexpr bool zpp::operator== ( const T_LHS &  lhs,
const T_RHS &  rhs 
)
constexprnoexcept

check if the instances refere to the same native zephyr object handle.

Returns
true if they refer to the same native zephyr object.

Definition at line 21 of file utils.hpp.

22 {
23  if constexpr (std::is_pointer_v<T_LHS> && std::is_pointer_v<T_RHS>) {
24  return lhs == rhs;
25  }
26 
27  if constexpr (std::is_pointer_v<T_LHS> && !std::is_pointer_v<T_RHS>) {
28  return lhs == rhs.native_handle();
29  }
30 
31  if constexpr (!std::is_pointer_v<T_LHS> && std::is_pointer_v<T_RHS>) {
32  return lhs.native_handle() == rhs;
33  }
34 
35  if constexpr (!std::is_pointer_v<T_LHS> && !std::is_pointer_v<T_RHS>) {
36  return lhs.native_handle() == rhs.native_handle();
37  }
38 
39  static_assert(true, "should never be reached");
40  return true;
41 }

◆ operator==() [4/5]

constexpr bool zpp::operator== ( const thread_id lhs,
const thread_id rhs 
)
constexprnoexcept

Compare if two ID are equal.

Parameters
lhsLeft hand side for comparison
rhsRight hand side for comparison
Returns
true is lhs and rhs are equal

Definition at line 84 of file thread_id.hpp.

85 {
86  return (lhs.native_handle() == rhs.native_handle());
87 }

◆ operator==() [5/5]

constexpr bool zpp::operator== ( const thread_prio lhs,
const thread_prio rhs 
)
constexprnoexcept

Compare if two priorities are equal.

Parameters
lhsLeft hand side for comparison
rhsRight hand side for comparison
Returns
true is lhs and rhs are equal

Definition at line 205 of file thread_prio.hpp.

206 {
207  return (lhs.native_value() == rhs.native_value());
208 }

◆ poll_event_set()

template<class... T_Args>
zpp::poll_event_set ( T_Args &&...  t) -> poll_event_set< sizeof...(T_Args)>
noexcept

try poll events waiting for e certain time

Parameters
timeoutthe time to wait
Returns
false on error

◆ power_of_two()

consteval uint32_t zpp::power_of_two ( uint32_t  power)
noexcept

calculate a power of 2

Parameters
powerthe power of 2 to calculate
Returns
the power of 2

Definition at line 79 of file utils.hpp.

80 {
81  uint32_t res = 1;
82 
83  for (uint32_t i = 1; i <= power; ++i) {
84  res *= 2;
85  }
86 
87  return res;
88 }

Referenced by is_power_of_two().

◆ print()

template<class ... T_Args>
void zpp::print ( const char *  fmt,
T_Args &&...  args 
)
inlinenoexcept

simple typesafe print function

print uses the same format string syntax as the fmt C++ lib, just that the feature set is very limited. It only supports {} without any options, for example print("Nr: {}", 1);

Parameters
fmtThe format string using {} as place holder
argsThe needed arguments to print

Definition at line 157 of file fmt.hpp.

158 {
159  internal::print_helper(fmt, std::forward<T_Args>(args)...);
160 }
void print_helper(const char *fmt, T_FirstArg &&first, T_Args &&... args) noexcept
Definition: fmt.hpp:67

References zpp::internal::print_helper().

Referenced by main(), and ZTEST().

◆ print_arg() [1/2]

void zpp::print_arg ( thread_id  id)
inlinenoexcept

Helper to output the ID with zpp::print("{}", id)

Parameters
idThe ID to print

Definition at line 109 of file thread_id.hpp.

110 {
111  printk("%p", id.native_handle());
112 }

◆ print_arg() [2/2]

void zpp::print_arg ( thread_prio  prio)
inlinenoexcept

Helper to output the priority with zpp::print("{}", prio)

Parameters
prioThe priority to print

Definition at line 257 of file thread_prio.hpp.

258 {
259  printk("%d", prio.native_value());
260 }

◆ sched_lock()

void zpp::sched_lock ( )
inlinenoexcept

Lock the scheduler.

Definition at line 18 of file sched.hpp.

19 {
20  k_sched_lock();
21 }

Referenced by zpp::sched_lock_guard::sched_lock_guard().

◆ sched_unlock()

void zpp::sched_unlock ( )
inlinenoexcept

Unlock the scheduler.

Definition at line 26 of file sched.hpp.

27 {
28  k_sched_unlock();
29 }

Referenced by zpp::sched_lock_guard::~sched_lock_guard().

◆ to_error_code()

◆ to_tick()

template<class T_Rep , class T_Period >
constexpr k_ticks_t zpp::to_tick ( const std::chrono::duration< T_Rep, T_Period > &  d)
constexprnoexcept

convert a duration to tick

Parameters
dthe std::chrono::duration to convert
Returns
the number of tick d represents

Definition at line 72 of file clock.hpp.

73 {
74  using namespace std::chrono;
75 
76  return k_ns_to_ticks_floor64(duration_cast<nanoseconds>(d).count());
77 }

Referenced by zpp::thread_attr::set(), and to_timeout().

◆ to_timeout()

template<class T_Rep , class T_Period >
constexpr k_timeout_t zpp::to_timeout ( const std::chrono::duration< T_Rep, T_Period > &  d)
constexprnoexcept

convert a duration to tick

Parameters
dthe std::chrono::duration to convert
Returns
the number of tick d represents

Definition at line 88 of file clock.hpp.

89 {
90  return { to_tick(d) };
91 }
constexpr k_ticks_t to_tick(const std::chrono::duration< T_Rep, T_Period > &d) noexcept
convert a duration to tick
Definition: clock.hpp:72

References to_tick().

Referenced by zpp::this_thread::sleep_for(), zpp::this_thread::sleep_until(), zpp::timer_base::start(), zpp::mem_slab_base< T_MemSlab >::try_allocate_for(), zpp::base_heap< T_Heap >::try_allocate_for(), zpp::mutex_base< T_Mutex >::try_lock_for(), zpp::sys_mutex_base< T_Mutex >::try_lock_for(), zpp::poll_event_set< T_Size >::try_poll_for(), zpp::sem_base< T_Sem >::try_take_for(), zpp::futex_base< T_Futex >::try_wait_for(), and zpp::condition_variable_base< T_ConditionVariable >::try_wait_for().