VSF Documented
type.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __APP_TYPE_H_INCLUDED__
19#define __APP_TYPE_H_INCLUDED__
20
21/*============================ INCLUDES ======================================*/
22
23#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__cplusplus)
24
25typedef unsigned char uint8_t;
26typedef signed char int8_t;
27typedef unsigned int uint_fast8_t;
28typedef signed int int_fast8_t;
29
30typedef unsigned short uint16_t;
31typedef signed short int16_t;
32typedef unsigned int uint_fast16_t;
33typedef signed int int_fast16_t;
34
35typedef unsigned int uint32_t;
36typedef signed int int32_t;
37typedef unsigned int uint_fast32_t;
38typedef signed int int_fast32_t;
39
40typedef unsigned long long uint64_t;
41typedef signed long long int64_t;
42typedef unsigned long long uint_fast64_t;
43typedef signed long long int_fast64_t;
44
45#ifndef UINT64_MAX
46# define UINT64_MAX ((uint64_t)(-1))
47#endif
48
53#else
54#include <stdint.h>
55#endif
56
57#if !defined(__USE_LOCAL_STDBOOL__)
58# if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__cplusplus)
59# if !defined(bool)
60typedef enum {
61 false = 0,
62 true = !false,
63} bool;
64# endif
65# else
66# include <stdbool.h>
67# endif
68#else
69# undef __USE_LOCAL_STDINT_STDBOOL__
70#endif
71
72#if !__IS_COMPILER_GCC__ && !__IS_COMPILER_ARM_COMPILER_5__ && !__IS_COMPILER_LLVM__
73# include <uchar.h>
74#endif
75
76#ifdef __cplusplus
77extern "C" {
78#endif
79
80/*============================ MACROS ========================================*/
81
82#define __optimal_bit_sz (sizeof(uintalu_t) * 8)
83#define __optimal_bit_msk (__optimal_bit_sz - 1)
84
85/*============================ MACROFIED FUNCTIONS ===========================*/
86/*============================ TYPES =========================================*/
87
90
91/*============================ GLOBAL VARIABLES ==============================*/
92/*============================ LOCAL VARIABLES ===============================*/
93/*============================ PROTOTYPES ====================================*/
94
95#ifdef __cplusplus
96}
97#endif
98
99#endif // __APP_TYPE_H_INCLUDED__
100
101/*============================ Multiple-Entry ================================*/
102
103#include "../__common/__type.h"
104
105#if __IS_COMPILER_IAR__
106
107// IAR has no _Static_assert, but has static_assert
108#define _Static_assert static_assert
109
110// iar has no such constants in math.h
111# define M_E 2.71828182845904523536 // e
112# define M_LOG2E 1.44269504088896340736 // log2(e)
113# define M_LOG10E 0.434294481903251827651 // log10(e)
114# define M_LN2 0.693147180559945309417 // ln(2)
115# define M_LN10 2.30258509299404568402 // ln(10)
116# define M_PI 3.14159265358979323846 // pi
117# define M_PI_2 1.57079632679489661923 // pi/2
118# define M_PI_4 0.785398163397448309616 // pi/4
119# define M_1_PI 0.318309886183790671538 // 1/pi
120# define M_2_PI 0.636619772367581343076 // 2/pi
121# define M_2_SQRTPI 1.12837916709551257390 // 2/sqrt(pi)
122# define M_SQRT2 1.41421356237309504880 // sqrt(2)
123# define M_SQRT1_2 0.707106781186547524401 // 1/sqrt(2)
124
125// iar has no strlcpy and strcasestr
126#ifdef __cplusplus
127extern "C" {
128#endif
129extern size_t strlcpy(char *dst, const char *src, size_t dsize);
130extern size_t strlcat(char *dst, const char *src, size_t dsize);
131extern char * strsep(char **stringp, const char *delim);
132extern char * strcasestr(const char *str, const char *substr);
133#ifdef __cplusplus
134}
135#endif
136
137#if !(VSF_USE_LINUX == ENABLED && VSF_LINUX_USE_SIMPLE_LIBC == ENABLED && VSF_LINUX_USE_SIMPLE_STDIO == ENABLED) && _DLIB_FILE_DESCRIPTOR
138# include <stdio.h>
139# ifdef __cplusplus
140extern "C" {
141# endif
142typedef long off_t;
143typedef int64_t off64_t;
144extern int fseeko(FILE *f, off_t offset, int whence);
145extern off_t ftello(FILE *f);
146extern int fseeko64(FILE *f, off64_t offset, int whence);
147extern off64_t ftello64(FILE *f);
148# ifdef __cplusplus
149}
150# endif
151#endif // !(VSF_USE_LINUX && VSF_LINUX_USE_SIMPLE_LIBC && VSF_LINUX_USE_SIMPLE_STDIO)
152
153#if !(VSF_USE_LINUX == ENABLED && VSF_LINUX_USE_SIMPLE_LIBC == ENABLED && VSF_LINUX_USE_SIMPLE_TIME == ENABLED)
154# include <time.h>
155// iar has no clockid_t and useconds_t
156# ifdef __cplusplus
157extern "C" {
158# endif
159# ifndef __IAR_TYPE_CLOCKID_T__
160# define __IAR_TYPE_CLOCKID_T__
161typedef enum {
164} clockid_t;
165typedef unsigned long useconds_t;
166extern int clock_gettime(clockid_t clk_id, struct timespec *tp);
167
168struct itimerspec {
169 struct timespec it_interval;
170 struct timespec it_value;
171};
172
173# ifdef __cplusplus
174}
175# endif
176# endif
177#endif // !(VSF_USE_LINUX && VSF_LINUX_USE_SIMPLE_LIBC && VSF_LINUX_USE_SIMPLE_TIME)
178
179#elif __IS_COMPILER_GCC__
180
181#if !(VSF_USE_LINUX == ENABLED && VSF_LINUX_USE_SIMPLE_LIBC == ENABLED && VSF_LINUX_USE_SIMPLE_STDIO == ENABLED)
182// arm-none-eabi-gcc has no 64-bit stdio APIs, if simple_stdio in simple_libc is not used,
183// implement 64-bit stdio APIs here, currently simply redirect to 32-bit version
184# define off64_t off_t
185# define ftello64 ftell
186# define fseeko64 fseek
187#endif // !(VSF_USE_LINUX && VSF_LINUX_USE_SIMPLE_LIBC && VSF_LINUX_USE_SIMPLE_STDIO)
188
189#ifndef __VSF_APPLET__
190
191// gcc use __builtin_alloca
192# ifndef alloca
193# define alloca(__s) __builtin_alloca(__s)
194# endif
195
196// gcc has no strcasestr
197#ifdef __cplusplus
198extern "C" {
199#endif
200extern char * strcasestr(const char *str, const char *substr);
201#ifdef __cplusplus
202}
203#endif
204
205#endif // __VSF_APPLET__
206
207#endif // __IS_COMPILER_XXX__
signed long long int_fast64_t
Definition type.h:43
unsigned long long uint64_t
Definition type.h:40
unsigned long long uint_fast64_t
Definition type.h:42
signed long long int64_t
Definition type.h:41
int32_t intalu_t
Definition type.h:69
uint32_t uintalu_t
Definition type.h:68
bool
Definition type.h:30
clockid_t
Definition types.h:138
__USECONDS_T useconds_t
Definition types.h:136
#define CLOCK_MONOTONIC
Definition types.h:142
#define CLOCK_REALTIME
Definition types.h:140
long long off64_t
Definition types.h:97
long off_t
Definition types.h:95
unsigned int uint32_t
Definition lvgl.h:43
signed int int32_t
Definition lvgl.h:44
int32_t intmax_t
Definition type.h:48
signed long int int_least32_t typedef uint32_t uintptr_t
Definition type.h:45
signed short int16_t
Definition type.h:30
unsigned short uint16_t
Definition type.h:29
unsigned char uint_fast8_t
Definition type.h:26
unsigned long int uint32_t
Definition type.h:34
int32_t intptr_t
Definition type.h:46
uint32_t uintmax_t
Definition type.h:47
signed short int_fast16_t
Definition type.h:32
unsigned long int uint_fast32_t
Definition type.h:36
unsigned short uint_fast16_t
Definition type.h:31
unsigned char uint8_t
Definition type.h:24
signed long int int32_t
Definition type.h:35
signed long int int_fast32_t
Definition type.h:37
signed char int8_t
Definition type.h:25
signed char int_fast8_t
Definition type.h:27
#define clock_gettime
Definition time.h:33
unsigned char uint_fast8_t
Definition stdint.h:23
long long int64_t
Definition stdint.h:10
unsigned long long uint64_t
Definition stdint.h:11
char int_fast8_t
Definition stdint.h:22
#define ftello64
Definition stdio.h:60
#define fseeko
Definition stdio.h:56
#define fseeko64
Definition stdio.h:57
#define ftello
Definition stdio.h:59
size_t strlcpy(char *dest, const char *src, size_t n)
Definition vsf_xboot.c:39
char * strcasestr(const char *haystack, const char *needle)
char * strsep(char **strp, const char *delim)
Definition vsf_xboot.c:44
Definition stdio.h:145
Definition time.h:71
struct timespec it_interval
Definition time.h:72
struct timespec it_value
Definition time.h:73
Definition time.h:66
uint64_t offset
Definition vsf_memfs.h:49
size_t strlcat(char *dst, const char *src, size_t dsize)
Definition x86_compiler.c:52