1 #ifndef _NET_DEFS_H_
2 #define _NET_DEFS_H_
3
4 #define __LINUX_ERRNO_EXTENSIONS__
5
6 #include "plat_types.h"
7 #include "cmsis.h"
8 #include <string.h>
9
10 #ifndef __ASSEMBLY__
11
12 //#define NEED_KEEP
13
14 #ifndef USHRT_MAX
15 #define USHRT_MAX ((u16)(~0U))
16 #endif
17
18 #ifndef SHRT_MAX
19 #define SHRT_MAX ((s16)(USHRT_MAX>>1))
20 #endif
21
22 #ifndef SHRT_MIN
23 #define SHRT_MIN ((s16)(-SHRT_MAX - 1))
24 #endif
25
26 #ifndef INT_MAX
27 #define INT_MAX ((int)(~0U>>1))
28 #endif
29
30 #ifndef INT_MIN
31 #define INT_MIN (-INT_MAX - 1)
32 #endif
33
34 #ifndef UINT_MAX
35 #define UINT_MAX (~0U)
36 #endif
37
38 #ifndef LONG_MAX
39 #define LONG_MAX ((long)(~0UL>>1))
40 #endif
41
42 #ifndef LONG_MIN
43 #define LONG_MIN (-LONG_MAX - 1)
44 #endif
45
46 #ifndef ULONG_MAX
47 #define ULONG_MAX (~0UL)
48 #endif
49
50 #ifndef LLONG_MIN
51 #define LLONG_MIN (-LLONG_MAX - 1)
52 #endif
53
54 #ifndef ULLONG_MAX
55 #define ULLONG_MAX (~0ULL)
56 #endif
57
58 #define N_FALSE 0
59 #define N_TRUE (!N_FALSE)
60
61 #define BIT(nr) (1UL << (nr))
62
63 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
64
65 #ifndef min
66 #define min(a,b) (((a) < (b)) ? (a) : (b))
67 #endif /* min */
68
69 #ifndef max
70 #define max(a,b) (((a) > (b)) ? (a) : (b))
71 #endif /* max */
72
73 #define min_t(type, x, y) ({ \
74 type __min1 = (x); \
75 type __min2 = (y); \
76 __min1 < __min2 ? __min1: __min2; })
77
78 #define max_t(type, x, y) ({ \
79 type __max1 = (x); \
80 type __max2 = (y); \
81 __max1 > __max2 ? __max1: __max2; })
82
83 #ifndef NULL
84 #define NULL ((void *) 0)
85 #endif
86
87 #ifndef __PLAT_TYPES_H__
88 typedef char __s8;
89 typedef unsigned char __u8;
90
91 typedef short __s16;
92 typedef unsigned short __u16;
93
94 typedef int __s32;
95 typedef unsigned int __u32;
96
97 typedef long long __s64;
98 #endif
99 typedef unsigned long long __u64;
100
101 #ifndef __PLAT_TYPES_H__
102 typedef unsigned char UCHAR;
103 typedef signed char CHAR;
104 typedef unsigned char* PUCHAR;
105 typedef signed char* PCHAR;
106
107 typedef unsigned char UINT8;
108 typedef unsigned short UINT16;
109 typedef unsigned int UINT32;
110
111 typedef char INT8;
112 typedef short INT16;
113 typedef int INT32;
114
115 typedef unsigned char u8_t;
116 typedef signed char s8_t;
117 typedef unsigned short u16_t;
118 typedef signed short s16_t;
119 typedef unsigned int u32_t;
120 typedef signed int s32_t;
121 #endif
122 /*
123 * Below are truly Linux-specific types that should never collide with
124 * any application/library that wants linux/types.h.
125 */
126
127 #ifdef __CHECKER__
128 #define __bitwise__ __attribute__((bitwise))
129 #else
130 #define __bitwise__
131 #endif
132 #ifdef __CHECK_ENDIAN__
133 #define __bitwise __bitwise__
134 #else
135 #define __bitwise
136 #endif
137
138 #ifndef __PLAT_TYPES_H__
139 typedef __u16 __bitwise __le16;
140 typedef __u16 __bitwise __be16;
141 typedef __u32 __bitwise __le32;
142 typedef __u32 __bitwise __be32;
143 typedef __u64 __bitwise __le64;
144 #endif
145 typedef __u64 __bitwise __be64;
146
147 typedef __u16 __bitwise __sum16;
148 typedef __u32 __bitwise __wsum;
149
150 /*
151 * aligned_u64 should be used in defining kernel<->userspace ABIs to avoid
152 * common 32/64-bit compat problems.
153 * 64-bit values align to 4-byte boundaries on x86_32 (and possibly other
154 * architectures) and to 8-byte boundaries on 64-bit architectures. The new
155 * aligned_64 type enforces 8-byte alignment so that structs containing
156 * aligned_64 values have the same alignment on 32-bit and 64-bit architectures.
157 * No conversions are necessary between 32-bit user-space and a 64-bit kernel.
158 */
159 #define __aligned_16 __attribute__((aligned(2)))
160 #define __aligned_u16 __u16 __attribute__((aligned(2)))
161 #define __aligned_u32 __u32 __attribute__((aligned(4)))
162 #define __aligned_u64 __u64 __attribute__((aligned(8)))
163 #define __aligned_be64 __be64 __attribute__((aligned(8)))
164 #define __aligned_le64 __le64 __attribute__((aligned(8)))
165
166 #define __init
167 #define __must_check
168 #ifndef __pure
169 #define __pure
170 #endif
171 #define might_sleep()
172 #ifndef offsetof
173 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
174 #endif
175 #define likely(x) (x)
176 #define unlikely(x) (x)
177
178 #define PTR_ERR(x) ((int)x)
179 #define IS_ERR(x) (((int)x > 0)?N_FALSE:N_TRUE)
180
181 typedef struct {
182 int counter;
183 } atomic32_t;
184
185 typedef struct {
186 uint64_t counter;
187 } atomic64_t;
188
189 typedef enum {
190 GFP_KERNEL = 0,
191 GFP_ATOMIC,
192 __GFP_HIGHMEM,
193 __GFP_HIGH
194 } gfp_t;
195
196 #define GFP_DMA GFP_KERNEL
197
198 #define barrier
199 #define EXPORT_SYMBOL(x)
200 #define EXPORT_SYMBOL_GPL(x)
201
202 #define smp_mb(x)
203
204 #define net_swap(a, b) \
205 do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
206
207 #define container_of(ptr, type, member) \
208 ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
209
210 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
211 /**
212 * struct rcu_head - callback structure for use with RCU
213 * @next: next update requests in a list
214 * @func: actual update function to call after the grace period.
215 */
216 struct rcu_head {
217 struct rcu_head *next;
218 void (*func)(struct rcu_head *head);
219 };
220
ERR_PTR(long error)221 static inline void * __must_check ERR_PTR(long error)
222 {
223 return (void *) error;
224 }
225
226 #define BITS_PER_LONG 32
227
228 /* Defined for the NFSv3 protocol */
229 #define EBADHANDLE 521 /* Illegal NFS file handle */
230 #define ENOTSYNC 522 /* Update synchronization mismatch */
231 #define EBADCOOKIE 523 /* Cookie is stale */
232 #define ENOTSUPP 524 /* Operation is not supported */
233 #define ETOOSMALL 525 /* Buffer or request is too small */
234 #define ESERVERFAULT 526 /* An untranslatable error occurred */
235 #define EBADTYPE 527 /* Type not supported by server */
236 #define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */
237 #define EIOCBQUEUED 529 /* iocb queued, will get completion event */
238
239 typedef struct
240 {
241 unsigned int tm_year;
242 unsigned int tm_mon;
243 unsigned int tm_mday;
244 unsigned int tm_hour;
245 unsigned int tm_min;
246 unsigned int tm_sec;
247 bool tm_isdst;
248 } tm_t;
249
250 #endif /* __ASSEMBLY__ */
251 #endif /* _NET_DEFS_H_ */
252
253