[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[csmith-dev] Combined use of csmith_minimal.h and safe_math_macros.h

Dear Csmith developers,

I am using Csmith 2.2.0 (git dcef52) and preprocessing/compiling the C files produced by Csmith with -DCSMITH_MINIMAL to use csmith_minimal.h instead of the definitions of csmith.h, thus reducing the set of included functions to the minimum (in particular by not requiring too many standard header files). However, such a file will still include safe_math.h whereas I claim it can be replaced with safe_math_macros.h thus further reducing the set of included functions (in particular if the C source file was generated by Csmith with --no-safe-math).

By reading random_inc.h, it seems that USE_MATH_MACROS can be used alone to replace safe_math.h with safe_math_macros.h, but when used with CSMITH_MINIMAL, it becomes inoperant. To solve this issue and allow the combined use of USE_MATH_MACROS and CSMITH_MINIMAL, I attached a patch for csmith_minimal.h following the same pattern as in random_inc.h.

Is my understanding of these preprocessing symbols correct? Are they stable enough (even though not extensively documented) to be used in practice?
If so, do you think this patch is worth considering for inclusion?

(As an alternative to my patch proposal, you might prefer handling USE_MATH_MACROS from within safe_math.h to "redirect" the preprocessor to safe_math_minimal.h, in the same way as CSMITH_MINIMAL being handled from within csmith.h to "redirect" to csmith_minimal.h, thus avoiding the duplication of compilation directives from random_inc.h to csmith_minimal.h)

Thank you in advance for your help.
Best regards,

Tahina Oliver Ramananandro, Ph. D.
Senior Engineer, Advanced Compilers and Formal Verification
Reservoir Labs, Inc.
632 Broadway, Suite 803
New York, NY 10012
Phone: +1 (212) 780-0527 ext. 157

--- a/runtime/csmith_minimal.h	2014-12-31 16:46:24.000000000 -0500
+++ b/runtime/csmith_minimal.h	2015-10-26 14:17:05.965143315 -0400
@@ -52,7 +52,15 @@
 #define assert(x)
+#if defined (USE_MATH_MACROS_NOTMP)
+#include "safe_math_macros_notmp.h"
+#elif defined (USE_MATH_MACROS)
+#include "safe_math_macros.h"
+#define FUNC_NAME(x) (safe_##x)
 #include "safe_math.h"
+#undef FUNC_NAME
 static inline void platform_main_begin(void)