diff --git a/SConstruct b/SConstruct index 096b7f340..309d935c3 100644 --- a/SConstruct +++ b/SConstruct @@ -495,6 +495,8 @@ struct %(N)s_derived : %(N)s_base { """.format(macro_name=macro_name, macro_value=macro_value, test=test), **kwargs) if not r: macro_value = _comment_not_supported + self._define_macro(context, macro_name, macro_value) + def _define_macro(self,context,macro_name,macro_value): context.sconf.Define(macro_name, macro_value) self.__defined_macros += '#define %s %s\n' % (macro_name, macro_value) implicit_tests.append(_implicit_test.RecordedTest('check_ccache_distcc_ld_works', "assume ccache, distcc, C++ compiler, and C++ linker work")) @@ -1063,7 +1065,7 @@ int main(int argc,char**argv){(void)argc;(void)argv; context.Display('%s: checking whether to use %s...%s\n' % (self.msgprefix, mixer, 'yes' if user_settings.sdlmixer else 'no')) # SDL_mixer support? use_sdlmixer = user_settings.sdlmixer - context.sconf.Define('DXX_USE_SDLMIXER', int(use_sdlmixer)) + self._define_macro(context, 'DXX_USE_SDLMIXER', int(use_sdlmixer)) if not use_sdlmixer: return successflags = self.pkgconfig.merge(context, self.msgprefix, user_settings, mixer, mixer, guess_flags) @@ -1838,6 +1840,7 @@ help:add Valgrind annotations; wipe certain freed memory when running under Valg if not r: return text = ''' +#define DXX_HAVE_POISON 1 #include "poison.h" ''' main = ''' @@ -1868,8 +1871,7 @@ help:always wipe certain freed memory for f in _methods: if f(self, context): poison = True - if poison: - context.sconf.Define('DXX_HAVE_POISON') + self._define_macro(context, 'DXX_HAVE_POISON', int(poison)) implicit_tests.append(_implicit_test.RecordedTest('check_size_type_size', "assume size_t is formatted as `size_t`")) implicit_tests.append(_implicit_test.RecordedTest('check_size_type_long', "assume size_t is formatted as `unsigned long`")) implicit_tests.append(_implicit_test.RecordedTest('check_size_type_int', "assume size_t is formatted as `unsigned int`")) diff --git a/common/include/physfsx.h b/common/include/physfsx.h index 006e6ba36..f376ac310 100644 --- a/common/include/physfsx.h +++ b/common/include/physfsx.h @@ -238,7 +238,7 @@ struct PHYSFSX_gets_line_t PHYSFSX_gets_line_t(PHYSFSX_gets_line_t &&) = default; PHYSFSX_gets_line_t &operator=(PHYSFSX_gets_line_t &&) = default; typedef array line_t; -#ifdef DXX_HAVE_POISON +#if DXX_HAVE_POISON /* Force onto heap to improve checker accuracy */ std::unique_ptr m_line; const line_t &line() const { return *m_line.get(); } @@ -274,7 +274,7 @@ struct PHYSFSX_gets_line_t<0> std::unique_ptr m_line; std::size_t m_length; PHYSFSX_gets_line_t(std::size_t n) : -#ifndef DXX_HAVE_POISON +#if !DXX_HAVE_POISON m_line(DXX_ALLOCATE_PHYSFS_LINE(n)), #endif m_length(n) @@ -284,7 +284,7 @@ struct PHYSFSX_gets_line_t<0> const char *line() const { return m_line.get(); } char *next() { -#ifdef DXX_HAVE_POISON +#if DXX_HAVE_POISON /* Reallocate to tell checker to undefine the buffer */ m_line = DXX_ALLOCATE_PHYSFS_LINE(m_length); #endif diff --git a/common/include/poison.h b/common/include/poison.h index 95034edd7..e26c1ceae 100644 --- a/common/include/poison.h +++ b/common/include/poison.h @@ -31,7 +31,7 @@ static inline void DXX_MAKE_VAR_UNDEFINED(T &b) template static inline void _DXX_POISON_MEMORY_RANGE(T b, T e, const V &v) { -#ifdef DXX_HAVE_POISON +#if DXX_HAVE_POISON int store = 0; #ifdef DXX_HAVE_POISON_OVERWRITE store |= 1; diff --git a/similar/main/bm.cpp b/similar/main/bm.cpp index 31b42e93f..817c8b48f 100644 --- a/similar/main/bm.cpp +++ b/similar/main/bm.cpp @@ -735,7 +735,7 @@ void compute_average_rgb(grs_bitmap *bm, array &rgb) auto sbits = &bm->get_bitmap_data()[4 + (bm->bm_h * data_offset)]; for (uint_fast32_t i = 0; i != bm_h; ++i) { -#ifdef DXX_HAVE_POISON +#if DXX_HAVE_POISON /* Reallocate to undefine buffer */ buf = make_unique(bm_w); #endif