hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/tools/testing/scatterlist/linux/mm.h
....@@ -33,6 +33,7 @@
3333 #define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
3434 #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
3535 #define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
36
+#define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a))
3637
3738 #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
3839
....@@ -114,6 +115,12 @@
114115 return malloc(size);
115116 }
116117
118
+static inline void *
119
+kmalloc_array(unsigned int n, unsigned int size, unsigned int flags)
120
+{
121
+ return malloc(n * size);
122
+}
123
+
117124 #define kfree(x) free(x)
118125
119126 #define kmemleak_alloc(a, b, c, d)
....@@ -122,4 +129,33 @@
122129 #define PageSlab(p) (0)
123130 #define flush_kernel_dcache_page(p)
124131
132
+#define MAX_ERRNO 4095
133
+
134
+#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
135
+
136
+static inline void * __must_check ERR_PTR(long error)
137
+{
138
+ return (void *) error;
139
+}
140
+
141
+static inline long __must_check PTR_ERR(__force const void *ptr)
142
+{
143
+ return (long) ptr;
144
+}
145
+
146
+static inline bool __must_check IS_ERR(__force const void *ptr)
147
+{
148
+ return IS_ERR_VALUE((unsigned long)ptr);
149
+}
150
+
151
+static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
152
+{
153
+ if (IS_ERR(ptr))
154
+ return PTR_ERR(ptr);
155
+ else
156
+ return 0;
157
+}
158
+
159
+#define IS_ENABLED(x) (0)
160
+
125161 #endif