diff options
| author | Jean-Sébastien Pédron <dumbbell@FreeBSD.org> | 2026-04-13 22:36:18 +0000 |
|---|---|---|
| committer | Jean-Sébastien Pédron <dumbbell@FreeBSD.org> | 2026-04-21 22:18:25 +0000 |
| commit | cefd0ae770bfad534ec666099489a869387e8836 (patch) | |
| tree | 9d38ed0de985bae3dd920e6fc1aefa9fd9eeb24a | |
| parent | ae1f6954e2c82ad7f1d8b80155a921b908d51756 (diff) | |
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
| -rw-r--r-- | sys/compat/linuxkpi/common/include/linux/uuid.h | 27 | ||||
| -rw-r--r-- | sys/compat/linuxkpi/common/src/linux_compat.c | 3 |
2 files changed, 30 insertions, 0 deletions
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) { |
