Loading...
Searching...
No Matches
dpl_types.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Inria
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#include <stdint.h>
20#include <math.h>
21
22#include "os/os_types.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
31#ifndef M_PI
32#define M_PI 3.1415926535
33#endif
34
39#define DPL_TIMEOUT_NEVER (OS_TIMEOUT_NEVER)
40#define DPL_WAIT_FOREVER (OS_WAIT_FOREVER)
42
47#define DPL_STACK_ALIGNMENT (OS_ALIGNMENT)
49
54
59
63typedef float dpl_float32_t;
67typedef double dpl_float64_t;
68
73#define DPL_FLOAT32_INIT(__X) ((float)__X)
74#define DPL_FLOAT64_INIT(__X) ((double)__X)
75#define DPL_FLOAT64TO32(__X) (float)(__X)
76#define DPL_FLOAT32_I32_TO_F32(__X) (float)(__X)
77#define DPL_FLOAT64_I32_TO_F64(__X) ((double)(__X))
78#define DPL_FLOAT64_I64_TO_F64(__X) ((double)(__X))
79#define DPL_FLOAT64_U64_TO_F64(__X) ((double)(__X))
80#define DPL_FLOAT64_F64_TO_U64(__X) ((uint64_t)(__X))
81#define DPL_FLOAT32_INT(__X) ((int32_t)__X)
82#define DPL_FLOAT64_INT(__X) ((int64_t)__X)
83#define DPL_FLOAT64_FROM_F32(__X) (double)(__X)
84#define DPL_FLOAT32_FROM_F64(__X) (float)(__X)
85#define DPL_FLOAT32_CEIL(__X) (ceilf(__X))
86#define DPL_FLOAT64_CEIL(__X) (ceil(__X))
87#define DPL_FLOAT32_FABS(__X) fabsf(__X)
88#define DPL_FLOAT32_FMOD(__X, __Y) fmodf(__X, __Y)
89#define DPL_FLOAT64_FMOD(__X, __Y) fmod(__X, __Y)
90#define DPL_FLOAT32_NAN() nanf("")
91#define DPL_FLOAT64_NAN() nan("")
92#define DPL_FLOAT32_ISNAN(__X) isnan(__X)
93#define DPL_FLOAT64_ISNAN(__X) DPL_FLOAT32_ISNAN(__X)
94#define DPL_FLOAT32_LOG10(__X) (log10f(__X))
95#define DPL_FLOAT64_LOG10(__X) (log10(__X))
96#define DPL_FLOAT64_ASIN(__X) asin(__X)
97#define DPL_FLOAT64_ATAN(__X) atan(__X)
98#define DPL_FLOAT32_SUB(__X, __Y) ((__X)-(__Y))
99#define DPL_FLOAT64_SUB(__X, __Y) ((__X)-(__Y))
100#define DPL_FLOAT32_ADD(__X, __Y) ((__X)+(__Y))
101#define DPL_FLOAT64_ADD(__X, __Y) ((__X)+(__Y))
102#define DPL_FLOAT32_MUL(__X, __Y) ((__X)*(__Y))
103#define DPL_FLOAT64_MUL(__X, __Y) ((__X)*(__Y))
104#define DPL_FLOAT32_DIV(__X, __Y) ((__X)/(__Y))
105#define DPL_FLOAT64_DIV(__X, __Y) ((__X)/(__Y))
106#define DPL_FLOAT32_PRINTF_PRIM "%s%d.%03d"
107#define DPL_FLOAT32_PRINTF_VALS(__X) (__X)<0?"-":"", (int)(fabsf(__X)), (int)(fabsf((__X)\
108 -(int)(__X))*1000)
109#define DPL_FLOAT64_PRINTF_PRIM "%s%d.%06d"
110#define DPL_FLOAT64_PRINTF_VALS(__X) (__X)<0?"-":"", (int)(fabs(__X)), (int)(fabs((__X)\
111 -(int)(__X))*1000000)
113
114#ifdef __cplusplus
115}
116#endif
os_time_t dpl_time_t
dpl time type
Definition dpl_types.h:53
double dpl_float64_t
dpl float 64 type
Definition dpl_types.h:67
os_stack_t dpl_stack_t
dpl stack buffer type
Definition dpl_types.h:58
float dpl_float32_t
dpl float 32 type
Definition dpl_types.h:63
Math helper macros.
mynewt-core types
uint32_t os_time_t
time type
Definition os_types.h:44
char os_stack_t
stack buffer type
Definition os_types.h:49