Zephyr API Documentation
4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
print_format.h
Go to the documentation of this file.
1
/* Copyright (c) 2023 Google LLC
2
* SPDX-License-Identifier: Apache-2.0
3
*/
4
5
#ifndef ZEPHYR_INCLUDE_DSP_PRINT_FORMAT_H_
6
#define ZEPHYR_INCLUDE_DSP_PRINT_FORMAT_H_
7
8
#include <
inttypes.h
>
9
#include <
stdlib.h
>
10
#include <
zephyr/dsp/types.h
>
11
30
#define PRIq(precision) "s%" PRIu32 ".%0" STRINGIFY(precision) PRIu32
31
32
static
inline
int64_t
___PRIq_arg_shift(
int64_t
q,
int
shift)
33
{
34
if
(shift < 0) {
35
return
llabs
(q) >> -shift;
36
}
else
{
37
return
llabs
(q) << shift;
38
}
39
}
40
41
#define __EXP2(a, b) a ## b
42
#define __EXP(a, b) __EXP2(a ## e, b)
43
#define __CONSTPOW(C, x) __EXP(C, x)
44
45
#define __PRIq_arg_shift(q, shift) ___PRIq_arg_shift(q, ((shift) + (8 * (4 - (int)sizeof(q)))))
46
#define __PRIq_arg_get(q, shift, h, l) FIELD_GET(GENMASK64(h, l), __PRIq_arg_shift(q, shift))
47
#define __PRIq_arg_get_int(q, shift) __PRIq_arg_get(q, shift, 63, 31)
48
#define __PRIq_arg_get_frac(q, precision, shift) \
49
((__PRIq_arg_get(q, shift, 30, 0) * __CONSTPOW(1, precision)) / INT32_MAX)
50
58
#define PRIq_arg(q, precision, shift) \
59
((q) < 0 ? "-" : ""), (uint32_t)__PRIq_arg_get_int(q, shift), \
60
(uint32_t)__PRIq_arg_get_frac(q, precision, shift)
61
66
#endif
/* ZEPHYR_INCLUDE_DSP_PRINT_FORMAT_H_ */
types.h
inttypes.h
int64_t
__INT64_TYPE__ int64_t
Definition
stdint.h:75
stdlib.h
llabs
static long long llabs(long long __n)
Definition
stdlib.h:70
zephyr
dsp
print_format.h
Generated on Mon Nov 18 2024 03:14:08 for Zephyr API Documentation by
1.12.0