git: cefd0ae770bf - main - linuxkpi: Add several `guid_*()` functions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 21 Apr 2026 22:27:13 UTC
The branch main has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=cefd0ae770bfad534ec666099489a869387e8836
commit cefd0ae770bfad534ec666099489a869387e8836
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-04-13 22:36:18 +0000
Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-04-21 22:18:25 +0000
linuxkpi: Add several `guid_*()` functions
The DRM generic code and the amdgpu DRM driver started to use several of
these functions in Linux 6.12. Likewise for `UUID_SIZE`.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56448
---
sys/compat/linuxkpi/common/include/linux/uuid.h | 27 +++++++++++++++++++++++++
sys/compat/linuxkpi/common/src/linux_compat.c | 3 +++
2 files changed, 30 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/uuid.h b/sys/compat/linuxkpi/common/include/linux/uuid.h
index 4f6f4a8b34f0..0765ef4dcc1e 100644
--- a/sys/compat/linuxkpi/common/include/linux/uuid.h
+++ b/sys/compat/linuxkpi/common/include/linux/uuid.h
@@ -33,6 +33,7 @@
#include <linux/random.h>
+#define UUID_SIZE 16
#define UUID_STRING_LEN 36
#define GUID_INIT(x0_3, x4_5, x6_7, x8, x9, x10, x11, x12, x13, x14, x15) \
@@ -59,6 +60,8 @@ typedef struct {
char x[16];
} guid_t;
+extern const guid_t guid_null;
+
static inline void
guid_gen(guid_t *g)
{
@@ -68,10 +71,34 @@ guid_gen(guid_t *g)
g->x[8] = (g->x[8] & 0x3f) | 0x80;
}
+static inline bool
+guid_equal(const guid_t *u1, const guid_t *u2)
+{
+ return (memcmp(u1, u2, sizeof(guid_t)) == 0);
+}
+
static inline void
guid_copy(guid_t *dst, const guid_t *src)
{
memcpy(dst, src, sizeof(*dst));
}
+static inline void
+import_guid(guid_t *dst, const uint8_t *src)
+{
+ memcpy(dst, src, sizeof(guid_t));
+}
+
+static inline void
+export_guid(uint8_t *dst, const guid_t *src)
+{
+ memcpy(dst, src, sizeof(guid_t));
+}
+
+static inline bool
+guid_is_null(const guid_t *guid)
+{
+ return (guid_equal(guid, &guid_null));
+}
+
#endif /* _LINUXKPI_LINUX_UUID_H */
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
index 8fc644241d79..0c7032fa6e23 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -98,6 +98,7 @@
#include <linux/interval_tree_generic.h>
#include <linux/printk.h>
#include <linux/seq_file.h>
+#include <linux/uuid.h>
#if defined(__i386__) || defined(__amd64__)
#include <asm/smp.h>
@@ -164,6 +165,8 @@ unsigned long linux_timer_hz_mask;
wait_queue_head_t linux_bit_waitq;
wait_queue_head_t linux_var_waitq;
+const guid_t guid_null;
+
int
panic_cmp(struct rb_node *one, struct rb_node *two)
{