Zephyr Project API 3.7.0
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_ZEPHYR_DSP_PRINT_FORMAT_H
6#define ZEPHYR_INCLUDE_ZEPHYR_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
32static 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_ZEPHYR_DSP_PRINT_FORMAT_H */
struct k_queue q
Definition kobject.c:1320
__INT64_TYPE__ int64_t
Definition stdint.h:75
static long long llabs(long long __n)
Definition stdlib.h:70