dpl_types.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
22 #include <stdint.h>
23 #include <math.h>
24 
25 #include "os/os_types.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
34 #ifndef M_PI
35 #define M_PI 3.1415926535
36 #endif
37 
42 #define DPL_TIMEOUT_NEVER (OS_TIMEOUT_NEVER)
43 #define DPL_WAIT_FOREVER (OS_WAIT_FOREVER)
50 #define DPL_STACK_ALIGNMENT (OS_ALIGNMENT)
57 
62 
66 typedef float dpl_float32_t;
70 typedef double dpl_float64_t;
71 
76 #define DPL_FLOAT32_INIT(__X) ((float)__X)
77 #define DPL_FLOAT64_INIT(__X) ((double)__X)
78 #define DPL_FLOAT64TO32(__X) (float)(__X)
79 #define DPL_FLOAT32_I32_TO_F32(__X) (float)(__X)
80 #define DPL_FLOAT64_I32_TO_F64(__X) ((double)(__X))
81 #define DPL_FLOAT64_I64_TO_F64(__X) ((double)(__X))
82 #define DPL_FLOAT64_U64_TO_F64(__X) ((double)(__X))
83 #define DPL_FLOAT64_F64_TO_U64(__X) ((uint64_t)(__X))
84 #define DPL_FLOAT32_INT(__X) ((int32_t)__X)
85 #define DPL_FLOAT64_INT(__X) ((int64_t)__X)
86 #define DPL_FLOAT64_FROM_F32(__X) (double)(__X)
87 #define DPL_FLOAT32_FROM_F64(__X) (float)(__X)
88 #define DPL_FLOAT32_CEIL(__X) (ceilf(__X))
89 #define DPL_FLOAT64_CEIL(__X) (ceil(__X))
90 #define DPL_FLOAT32_FABS(__X) fabsf(__X)
91 #define DPL_FLOAT32_FMOD(__X, __Y) fmodf(__X, __Y)
92 #define DPL_FLOAT64_FMOD(__X, __Y) fmod(__X, __Y)
93 #define DPL_FLOAT32_NAN() nanf("")
94 #define DPL_FLOAT64_NAN() nan("")
95 #define DPL_FLOAT32_ISNAN(__X) isnan(__X)
96 #define DPL_FLOAT64_ISNAN(__X) DPL_FLOAT32_ISNAN(__X)
97 #define DPL_FLOAT32_LOG10(__X) (log10f(__X))
98 #define DPL_FLOAT64_LOG10(__X) (log10(__X))
99 #define DPL_FLOAT64_ASIN(__X) asin(__X)
100 #define DPL_FLOAT64_ATAN(__X) atan(__X)
101 #define DPL_FLOAT32_SUB(__X, __Y) ((__X)-(__Y))
102 #define DPL_FLOAT64_SUB(__X, __Y) ((__X)-(__Y))
103 #define DPL_FLOAT32_ADD(__X, __Y) ((__X)+(__Y))
104 #define DPL_FLOAT64_ADD(__X, __Y) ((__X)+(__Y))
105 #define DPL_FLOAT32_MUL(__X, __Y) ((__X)*(__Y))
106 #define DPL_FLOAT64_MUL(__X, __Y) ((__X)*(__Y))
107 #define DPL_FLOAT32_DIV(__X, __Y) ((__X)/(__Y))
108 #define DPL_FLOAT64_DIV(__X, __Y) ((__X)/(__Y))
109 #define DPL_FLOAT32_PRINTF_PRIM "%s%d.%03d"
110 #define DPL_FLOAT32_PRINTF_VALS(__X) (__X)<0?"-":"", (int)(fabsf(__X)), (int)(fabsf((__X)-(int)(__X))*1000)
111 #define DPL_FLOAT64_PRINTF_PRIM "%s%d.%06d"
112 #define DPL_FLOAT64_PRINTF_VALS(__X) (__X)<0?"-":"", (int)(fabs(__X)), (int)(fabs((__X)-(int)(__X))*1000000)
115 #ifdef __cplusplus
116 }
117 #endif
os_time_t dpl_time_t
dpl time type
Definition: dpl_types.h:56
double dpl_float64_t
dpl float 64 type
Definition: dpl_types.h:70
os_stack_t dpl_stack_t
dpl stack buffer type
Definition: dpl_types.h:61
float dpl_float32_t
dpl float 32 type
Definition: dpl_types.h:66
Math helper macros.
mynewt-core types
uint32_t os_time_t
time type
Definition: os_types.h:47
char os_stack_t
stack buffer type
Definition: os_types.h:52