Zephyr API Documentation
4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
math_extras.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2019 Facebook.
3
*
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
18
19
#ifndef ZEPHYR_INCLUDE_SYS_MATH_EXTRAS_H_
20
#define ZEPHYR_INCLUDE_SYS_MATH_EXTRAS_H_
21
22
#include <
zephyr/types.h
>
23
#include <
stdbool.h
>
24
#include <stddef.h>
25
33
41
static
bool
u16_add_overflow
(
uint16_t
a,
uint16_t
b,
uint16_t
*result);
42
50
51
static
bool
u32_add_overflow
(
uint32_t
a,
uint32_t
b,
uint32_t
*result);
52
60
static
bool
u64_add_overflow
(
uint64_t
a,
uint64_t
b,
uint64_t
*result);
61
69
static
bool
size_add_overflow
(
size_t
a,
size_t
b,
size_t
*result);
70
72
80
88
static
bool
u16_mul_overflow
(
uint16_t
a,
uint16_t
b,
uint16_t
*result);
89
97
98
static
bool
u32_mul_overflow
(
uint32_t
a,
uint32_t
b,
uint32_t
*result);
106
static
bool
u64_mul_overflow
(
uint64_t
a,
uint64_t
b,
uint64_t
*result);
107
115
static
bool
size_mul_overflow
(
size_t
a,
size_t
b,
size_t
*result);
116
118
126
132
static
int
u32_count_leading_zeros
(
uint32_t
x);
133
139
static
int
u64_count_leading_zeros
(
uint64_t
x);
140
142
150
156
static
int
u32_count_trailing_zeros
(
uint32_t
x);
157
163
static
int
u64_count_trailing_zeros
(
uint64_t
x);
164
166
175
181
typedef
struct
{
183
uint64_t
low
;
185
uint64_t
high
;
186
}
int128_t
;
187
198
static
void
i128_multiply_i64_i64
(
int64_t
a,
int64_t
b,
int128_t
*result);
199
201
203
204
#include <
zephyr/sys/math_extras_impl.h
>
205
206
#endif
/* ZEPHYR_INCLUDE_SYS_MATH_EXTRAS_H_ */
u16_mul_overflow
static bool u16_mul_overflow(uint16_t a, uint16_t b, uint16_t *result)
Multiply two unsigned 16-bit integers.
u64_count_trailing_zeros
static int u64_count_trailing_zeros(uint64_t x)
Count the number of trailing zero bits in a 64-bit integer.
u64_mul_overflow
static bool u64_mul_overflow(uint64_t a, uint64_t b, uint64_t *result)
Multiply two unsigned 64-bit integers.
u32_add_overflow
static bool u32_add_overflow(uint32_t a, uint32_t b, uint32_t *result)
Add two unsigned 32-bit integers.
u32_mul_overflow
static bool u32_mul_overflow(uint32_t a, uint32_t b, uint32_t *result)
Multiply two unsigned 32-bit integers.
u32_count_trailing_zeros
static int u32_count_trailing_zeros(uint32_t x)
Count the number of trailing zero bits in a 32-bit integer.
u16_add_overflow
static bool u16_add_overflow(uint16_t a, uint16_t b, uint16_t *result)
Add two unsigned 16-bit integers.
size_mul_overflow
static bool size_mul_overflow(size_t a, size_t b, size_t *result)
Multiply two size_t integers.
size_add_overflow
static bool size_add_overflow(size_t a, size_t b, size_t *result)
Add two size_t integers.
u32_count_leading_zeros
static int u32_count_leading_zeros(uint32_t x)
Count the number of leading zero bits in a 32-bit integer.
i128_multiply_i64_i64
static void i128_multiply_i64_i64(int64_t a, int64_t b, int128_t *result)
Multiply two signed 64-bit integers and store the result in a 128-bit integer.
u64_count_leading_zeros
static int u64_count_leading_zeros(uint64_t x)
Count the number of leading zero bits in a 64-bit integer.
u64_add_overflow
static bool u64_add_overflow(uint64_t a, uint64_t b, uint64_t *result)
Add two unsigned 64-bit integers.
types.h
math_extras_impl.h
Inline implementation of functions declared in math_extras.h.
stdbool.h
uint32_t
__UINT32_TYPE__ uint32_t
Definition
stdint.h:90
uint64_t
__UINT64_TYPE__ uint64_t
Definition
stdint.h:91
uint16_t
__UINT16_TYPE__ uint16_t
Definition
stdint.h:89
int64_t
__INT64_TYPE__ int64_t
Definition
stdint.h:75
int128_t
128-bit integer structure.
Definition
math_extras.h:181
int128_t::high
uint64_t high
High-order 64 bits (includes sign bit).
Definition
math_extras.h:185
int128_t::low
uint64_t low
Low-order 64 bits.
Definition
math_extras.h:183
zephyr
sys
math_extras.h
Generated on
for Zephyr API Documentation by
1.16.1