]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
tools: Add kernel stubs needed for rosebush
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 21 Jun 2024 18:55:35 +0000 (14:55 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 25 Jun 2024 20:58:55 +0000 (16:58 -0400)
Various parts of the kernel API didn't need to exist before, so add
them:

 - spin_trylock()
 - DECLARE_FLEX_ARRAY
 - vmalloc
 - __vmalloc_node
 - kvmalloc
 - kvfree_rcu_mightsleep

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
tools/include/linux/compiler.h
tools/include/linux/compiler_types.h
tools/include/linux/spinlock.h
tools/include/linux/stddef.h [new file with mode: 0644]
tools/testing/radix-tree/linux/kernel.h
tools/testing/radix-tree/linux/vmalloc.h [new file with mode: 0644]

index 8a63a9913495a672d4d2ed10b42134ae7f12584b..936b5153b0fe260e14587c29961ff50209813810 100644 (file)
 #define __nocf_check __attribute__((nocf_check))
 #endif
 
+#ifndef __refdata
+#define __refdata
+#endif
+
 /* Are two types/vars the same type (ignoring qualifiers)? */
 #ifndef __same_type
 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
index d09f9dc172a486875e2e62cf8550a69f24c9beed..18bd8767cebc6c0c8e40cd68df83bf7d75b306d4 100644 (file)
@@ -17,6 +17,7 @@
 /* context/locking */
 # define __must_hold(x)        __attribute__((context(x,1,1)))
 # define __acquires(x) __attribute__((context(x,0,1)))
+# define __cond_acquires(x) __attribute__((context(x,0,-1)))
 # define __releases(x) __attribute__((context(x,1,0)))
 # define __acquire(x)  __context__(x,1)
 # define __release(x)  __context__(x,-1)
@@ -27,6 +28,7 @@
 # define __acquires(x)
 # define __releases(x)
 # define __acquire(x)  (void)0
+# define __cond_acquires(x)
 # define __release(x)  (void)0
 # define __cond_lock(x,c) (c)
 #endif /* __CHECKER__ */
index a6cdf25b6b9da10433dbf7e9ed4d4d012369816d..871a6a305b9deafd2759f940338e389e3cedda73 100644 (file)
@@ -20,6 +20,8 @@
 #define spin_lock_irqsave(x, f)                (void)f, pthread_mutex_lock(x)
 #define spin_unlock_irqrestore(x, f)   (void)f, pthread_mutex_unlock(x)
 
+#define spin_trylock(x)                        (pthread_mutex_trylock(x) == 0)
+
 #define arch_spinlock_t pthread_mutex_t
 #define __ARCH_SPIN_LOCK_UNLOCKED PTHREAD_MUTEX_INITIALIZER
 
diff --git a/tools/include/linux/stddef.h b/tools/include/linux/stddef.h
new file mode 100644 (file)
index 0000000..337f520
--- /dev/null
@@ -0,0 +1,3 @@
+#include <uapi/linux/stddef.h>
+
+#define DECLARE_FLEX_ARRAY(TYPE, NAME) __DECLARE_FLEX_ARRAY(TYPE, NAME)
index c0a2bb785b92b41f2f734afa39661adcde51a433..72a95fd9708cd85637b53a7d18c8368e1a651383 100644 (file)
@@ -26,4 +26,6 @@
 #define __must_hold(x)
 
 #define EXPORT_PER_CPU_SYMBOL_GPL(x)
+
+#define PAGE_SIZE      4096
 #endif /* _KERNEL_H */
diff --git a/tools/testing/radix-tree/linux/vmalloc.h b/tools/testing/radix-tree/linux/vmalloc.h
new file mode 100644 (file)
index 0000000..2857c37
--- /dev/null
@@ -0,0 +1,14 @@
+#include <malloc.h>
+
+#define vmalloc(x)             malloc(x)
+#define __vmalloc_node(size, align, gfp, node, caller) memalign(size, align)
+#define vfree(x)               free(x)
+
+#define kvmalloc(x, gfp)       memalign(x, x)
+#define kvfree(x)              free(x)
+
+/* A correct but slow implementation */
+#define kvfree_rcu_mightsleep(x)       {                               \
+       synchronize_rcu();                                              \
+       free(x);                                                        \
+}