hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/arch/x86/include/asm/div64.h
....@@ -73,6 +73,29 @@
7373
7474 #else
7575 # include <asm-generic/div64.h>
76
+
77
+/*
78
+ * Will generate an #DE when the result doesn't fit u64, could fix with an
79
+ * __ex_table[] entry when it becomes an issue.
80
+ */
81
+static inline u64 mul_u64_u64_div_u64(u64 a, u64 mul, u64 div)
82
+{
83
+ u64 q;
84
+
85
+ asm ("mulq %2; divq %3" : "=a" (q)
86
+ : "a" (a), "rm" (mul), "rm" (div)
87
+ : "rdx");
88
+
89
+ return q;
90
+}
91
+#define mul_u64_u64_div_u64 mul_u64_u64_div_u64
92
+
93
+static inline u64 mul_u64_u32_div(u64 a, u32 mul, u32 div)
94
+{
95
+ return mul_u64_u64_div_u64(a, mul, div);
96
+}
97
+#define mul_u64_u32_div mul_u64_u32_div
98
+
7699 #endif /* CONFIG_X86_32 */
77100
78101 #endif /* _ASM_X86_DIV64_H */