From 5e36a64acb1a63ae2c4fe4b461fe90592fa8e39f Mon Sep 17 00:00:00 2001 From: Theodor Chikin Date: Thu, 9 Oct 2025 15:38:10 +0300 Subject: [PATCH] now printf is disabled if twiddles arrays are external. Now while used for emdedded there is no prfintf garbage in compiled code. --- C/FFT_FP_realisation.c | 8 ++++++++ C/FFT_FP_realisation.h | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/C/FFT_FP_realisation.c b/C/FFT_FP_realisation.c index ec6bdf1..fd5561c 100644 --- a/C/FFT_FP_realisation.c +++ b/C/FFT_FP_realisation.c @@ -6,8 +6,11 @@ #ifndef FFT_FP_EXTERNAL_TWIDDLES static int64_t twiddle_re[TWIDDLE_L] = {0,}; static int64_t twiddle_im[TWIDDLE_L] = {0,}; +#define PRINTF #endif + + void fft_twiddle_gen(int64_t* tw_re, int64_t* tw_im){ for (uint32_t k = 0; k < TWIDDLE_L; ++k){ double angle = 2.0 * PI * k / DATA_L; @@ -19,7 +22,9 @@ void fft_twiddle_gen(int64_t* tw_re, int64_t* tw_im){ void fft_fp_prepare(void){ fft_twiddle_gen(twiddle_re, twiddle_im); for (uint32_t k = 0; k < TWIDDLE_L; ++k){ +#ifdef PRINTF printf("k, angle, tw_re, tw_im: %u %g %lld %lld\n", k, 2.0 * PI * k / DATA_L, (long long)twiddle_re[k], (long long)twiddle_im[k]); +#endif } } @@ -90,7 +95,10 @@ void FFT_fp(int64_t* inp, uint32_t inp_L, int64_t* buf){ for (uint32_t ii = 0; ii < inp_L; ++ii){ buf[ii*2] /= inp_L; buf[ii*2+1] /= inp_L; +#ifdef PRINTF printf("re,im: %lld, %lld\n", (long long)buf[ii*2], (long long)buf[ii*2 +1]); +#endif + } } diff --git a/C/FFT_FP_realisation.h b/C/FFT_FP_realisation.h index 6331ce8..2fcec2f 100644 --- a/C/FFT_FP_realisation.h +++ b/C/FFT_FP_realisation.h @@ -20,8 +20,8 @@ #endif #ifdef FFT_FP_EXTERNAL_TWIDDLES -extern int64_t twiddle_re[TWIDDLE_L]; -extern int64_t twiddle_im[TWIDDLE_L]; +extern volatile int64_t twiddle_re[TWIDDLE_L]; +extern volatile int64_t twiddle_im[TWIDDLE_L]; #endif void fft_twiddle_gen(int64_t* twiddle_re, int64_t* twiddle_im);