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 such constants in math.h
108# define M_E 2.71828182845904523536 // e
109# define M_LOG2E 1.44269504088896340736 // log2(e)
110# define M_LOG10E 0.434294481903251827651 // log10(e)
111# define M_LN2 0.693147180559945309417 // ln(2)
112# define M_LN10 2.30258509299404568402 // ln(10)
113# define M_PI 3.14159265358979323846 // pi
114# define M_PI_2 1.57079632679489661923 // pi/2
115# define M_PI_4 0.785398163397448309616 // pi/4
116# define M_1_PI 0.318309886183790671538 // 1/pi
117# define M_2_PI 0.636619772367581343076 // 2/pi
118# define M_2_SQRTPI 1.12837916709551257390 // 2/sqrt(pi)
119# define M_SQRT2 1.41421356237309504880 // sqrt(2)
120# define M_SQRT1_2 0.707106781186547524401 // 1/sqrt(2)
121
122// iar has no strlcpy and strcasestr
123#ifdef __cplusplus
124extern "C" {
125#endif
126extern size_t strlcpy(char *dst, const char *src, size_t dsize);
127extern size_t strlcat(char *dst, const char *src, size_t dsize);
128extern char * strsep(char **stringp, const char *delim);
129extern char * strcasestr(const char *str, const char *substr);
130#ifdef __cplusplus
131}
132#endif
133
134#if !(VSF_USE_LINUX == ENABLED && VSF_LINUX_USE_SIMPLE_LIBC == ENABLED && VSF_LINUX_USE_SIMPLE_STDIO == ENABLED) && _DLIB_FILE_DESCRIPTOR
135# include <stdio.h>
136# ifdef __cplusplus
137extern "C" {
138# endif
139typedef long off_t;
140typedef int64_t off64_t;
141extern int fseeko(FILE *f, off_t offset, int whence);
142extern off_t ftello(FILE *f);
143extern int fseeko64(FILE *f, off64_t offset, int whence);
144extern off64_t ftello64(FILE *f);
145# ifdef __cplusplus
146}
147# endif
148#endif // !(VSF_USE_LINUX && VSF_LINUX_USE_SIMPLE_LIBC && VSF_LINUX_USE_SIMPLE_STDIO)
149
150#if !(VSF_USE_LINUX == ENABLED && VSF_LINUX_USE_SIMPLE_LIBC == ENABLED && VSF_LINUX_USE_SIMPLE_TIME == ENABLED)
151# include <time.h>
152// iar has no clockid_t and useconds_t
153# ifdef __cplusplus
154extern "C" {
155# endif
156# ifndef __IAR_TYPE_CLOCKID_T__
157# define __IAR_TYPE_CLOCKID_T__
158typedef enum {
161} clockid_t;
162typedef unsigned long useconds_t;
163extern int clock_gettime(clockid_t clk_id, struct timespec *tp);
164
165struct itimerspec {
166 struct timespec it_interval;
167 struct timespec it_value;
168};
169
170# ifdef __cplusplus
171}
172# endif
173# endif
174#endif // !(VSF_USE_LINUX && VSF_LINUX_USE_SIMPLE_LIBC && VSF_LINUX_USE_SIMPLE_TIME)
175
176#elif __IS_COMPILER_GCC__
177
178#if !(VSF_USE_LINUX == ENABLED && VSF_LINUX_USE_SIMPLE_LIBC == ENABLED && VSF_LINUX_USE_SIMPLE_STDIO == ENABLED)
179// arm-none-eabi-gcc has no 64-bit stdio APIs, if simple_stdio in simple_libc is not used,
180// implement 64-bit stdio APIs here, currently simply redirect to 32-bit version
181# define off64_t off_t
182# define ftello64 ftell
183# define fseeko64 fseek
184#endif // !(VSF_USE_LINUX && VSF_LINUX_USE_SIMPLE_LIBC && VSF_LINUX_USE_SIMPLE_STDIO)
185
186#ifndef __VSF_APPLET__
187
188// gcc use __builtin_alloca
189# define alloca(__size) __builtin_alloca(__size)
190
191// gcc has no strcasestr
192#ifdef __cplusplus
193extern "C" {
194#endif
195extern char * strcasestr(const char *str, const char *substr);
196#ifdef __cplusplus
197}
198#endif
199
200#endif // __VSF_APPLET__
201
202#endif // __IS_COMPILER_XXX__
int64_t intmax_t
Definition type.h:52
uint32_t uintptr_t
Definition type.h:49
unsigned int uint_fast16_t
Definition type.h:32
signed short int16_t
Definition type.h:31
unsigned short uint16_t
Definition type.h:30
signed long long int_fast64_t
Definition type.h:43
uint64_t uintmax_t
Definition type.h:51
signed int int_fast8_t
Definition type.h:28
unsigned int uint32_t
Definition type.h:35
int32_t intptr_t
Definition type.h:50
unsigned int uint_fast32_t
Definition type.h:37
signed int int_fast16_t
Definition type.h:33
unsigned long long uint64_t
Definition type.h:40
unsigned long long uint_fast64_t
Definition type.h:42
signed int int32_t
Definition type.h:36
unsigned char uint8_t
Definition type.h:25
unsigned int uint_fast8_t
Definition type.h:27
signed long long int64_t
Definition type.h:41
signed int int_fast32_t
Definition type.h:38
signed char int8_t
Definition type.h:26
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
#define clock_gettime
Definition time.h:33
unsigned char uint_fast8_t
Definition stdint.h:23
unsigned uint32_t
Definition stdint.h:9
int int32_t
Definition stdint.h:8
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
int FILE
Definition stdio.h:141
#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 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