diff options
author | Joshua Bakita <bakitajoshua@gmail.com> | 2024-09-25 16:09:09 -0400 |
---|---|---|
committer | Joshua Bakita <bakitajoshua@gmail.com> | 2024-09-25 16:09:09 -0400 |
commit | f347fde22f1297e4f022600d201780d5ead78114 (patch) | |
tree | 76be305d6187003a1e0486ff6e91efb1062ae118 /include/nvgpu/posix/types.h | |
parent | 8340d234d78a7d0f46c11a584de538148b78b7cb (diff) |
Delete no-longer-needed nvgpu headersHEADmasterjbakita-wip
The dependency on these was removed in commit 8340d234.
Diffstat (limited to 'include/nvgpu/posix/types.h')
-rw-r--r-- | include/nvgpu/posix/types.h | 221 |
1 files changed, 0 insertions, 221 deletions
diff --git a/include/nvgpu/posix/types.h b/include/nvgpu/posix/types.h deleted file mode 100644 index 12078b9..0000000 --- a/include/nvgpu/posix/types.h +++ /dev/null | |||
@@ -1,221 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_TYPES_H__ | ||
24 | #define __NVGPU_POSIX_TYPES_H__ | ||
25 | |||
26 | #include <stdbool.h> | ||
27 | #include <stdint.h> | ||
28 | #include <stddef.h> | ||
29 | #include <errno.h> | ||
30 | #include <limits.h> | ||
31 | #include <string.h> | ||
32 | #include <strings.h> | ||
33 | #include <stdio.h> | ||
34 | #include <stdarg.h> | ||
35 | |||
36 | /* | ||
37 | * For endianness functions. | ||
38 | */ | ||
39 | #include <netinet/in.h> | ||
40 | |||
41 | typedef unsigned char u8; | ||
42 | typedef unsigned short u16; | ||
43 | typedef unsigned int u32; | ||
44 | typedef unsigned long long u64; | ||
45 | |||
46 | typedef signed char s8; | ||
47 | typedef signed short s16; | ||
48 | typedef signed int s32; | ||
49 | typedef signed long long s64; | ||
50 | |||
51 | #define min_t(type, a, b) \ | ||
52 | ({ \ | ||
53 | type __a = (a); \ | ||
54 | type __b = (b); \ | ||
55 | __a < __b ? __a : __b; \ | ||
56 | }) | ||
57 | |||
58 | #if defined(min) | ||
59 | #undef min | ||
60 | #endif | ||
61 | #if defined(max) | ||
62 | #undef max | ||
63 | #endif | ||
64 | |||
65 | #define min(a, b) \ | ||
66 | ({ \ | ||
67 | (a) < (b) ? a : b; \ | ||
68 | }) | ||
69 | #define max(a, b) \ | ||
70 | ({ \ | ||
71 | (a) > (b) ? a : b; \ | ||
72 | }) | ||
73 | #define min3(a, b, c) min(min(a, b), c) | ||
74 | |||
75 | #define PAGE_SIZE 4096U | ||
76 | |||
77 | #define ARRAY_SIZE(array) \ | ||
78 | (sizeof(array) / sizeof((array)[0])) | ||
79 | |||
80 | #define MAX_SCHEDULE_TIMEOUT LONG_MAX | ||
81 | |||
82 | #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) | ||
83 | |||
84 | /* | ||
85 | * Only used in clk_gm20b.c which we will never unit test. Don't use! | ||
86 | */ | ||
87 | #define DIV_ROUND_CLOSEST(x, divisor) ({BUG(); 0; }) | ||
88 | |||
89 | /* | ||
90 | * Joys of userspace: usually division just works since the compiler can link | ||
91 | * against external division functions implicitly. | ||
92 | */ | ||
93 | #define do_div(a, b) ((a) /= (b)) | ||
94 | #define div64_u64(a, b) ((a) / (b)) | ||
95 | |||
96 | #define __round_mask(x, y) ((__typeof__(x))((y) - 1)) | ||
97 | #define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1) | ||
98 | #define roundup(x, y) round_up(x, y) | ||
99 | #define round_down(x, y) ((x) & ~__round_mask(x, y)) | ||
100 | |||
101 | #define ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) | ||
102 | #define ALIGN(x, a) ALIGN_MASK(x, (typeof(x))(a) - 1) | ||
103 | #define PAGE_ALIGN(x) ALIGN(x, PAGE_SIZE) | ||
104 | |||
105 | /* | ||
106 | * Caps return at the size of the buffer not what would have been written if buf | ||
107 | * were arbitrarily sized. | ||
108 | */ | ||
109 | static inline int scnprintf(char *buf, size_t size, const char *format, ...) | ||
110 | { | ||
111 | size_t ret; | ||
112 | va_list args; | ||
113 | |||
114 | va_start(args, format); | ||
115 | ret = vsnprintf(buf, size, format, args); | ||
116 | va_end(args); | ||
117 | |||
118 | return ret <= size ? ret : size; | ||
119 | } | ||
120 | |||
121 | static inline u32 be32_to_cpu(u32 x) | ||
122 | { | ||
123 | /* | ||
124 | * Conveniently big-endian happens to be network byte order as well so | ||
125 | * we can use ntohl() for this. | ||
126 | */ | ||
127 | return ntohl(x); | ||
128 | } | ||
129 | |||
130 | /* | ||
131 | * Hamming weights. | ||
132 | */ | ||
133 | static inline unsigned long __hweight8(uint8_t x) | ||
134 | { | ||
135 | return (unsigned long)(!!(x & (1 << 0)) + | ||
136 | !!(x & (1 << 1)) + | ||
137 | !!(x & (1 << 2)) + | ||
138 | !!(x & (1 << 3)) + | ||
139 | !!(x & (1 << 4)) + | ||
140 | !!(x & (1 << 5)) + | ||
141 | !!(x & (1 << 6)) + | ||
142 | !!(x & (1 << 7))); | ||
143 | } | ||
144 | |||
145 | static inline unsigned long __hweight16(uint16_t x) | ||
146 | { | ||
147 | return __hweight8((uint8_t)x) + | ||
148 | __hweight8((uint8_t)((x & 0xff00) >> 8)); | ||
149 | } | ||
150 | |||
151 | static inline unsigned long __hweight32(uint32_t x) | ||
152 | { | ||
153 | return __hweight16((uint16_t)x) + | ||
154 | __hweight16((uint16_t)((x & 0xffff0000) >> 16)); | ||
155 | } | ||
156 | |||
157 | static inline unsigned long __hweight64(uint64_t x) | ||
158 | { | ||
159 | return __hweight32((uint32_t)x) + | ||
160 | __hweight32((uint32_t)((x & 0xffffffff00000000) >> 32)); | ||
161 | } | ||
162 | |||
163 | #define hweight32 __hweight32 | ||
164 | #define hweight_long __hweight64 | ||
165 | |||
166 | /* | ||
167 | * Better suited under a compiler.h type header file, but for now these can live | ||
168 | * here. | ||
169 | */ | ||
170 | #define __must_check | ||
171 | #define __maybe_unused __attribute__((unused)) | ||
172 | #define __iomem | ||
173 | #define __user | ||
174 | #define unlikely | ||
175 | #define likely | ||
176 | |||
177 | #define __stringify(x) #x | ||
178 | |||
179 | /* | ||
180 | * Prevent compiler optimizations from mangling writes. But likely most uses of | ||
181 | * this in nvgpu are incorrect (i.e unnecessary). | ||
182 | */ | ||
183 | #define WRITE_ONCE(p, v) \ | ||
184 | ({ \ | ||
185 | volatile typeof(p) *__p__ = &(p); \ | ||
186 | *__p__ = v; \ | ||
187 | }) | ||
188 | |||
189 | #define container_of(ptr, type, member) ({ \ | ||
190 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | ||
191 | (type *)( (char *)__mptr - offsetof(type,member) );}) | ||
192 | |||
193 | #define __packed __attribute__((packed)) | ||
194 | |||
195 | #define IS_ENABLED(config) 0 | ||
196 | |||
197 | #define MAX_ERRNO 4095 | ||
198 | |||
199 | #define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO) | ||
200 | |||
201 | static inline void *ERR_PTR(long error) | ||
202 | { | ||
203 | return (void *) error; | ||
204 | } | ||
205 | |||
206 | static inline long PTR_ERR(void *error) | ||
207 | { | ||
208 | return (long)(uintptr_t)error; | ||
209 | } | ||
210 | |||
211 | static inline bool IS_ERR(const void *ptr) | ||
212 | { | ||
213 | return IS_ERR_VALUE((unsigned long)ptr); | ||
214 | } | ||
215 | |||
216 | static inline bool IS_ERR_OR_NULL(const void *ptr) | ||
217 | { | ||
218 | return (ptr == NULL) || IS_ERR_VALUE((unsigned long)ptr); | ||
219 | } | ||
220 | |||
221 | #endif | ||