Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F168438626
D57583.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D57583.diff
View Options
Index: sys/compat/linuxkpi/common/include/linux/cleanup.h
===================================================================
--- sys/compat/linuxkpi/common/include/linux/cleanup.h
+++ sys/compat/linuxkpi/common/include/linux/cleanup.h
@@ -20,6 +20,32 @@
CLEANUP_NAME(_n, _t) _x __cleanup(CLEANUP_NAME(_n, _destroy)) = \
CLEANUP_NAME(_n, _create)
+/*
+ * On Linux, the following macro is called `DEFINE_CLASS()`. However it
+ * conflicts with FreeBSD's macro defined in <sys/kobj.h>.
+ *
+ * Note: "_T" are special as they are exposed into common code for
+ * statements. Extra care should be taken when changing the code.
+ */
+#define LINUXKPI_DEFINE_CLASS(_name, _type, _exit, _init, _init_args...)\
+ typedef _type class_##_name##_t; \
+ \
+ static inline _type class_##_name##_constructor(_init_args) \
+ { \
+ _type v = _init; \
+ return (v); \
+ } \
+ \
+ static inline void class_##_name##_destructor(_type *p) \
+ { \
+ _type _T = *p; \
+ _exit; \
+ }
+
+#define CLASS(_name, _var) \
+ class_##_name##_t _var __cleanup(class_##_name##_destructor) = \
+ class_##_name##_constructor
+
/*
* Note: "_T" are special as they are exposed into common code for
* statements. Extra care should be taken when changing the code.
Index: sys/compat/linuxkpi/common/include/linux/file.h
===================================================================
--- sys/compat/linuxkpi/common/include/linux/file.h
+++ sys/compat/linuxkpi/common/include/linux/file.h
@@ -184,6 +184,8 @@
return (struct fd){f};
}
+LINUXKPI_DEFINE_CLASS(fd, struct fd, fdput(_T), fdget(fd), int fd)
+
#define fd_file(fd) ((fd).linux_file)
static inline bool
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Aug 29, 8:50 AM (15 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37503459
Default Alt Text
D57583.diff (1 KB)
Attached To
Mode
D57583: linuxkpi: Define `DEFINE_CLASS()` and `CLASS()`
Attached
Detach File
Event Timeline
Log In to Comment