[libc-commits] [libc] [libc][stdfix] Implement `idivfx` functions in LLVM libc (PR #133005)

Krishna Pandey via libc-commits libc-commits at lists.llvm.org
Thu Apr 17 14:08:02 PDT 2025


================
@@ -19,10 +19,19 @@
     if (LIBC_UNLIKELY((ptr) == nullptr))                                       \
       __builtin_trap();                                                        \
   } while (0)
+#define LIBC_CRASH_ON_VALUE(var, value)                                        \
+  do {                                                                         \
+    if (LIBC_UNLIKELY((var) == (value)))                                       \
+      __builtin_trap();                                                        \
+  } while (0)
+
----------------
krishna2803 wrote:

For this, I just followed what tue [suggested](https://github.com/llvm/llvm-project/pull/133005#discussion_r2016916611). Since divide by 0 is UB as mentioned in the standard, we thought of making this macro, similar to [LIBC_CRASH_ON_NULLPTR](https://github.com/llvm/llvm-project/blob/main/libc/src/__support/macros/null_check.h). Should I change it to `LIBC_ASSERT` for this case?

https://github.com/llvm/llvm-project/pull/133005


More information about the libc-commits mailing list