summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorThomas Weißschuh <linux@weissschuh.net>2026-04-04 11:08:20 +0300
committerThomas Weißschuh <linux@weissschuh.net>2026-04-04 11:28:50 +0300
commit70091eada34c9ebc650dc88dd0e8c9246c5df8f8 (patch)
tree6c4fbc2bf24bea4f5360e83fed161af5f8a953ba /tools
parent5afc7e9b90b82e0c43615dcf2ff0559909714d83 (diff)
downloadlinux-70091eada34c9ebc650dc88dd0e8c9246c5df8f8.tar.xz
tools/nolibc: move the logic of makedev() and friends into functions
Functions make it easier to keep the input and output types straight and avoid duplicate evaluations of their arguments. Also these functions will become a bit more complex to handle full 64-bit 'dev_t' which is easier to read in a function. Still stay compatible with code which expects these to be macros. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://patch.msgid.link/20260404-nolibc-makedev-v2-3-456a429bf60c@weissschuh.net
Diffstat (limited to 'tools')
-rw-r--r--tools/include/nolibc/sys/sysmacros.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/tools/include/nolibc/sys/sysmacros.h b/tools/include/nolibc/sys/sysmacros.h
index 37c33f030f02..347a95341ea2 100644
--- a/tools/include/nolibc/sys/sysmacros.h
+++ b/tools/include/nolibc/sys/sysmacros.h
@@ -13,8 +13,25 @@
#include "../std.h"
/* WARNING, it only deals with the 4096 first majors and 256 first minors */
-#define makedev(major, minor) ((dev_t)((((major) & 0xfff) << 8) | ((minor) & 0xff)))
-#define major(dev) ((unsigned int)(((dev) >> 8) & 0xfff))
-#define minor(dev) ((unsigned int)((dev) & 0xff))
+static __inline__ dev_t __nolibc_makedev(unsigned int maj, unsigned int min)
+{
+ return ((maj & 0xfff) << 8) | (min & 0xff);
+}
+
+#define makedev(maj, min) __nolibc_makedev(maj, min)
+
+static __inline__ unsigned int __nolibc_major(dev_t dev)
+{
+ return (dev >> 8) & 0xfff;
+}
+
+#define major(dev) __nolibc_major(dev)
+
+static __inline__ unsigned int __nolibc_minor(dev_t dev)
+{
+ return dev & 0xff;
+}
+
+#define minor(dev) __nolibc_minor(dev)
#endif /* _NOLIBC_SYS_SYSMACROS_H */