]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/nolibc: Import sys/sysmacros.h
authorAndrei Tatar <andrei@unikraft.io>
Thu, 6 Feb 2025 11:22:56 +0000 (12:22 +0100)
committerUnikraft Bot <monkey@unikraft.io>
Mon, 10 Feb 2025 10:46:41 +0000 (10:46 +0000)
Provides convenient macros for handling minor/major device numbers and
encoding these into a single dev_t.
Imported verbatim; checkpatch ignored.

Source of import:
Repository: git://git.musl-libc.org/musl
Tag: v1.2.4 (f5f55d65)
Path: include/sys/sysmacros.h

Checkpatch-Ignore: SPDX_LICENSE_TAG
Checkpatch-Ignore: MACRO_ARG_REUSE
Checkpatch-Ignore: UNSPECIFIED_INT
Checkpatch-Ignore: SPACING
Checkpatch-Ignore: CODE_INDENT
Checkpatch-Ignore: LEADING_SPACE
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
GitHub-Closes: #1578

lib/nolibc/musl-imported/include/sys/sysmacros.h [new file with mode: 0644]

diff --git a/lib/nolibc/musl-imported/include/sys/sysmacros.h b/lib/nolibc/musl-imported/include/sys/sysmacros.h
new file mode 100644 (file)
index 0000000..07a3ef1
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef _SYS_SYSMACROS_H
+#define _SYS_SYSMACROS_H
+
+#define major(x) \
+       ((unsigned)( (((x)>>31>>1) & 0xfffff000) | (((x)>>8) & 0x00000fff) ))
+#define minor(x) \
+       ((unsigned)( (((x)>>12) & 0xffffff00) | ((x) & 0x000000ff) ))
+
+#define makedev(x,y) ( \
+        (((x)&0xfffff000ULL) << 32) | \
+       (((x)&0x00000fffULL) << 8) | \
+        (((y)&0xffffff00ULL) << 12) | \
+       (((y)&0x000000ffULL)) )
+
+#endif