1 /* This file is part of the gf2x library.
2 
3    Copyright 2007, 2008, 2009, 2010, 2013, 2014, 2015
4    Richard Brent, Pierrick Gaudry, Emmanuel Thome', Paul Zimmermann
5 
6    This program is free software; you can redistribute it and/or modify it
7    under the terms of either:
8     - If the archive contains a file named toom-gpl.c (not a trivial
9     placeholder), the GNU General Public License as published by the Free
10     Software Foundation; either version 3 of the License, or (at your
11     option) any later version.
12     - If the archive contains a file named toom-gpl.c which is a trivial
13     placeholder, the GNU Lesser General Public License as published by
14     the Free Software Foundation; either version 2.1 of the License, or
15     (at your option) any later version.
16 
17    This program is distributed in the hope that it will be useful, but WITHOUT
18    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19    FITNESS FOR A PARTICULAR PURPOSE.  See the license text for more details.
20 
21    You should have received a copy of the GNU General Public License as
22    well as the GNU Lesser General Public License along with this program;
23    see the files COPYING and COPYING.LIB.  If not, write to the Free
24    Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25    02110-1301, USA.
26 */
27 
28 #ifndef GF2X_FAKE_FFT_H_
29 #define GF2X_FAKE_FFT_H_
30 
31 #include <stdlib.h>
32 #include <string.h>
33 
34 #include "gf2x/gf2x-config-export.h"
35 #include "gf2x/gf2x-impl-export.h"
36 #include "gf2x/gf2x-thresholds.h"
37 
38 #ifndef GF2X_EXPORTED
39 #define GF2X_EXPORTED
40 #endif
41 
42 /* This file is a placeholder for the typical requirements of an FFT
43  * interface. Of course, there is nothing interesting being done here.
44  * It's just an E-X-A-M-P-L-E. See also the .c file.
45  */
46 
47 /* The section below is automatically generated */
48 /* inline: init_empty clear copy compatible order adjust */
49 
50 #ifndef GF2X_FFT_EXPORTED
51 #define GF2X_FFT_EXPORTED
52 #endif
53 
54 struct gf2x_fake_fft_info;
55 // gf2x_fake_fft_info_t is defined after the struct fields.
56 // typedef struct gf2x_fake_fft_info gf2x_fake_fft_info_t[1];
57 typedef struct gf2x_fake_fft_info * gf2x_fake_fft_info_ptr;
58 typedef const struct gf2x_fake_fft_info * gf2x_fake_fft_info_srcptr;
59 
60 /* gf2x_fake_fft_info is an implementation-defined structure that holds important
61  * auxiliary data, used for dealing with transforms. This structure may
62  * or may not consist of plain-old datatypes only, so that it only
63  * possible to copy it with care (see below).
64  *
65  * C code should use gf2x_fake_fft_info_t preferrably, as it provides transparent
66  * conversion to a pointer, and yet defines storage as well (à la GMP).
67  *
68  * C++ code should use gf2x_fake_fft_info.  When the header is included from C++
69  * code, the api below is also exported as member functions of gf2x_fake_fft_info.
70  * The info type is default-constructible in all cases, but not always
71  * trivially copyable.
72  *
73  * gf2x_fake_fft_info_ptr and gf2x_fake_fft_info_srcptr are auxiliary types used in C
74  * prototypes. C++ code should prefer references and const references to
75  * gf2x_fake_fft_info.
76  */
77 
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 
82 extern int gf2x_fake_fft_info_init(
83         gf2x_fake_fft_info_ptr p,
84         size_t bits_a,
85         size_t bits_b) GF2X_FFT_EXPORTED;
86 /* Basic constructor. Used to multiply polynomials with the given number
87  * of bits.
88  *
89  * Extra tuning may be done with gf2x_fake_fft_info_adjust
90  *
91  * Returns 0 if everything went well, and a negative number on error
92  */
93 
94 extern int gf2x_fake_fft_info_init_mp(
95         gf2x_fake_fft_info_ptr p,
96         size_t bits_a,
97         size_t bits_b) GF2X_FFT_EXPORTED;
98 /* Used to compute middle products of polynomials with the given number
99  * of bits. That is, the result MP(a, b) consists of coefficients of
100  * degrees MIN(bits_a, bits_b)-1 to MAX(bits_a, bits_b)-1 (inclusive),
101  * forming a result with MAX(bits_a, bits_b)-MIN(bits_a, bits_b)+1
102  * coefficients.
103  *
104  * Extra tuning may be done with gf2x_fake_fft_info_adjust
105  *
106  * Returns 0 if everything went well, and a negative number on error
107  */
108 
109 static inline void gf2x_fake_fft_info_init_empty(
110         gf2x_fake_fft_info_ptr p);
111 /* This is not really a constructor. Most often we expect this function
112  * to be a noop, or at most an inline. It is just meant to provide some
113  * default-initialization, so that info_clear does not choke. Note that
114  *
115  * gf2x_fake_fft_info_adjust on an empty-initialized info structure is likely to
116  * fail.
117  */
118 
119 /* Adjust the fft structure with one of the GF2X_FFT_ADJUST_* tweaks, and
120  * an extra parameter.
121  *
122  * This must be done right after the info_init (or info_init_mp) call, as
123  * this might invalidate all transforms.
124  *
125  * Returns 0 if everything went well, and a negative number on error
126  * (maybe if the extra argument was incorrect).
127  *
128  * Note that adjustments that happen to exist but are valid for other fft
129  * engines are simply ignored.
130  */
131 static inline int gf2x_fake_fft_info_adjust(
132         gf2x_fake_fft_info_ptr p,
133         int adjust_kind,
134         long val);
135 
136 static inline void gf2x_fake_fft_info_clear(
137         gf2x_fake_fft_info_ptr p);
138 /* Destructor for the info type. */
139 
140 static inline int gf2x_fake_fft_info_copy(
141         gf2x_fake_fft_info_ptr p,
142         gf2x_fake_fft_info_srcptr other);
143 /* Copy constructor. Returns 0 on success or GF2X_ERROR_OUT_OF_MEMORY.*/
144 
145 static inline int gf2x_fake_fft_info_order(
146         gf2x_fake_fft_info_srcptr p);
147 /* Return the "order", whatever that means for the underlying info type.  */
148 
149 extern void gf2x_fake_fft_info_get_alloc_sizes(
150         gf2x_fake_fft_info_srcptr p,
151         size_t sizes[3]) GF2X_FFT_EXPORTED;
152 /* Fill the sizes array with three byte counts:
153  *     sizes[0] : equivalent to gf2x_fake_fft_transform_size(p) * sizeof(gf2x_fake_fft_elt)
154  *     sizes[1] : number of bytes of temp space that must be passed to each
155  *                gf2x_fake_fft_dft or gf2x_fake_fft_ift call.
156  *     sizes[2] : number of bytes of temp space that must be passed to each
157  *                gf2x_fake_fft_compose, gf2x_fake_fft_addcompose, or gf2x_fake_fft_addcompose_n call.
158  *                Note that the addcompose variants need two temp
159  *                buffers, of sizes sizes[2] and sizes[1], respectively.
160  */
161 
162 extern char * gf2x_fake_fft_info_explain(
163         gf2x_fake_fft_info_srcptr p) GF2X_FFT_EXPORTED;
164 /* Returns a malloc()ed string that gives the description of what the
165  * transform type is doing. The returned pointer may also be NULL if the
166  * implementation does not provide that information. It should be freed
167  * by the caller eventually.
168  */
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 
174 /* End of automatically generated section */
175 
176 typedef unsigned long gf2x_fake_fft_elt;
177 
178 /* The section below is automatically generated */
179 /* inline: transform_size alloc free get get_const zero cpy */
180 /* inline: export import prepare check */
181 
182 typedef gf2x_fake_fft_elt * gf2x_fake_fft_ptr;
183 typedef const gf2x_fake_fft_elt * gf2x_fake_fft_srcptr;
184 /* A transform has type gf2x_fake_fft_ptr. It is made of a series of gf2x_fake_fft_elt
185  * objects. */
186 
187 #ifdef __cplusplus
188 extern "C" {
189 #endif
190 
191 static inline size_t gf2x_fake_fft_transform_size(
192         gf2x_fake_fft_info_srcptr o);
193 /* Number of gf2x_fake_fft_elt objects it takes to allocate one transform. */
194 
195 static inline gf2x_fake_fft_ptr gf2x_fake_fft_alloc(
196         gf2x_fake_fft_info_srcptr o,
197         size_t n);
198 /* Allocate space for n transforms. Equivalent to (gf2x_fake_fft_ptr) malloc(n *
199  * gf2x_fake_fft_transform_size(p) * sizeof(gf2x_fake_fft_elt)); */
200 
201 static inline void gf2x_fake_fft_free(
202         gf2x_fake_fft_info_srcptr o,
203         gf2x_fake_fft_ptr ptr,
204         size_t n);
205 /* Free space for n transforms. */
206 
207 static inline gf2x_fake_fft_ptr gf2x_fake_fft_get(
208         gf2x_fake_fft_info_srcptr o,
209         gf2x_fake_fft_ptr ptr,
210         size_t k);
211 /* Get the k-th transform. */
212 
213 static inline gf2x_fake_fft_srcptr gf2x_fake_fft_get_const(
214         gf2x_fake_fft_info_srcptr o,
215         gf2x_fake_fft_srcptr ptr,
216         size_t k);
217 /* Get the k-th transform. */
218 
219 static inline void gf2x_fake_fft_zero(
220         gf2x_fake_fft_info_srcptr o,
221         gf2x_fake_fft_ptr ptr,
222         size_t n);
223 /* Zero n consecutive transforms. */
224 
225 static inline void gf2x_fake_fft_cpy(
226         gf2x_fake_fft_info_srcptr o,
227         gf2x_fake_fft_ptr y,
228         gf2x_fake_fft_srcptr x,
229         size_t n);
230 /* Copy n consecutive transforms (named "cpy" by analogy to memcpy)/ */
231 
232 static inline void gf2x_fake_fft_export(
233         gf2x_fake_fft_info_srcptr o,
234         gf2x_fake_fft_ptr ptr,
235         size_t n);
236 /* Export (serialize) n consecutive transforms in place. This is a noop
237  * if the transforms are free of any pointers, which is always the case
238  * with gf2x. */
239 
240 static inline void gf2x_fake_fft_import(
241         gf2x_fake_fft_info_srcptr o,
242         gf2x_fake_fft_ptr ptr,
243         size_t n);
244 /* Import (deserialize) n consecutive transforms in place. This is a noop
245  * if the transforms are free of any pointers, which is always the case
246  * with gf2x. */
247 
248 static inline void gf2x_fake_fft_prepare(
249         gf2x_fake_fft_info_srcptr o,
250         gf2x_fake_fft_ptr ptr,
251         size_t n);
252 /* Prepare n consecutive transforms in place so that they're
253  * pointer-correct, but do not set any of the internal data. It is
254  * conceivably simpler than gf2x_fake_fft_zero. This is a noop if the transforms
255  * are free of any pointers, which is always the case with gf2x. */
256 
257 static inline int gf2x_fake_fft_check(
258         gf2x_fake_fft_info_srcptr o,
259         gf2x_fake_fft_srcptr ptr,
260         size_t n,
261         int printf_diagnostics);
262 /* Checks that the n consecutive transforms are valid (in particular,
263  * pointer-correct if relevant). This might be a noop if the transforms
264  * are free of any pointers, which is always the case with gf2x. */
265 
266 #if 0 && defined(__GNU_MP__) /* we don't want a gmp dependency... */
267 extern void gf2x_fake_fft_fill_random(
268         gf2x_fake_fft_info_srcptr o,
269         gf2x_fake_fft_ptr ptr,
270         size_t n,
271         gmp_randstate_t rstate) GF2X_FFT_EXPORTED;
272 /* fill n consecutive transforms with random data from the provided
273  * random state.
274  */
275 #endif
276 
277 extern void gf2x_fake_fft_add(
278         gf2x_fake_fft_info_srcptr o,
279         gf2x_fake_fft_ptr tc,
280         gf2x_fake_fft_srcptr ta,
281         gf2x_fake_fft_srcptr tb) GF2X_FFT_EXPORTED;
282 /* Add two transforms to tc. tc==ta or tc==tb are allowed. */
283 
284 extern int gf2x_fake_fft_dft(
285         gf2x_fake_fft_info_srcptr o,
286         gf2x_fake_fft_ptr tr,
287         const unsigned long * a,
288         size_t bits_a,
289         gf2x_fake_fft_ptr temp1) GF2X_FFT_EXPORTED;
290 /* Compute the dft of the polynomial pointed to by a. Attention: the size
291  * is given in number of *bits*, not in number of unsigned longs.  temp1
292  * must point to storage of size sizes[1], with sizes[] filled as in the
293  * gf2x_fake_fft_info_get_alloc_sizes call.
294  *
295  * Returns 0 on success or GF2X_ERROR_OUT_OF_MEMORY (only minor extra
296  * allocation is needed by some implementations).
297  */
298 
299 extern int gf2x_fake_fft_ift(
300         gf2x_fake_fft_info_srcptr o,
301         unsigned long * c,
302         size_t bits_c,
303         gf2x_fake_fft_ptr tr,
304         gf2x_fake_fft_ptr temp1) GF2X_FFT_EXPORTED;
305 /* Compute the ift of the transform tr, to polynomial pointed to by c.
306  * Attention: the size is given in number of *bits*, not in number of
307  * unsigned longs.  temp1 must point to storage of size sizes[1], with
308  * sizes[] filled as in the gf2x_fake_fft_info_get_alloc_sizes call.
309  *
310  * Returns 0 on success or GF2X_ERROR_OUT_OF_MEMORY (only minor extra
311  * allocation is needed by some implementations).
312  */
313 
314 extern int gf2x_fake_fft_compose(
315         gf2x_fake_fft_info_srcptr o,
316         gf2x_fake_fft_ptr tc,
317         gf2x_fake_fft_srcptr ta,
318         gf2x_fake_fft_srcptr tb,
319         gf2x_fake_fft_ptr temp2) GF2X_FFT_EXPORTED;
320 /* Compose two DFTs.  temp2 must point to storage of size sizes[2], with
321  * sizes[] filled as in the gf2x_fake_fft_info_get_alloc_sizes call.
322  *
323  * Returns 0 on success or GF2X_ERROR_OUT_OF_MEMORY (only minor extra
324  * allocation is needed by some implementations).
325  */
326 
327 extern int gf2x_fake_fft_addcompose_n(
328         gf2x_fake_fft_info_srcptr o,
329         gf2x_fake_fft_ptr tc,
330         gf2x_fake_fft_srcptr * ta,
331         gf2x_fake_fft_srcptr * tb,
332         size_t n,
333         gf2x_fake_fft_ptr temp2,
334         gf2x_fake_fft_ptr temp1) GF2X_FFT_EXPORTED;
335 /* Compose 2n DFTs, and add the result to tc. temp1 and temp2 must point to
336  * storage of size sizes[1] and sizes[2], respectively, with sizes[]
337  * filled as in the gf2x_fake_fft_info_get_alloc_sizes call.
338  *
339  * Returns 0 on success or GF2X_ERROR_OUT_OF_MEMORY (only minor extra
340  * allocation is needed by some implementations).
341  */
342 
343 extern int gf2x_fake_fft_addcompose(
344         gf2x_fake_fft_info_srcptr o,
345         gf2x_fake_fft_ptr tc,
346         gf2x_fake_fft_srcptr ta,
347         gf2x_fake_fft_srcptr tb,
348         gf2x_fake_fft_ptr temp2,
349         gf2x_fake_fft_ptr temp1) GF2X_FFT_EXPORTED;
350 /* Compose 2 DFTs, and add the result to tc. temp1 and temp2 must point to
351  * storage of size sizes[1] and sizes[2], respectively, with sizes[]
352  * filled as in the gf2x_fake_fft_info_get_alloc_sizes call.
353  *
354  * Returns 0 on success or GF2X_ERROR_OUT_OF_MEMORY (only minor extra
355  * allocation is needed by some implementations).
356  */
357 
358 #ifdef __cplusplus
359 }
360 #endif
361 
362 #ifdef __cplusplus
363 #include <exception>
364 #include <array>
365 #include <string>
366 #endif
367 
368 /* End of automatically generated section */
369 
370 
371 struct gf2x_fake_fft_info {
372     size_t n1,n2,n3;
373     size_t size;
374     size_t mp_shift;
375 
376     /* The section below is automatically generated */
377     /* pod: yes */
378 #ifdef __cplusplus
379 
380     // a C++ compilation unit that (odr-) uses this interface must include a
381     // definition like
382     //
383     // constexpr const char * gf2x_fake_fft_info::name;
384     //
385     // Note that libgf2x-fft has no C++ compilation unit, so we request
386     // the user to do this extra bit of work.
387     //
388     // Note also that as per C++11 9.4.2.3, this is only necessary if the
389     // member is odr-used.
390     static constexpr const char * name = "gf2x_fake_fft";
391 
392     class ctor_fails: public std::exception
393     {
whatgf2x_fake_fft_info394       virtual const char* what() const throw() {
395         return "contructor failed for gf2x_fake_fft";
396       }
397     };
398 
399     typedef gf2x_fake_fft_elt elt;
400     typedef gf2x_fake_fft_ptr ptr;
401     typedef gf2x_fake_fft_srcptr srcptr;
402 
403     inline gf2x_fake_fft_info() = default;
gf2x_fake_fft_infogf2x_fake_fft_info404     inline gf2x_fake_fft_info(size_t nF, size_t nG)
405     {
406         if (gf2x_fake_fft_info_init(this, nF, nG) < 0)
407             throw ctor_fails();
408     }
409     inline ~gf2x_fake_fft_info() = default;
410     inline gf2x_fake_fft_info(gf2x_fake_fft_info const &) = default;
411     inline gf2x_fake_fft_info& operator=(gf2x_fake_fft_info const &) = default;
412     /* Use named constructor idiom for the variants */
mul_infogf2x_fake_fft_info413     inline static gf2x_fake_fft_info mul_info(size_t nF, size_t nG) {
414         gf2x_fake_fft_info a;
415         if (gf2x_fake_fft_info_init(&a, nF, nG) < 0)
416             throw ctor_fails();
417         return a;
418     }
mp_infogf2x_fake_fft_info419     inline static gf2x_fake_fft_info mp_info(size_t nF, size_t nG) {
420         gf2x_fake_fft_info a;
421         if (gf2x_fake_fft_info_init_mp(&a, nF, nG) < 0)
422             throw ctor_fails();
423         return a;
424     }
adjustgf2x_fake_fft_info425     inline int adjust(int adjust_kind, long val) {
426         return gf2x_fake_fft_info_adjust(this, adjust_kind, val);
427     }
ordergf2x_fake_fft_info428     inline int order() const {
429         return gf2x_fake_fft_info_order(this);
430     }
get_alloc_sizesgf2x_fake_fft_info431     inline std::array<size_t, 3> get_alloc_sizes() const {
432         std::array<size_t, 3> sizes;
433         gf2x_fake_fft_info_get_alloc_sizes(this, &sizes[0]);
434         return sizes;
435     }
436     /* This is equal to transform_size() * sizeof(elt) */
size0_bytesgf2x_fake_fft_info437     inline size_t size0_bytes() const { return get_alloc_sizes()[0]; }
size1_bytesgf2x_fake_fft_info438     inline size_t size1_bytes() const { return get_alloc_sizes()[1]; }
size2_bytesgf2x_fake_fft_info439     inline size_t size2_bytes() const { return get_alloc_sizes()[2]; }
transform_sizegf2x_fake_fft_info440     inline size_t transform_size() const { return gf2x_fake_fft_transform_size(this); }
441     inline ptr alloc(size_t n = 1) const { return gf2x_fake_fft_alloc(this, n); }
442     inline void free(ptr x, size_t n = 1) const { gf2x_fake_fft_free(this, x, n); }
getgf2x_fake_fft_info443     inline ptr get(ptr x, size_t k) const { return gf2x_fake_fft_get(this, x, k); }
getgf2x_fake_fft_info444     inline srcptr get(srcptr x, size_t k) const { return gf2x_fake_fft_get_const(this, x, k); }
445     inline void zero(ptr x, size_t n = 1) const { gf2x_fake_fft_zero(this, x, n); }
446     inline void to_export(ptr x, size_t n = 1) const { gf2x_fake_fft_export(this, x, n); }
447     inline void to_import(ptr x, size_t n = 1) const { gf2x_fake_fft_import(this, x, n); }
448     inline void prepare(ptr x, size_t n = 1) const { gf2x_fake_fft_prepare(this, x, n); }
checkgf2x_fake_fft_info449     inline bool check(srcptr x, size_t n, bool printf_diagnostics) const { return gf2x_fake_fft_check(this, x, n, printf_diagnostics); }
checkgf2x_fake_fft_info450     inline bool check(srcptr x, bool printf_diagnostics) const { return gf2x_fake_fft_check(this, x, 1, printf_diagnostics); }
451 #if 0 && defined(__GNU_MP__) /* we don't want a gmp dependency... */
452     inline void fill_random(ptr x, size_t n, gmp_randstate_t rstate) const {
453         gf2x_fake_fft_fill_random(x, n, rstate);
454     }
455     inline void fill_random(ptr x, gmp_randstate_t rstate) const {
456         gf2x_fake_fft_fill_random(x, 1, rstate);
457     }
458 #endif
459 
dftgf2x_fake_fft_info460     inline int dft(ptr x, const unsigned long * F, size_t nF, ptr temp1) const {
461         return gf2x_fake_fft_dft(this, x, F, nF, temp1);
462     }
composegf2x_fake_fft_info463     inline int compose(ptr y, srcptr x1, srcptr x2, ptr temp2) const
464     {
465         return gf2x_fake_fft_compose(this, y, x1, x2, temp2);
466     }
addcomposegf2x_fake_fft_info467     inline int addcompose(ptr y, srcptr x1, srcptr x2, ptr temp2, ptr temp1) const
468     {
469         return gf2x_fake_fft_addcompose(this, y, x1, x2, temp2, temp1);
470     }
addcompose_ngf2x_fake_fft_info471     inline int addcompose_n(ptr y, srcptr * x1, srcptr * x2, size_t n, ptr temp2, ptr temp1) const
472     {
473         return gf2x_fake_fft_addcompose_n(this, y, x1, x2, n, temp2, temp1);
474     }
addgf2x_fake_fft_info475     inline void add(ptr y, srcptr x1, srcptr x2) const
476     {
477         gf2x_fake_fft_add(this, y, x1, x2);
478     }
479     inline void cpy(ptr y, srcptr x, size_t n = 1) const
480     {
481         gf2x_fake_fft_cpy(this, y, x, n);
482     }
iftgf2x_fake_fft_info483     inline int ift(unsigned long * H, size_t Hl, ptr h, ptr temp1) const
484     {
485         return gf2x_fake_fft_ift(this, H, Hl, h, temp1);
486     }
explaingf2x_fake_fft_info487     std::string explain() const { char * x = gf2x_fake_fft_info_explain(this); std::string s = x; ::free(x); return s; }
488 #endif
489 
490     /* End of automatically generated section */
491 };
492 /* The section below is automatically generated */
493 /* Now that gf2x_fake_fft_info is declared completely, we may declare the 1-sized
494  * array */
495 typedef struct gf2x_fake_fft_info gf2x_fake_fft_info_t[1];
496 /* End of automatically generated section */
497 
498 #ifdef __cplusplus
499 extern "C" {
500 #endif
501 
gf2x_fake_fft_info_adjust(gf2x_fake_fft_info_ptr p GF2X_MAYBE_UNUSED,int adjust_kind GF2X_MAYBE_UNUSED,long val GF2X_MAYBE_UNUSED)502 static inline int gf2x_fake_fft_info_adjust(
503         gf2x_fake_fft_info_ptr p GF2X_MAYBE_UNUSED,
504         int adjust_kind GF2X_MAYBE_UNUSED,
505         long val GF2X_MAYBE_UNUSED)
506 { return 0; }
507 
gf2x_fake_fft_info_clear(gf2x_fake_fft_info_ptr p GF2X_MAYBE_UNUSED)508 static inline void gf2x_fake_fft_info_clear(
509         gf2x_fake_fft_info_ptr p GF2X_MAYBE_UNUSED)
510 {}
gf2x_fake_fft_info_init_empty(gf2x_fake_fft_info_ptr p)511 static inline void gf2x_fake_fft_info_init_empty(
512         gf2x_fake_fft_info_ptr p)
513 {
514     p->n1 = p->n2 = p->n3 = p->size = 0;
515 }
gf2x_fake_fft_info_copy(gf2x_fake_fft_info_ptr o,gf2x_fake_fft_info_srcptr other)516 static inline int gf2x_fake_fft_info_copy(
517         gf2x_fake_fft_info_ptr o,
518         gf2x_fake_fft_info_srcptr other)
519 {
520         memcpy(o, other, sizeof(struct gf2x_fake_fft_info));
521         return 0;
522 }
gf2x_fake_fft_info_compatible(gf2x_fake_fft_info_srcptr o1 GF2X_MAYBE_UNUSED,gf2x_fake_fft_info_srcptr o2 GF2X_MAYBE_UNUSED)523 static inline int gf2x_fake_fft_info_compatible(
524         gf2x_fake_fft_info_srcptr o1 GF2X_MAYBE_UNUSED,
525         gf2x_fake_fft_info_srcptr o2 GF2X_MAYBE_UNUSED)
526 {
527         return 1;
528 }
gf2x_fake_fft_info_order(gf2x_fake_fft_info_srcptr o GF2X_MAYBE_UNUSED)529 static inline int gf2x_fake_fft_info_order(
530         gf2x_fake_fft_info_srcptr o GF2X_MAYBE_UNUSED)
531 {
532         return 0;
533 }
534 
535 
gf2x_fake_fft_transform_size(gf2x_fake_fft_info_srcptr p)536 static inline size_t gf2x_fake_fft_transform_size(gf2x_fake_fft_info_srcptr p)
537 {
538         return p->size;
539 }
540 
gf2x_fake_fft_alloc(gf2x_fake_fft_info_srcptr p,size_t n)541 static inline gf2x_fake_fft_ptr gf2x_fake_fft_alloc(
542         gf2x_fake_fft_info_srcptr p,
543         size_t n)
544 {
545         return (gf2x_fake_fft_ptr) malloc(n * gf2x_fake_fft_transform_size(p) * sizeof(gf2x_fake_fft_elt));
546 }
547 
gf2x_fake_fft_free(gf2x_fake_fft_info_srcptr p GF2X_MAYBE_UNUSED,gf2x_fake_fft_ptr x,size_t n GF2X_MAYBE_UNUSED)548 static inline void gf2x_fake_fft_free(
549         gf2x_fake_fft_info_srcptr p GF2X_MAYBE_UNUSED,
550         gf2x_fake_fft_ptr x,
551         size_t n GF2X_MAYBE_UNUSED)
552 {
553         free(x);
554 }
gf2x_fake_fft_get(gf2x_fake_fft_info_srcptr p,gf2x_fake_fft_ptr x,size_t k)555 static inline gf2x_fake_fft_ptr gf2x_fake_fft_get(gf2x_fake_fft_info_srcptr p, gf2x_fake_fft_ptr x, size_t k)
556 {
557         return x + k * gf2x_fake_fft_transform_size(p);
558 }
gf2x_fake_fft_get_const(gf2x_fake_fft_info_srcptr p,gf2x_fake_fft_srcptr x,size_t k)559 static inline gf2x_fake_fft_srcptr gf2x_fake_fft_get_const(gf2x_fake_fft_info_srcptr p, gf2x_fake_fft_srcptr x, size_t k)
560 {
561         return x + k * gf2x_fake_fft_transform_size(p);
562 }
gf2x_fake_fft_zero(gf2x_fake_fft_info_srcptr p,gf2x_fake_fft_ptr x,size_t n)563 static inline void gf2x_fake_fft_zero(gf2x_fake_fft_info_srcptr p, gf2x_fake_fft_ptr x, size_t n)
564 {
565         memset(x, 0, n * gf2x_fake_fft_transform_size(p) * sizeof(gf2x_fake_fft_elt));
566 }
gf2x_fake_fft_cpy(gf2x_fake_fft_info_srcptr p,gf2x_fake_fft_ptr y,gf2x_fake_fft_srcptr x,size_t n)567 static inline void gf2x_fake_fft_cpy(gf2x_fake_fft_info_srcptr p, gf2x_fake_fft_ptr y, gf2x_fake_fft_srcptr x, size_t n)
568 {
569     memcpy(y, x, n * gf2x_fake_fft_transform_size(p) * sizeof(gf2x_fake_fft_elt));
570 }
571 
gf2x_fake_fft_export(gf2x_fake_fft_info_srcptr o GF2X_MAYBE_UNUSED,gf2x_fake_fft_ptr ptr GF2X_MAYBE_UNUSED,size_t n GF2X_MAYBE_UNUSED)572 static inline void gf2x_fake_fft_export(
573         gf2x_fake_fft_info_srcptr o GF2X_MAYBE_UNUSED,
574         gf2x_fake_fft_ptr ptr GF2X_MAYBE_UNUSED,
575         size_t n GF2X_MAYBE_UNUSED) {}
gf2x_fake_fft_import(gf2x_fake_fft_info_srcptr o GF2X_MAYBE_UNUSED,gf2x_fake_fft_ptr ptr GF2X_MAYBE_UNUSED,size_t n GF2X_MAYBE_UNUSED)576 static inline void gf2x_fake_fft_import(
577         gf2x_fake_fft_info_srcptr o GF2X_MAYBE_UNUSED,
578         gf2x_fake_fft_ptr ptr GF2X_MAYBE_UNUSED,
579         size_t n GF2X_MAYBE_UNUSED) {}
gf2x_fake_fft_prepare(gf2x_fake_fft_info_srcptr o GF2X_MAYBE_UNUSED,gf2x_fake_fft_ptr ptr GF2X_MAYBE_UNUSED,size_t n GF2X_MAYBE_UNUSED)580 static inline void gf2x_fake_fft_prepare(
581         gf2x_fake_fft_info_srcptr o GF2X_MAYBE_UNUSED,
582         gf2x_fake_fft_ptr ptr GF2X_MAYBE_UNUSED,
583         size_t n GF2X_MAYBE_UNUSED) {}
gf2x_fake_fft_check(gf2x_fake_fft_info_srcptr o GF2X_MAYBE_UNUSED,gf2x_fake_fft_srcptr ptr GF2X_MAYBE_UNUSED,size_t n GF2X_MAYBE_UNUSED,int printf_diagnostics GF2X_MAYBE_UNUSED)584 static inline int gf2x_fake_fft_check(
585         gf2x_fake_fft_info_srcptr o GF2X_MAYBE_UNUSED,
586         gf2x_fake_fft_srcptr ptr GF2X_MAYBE_UNUSED,
587         size_t n GF2X_MAYBE_UNUSED,
588         int printf_diagnostics GF2X_MAYBE_UNUSED) { return 1; }
589 
590 #ifdef __cplusplus
591 }
592 #endif
593 
594 #endif	/* GF2X_FAKE_FFT_H_ */
595 /* vim: set sw=4 sta et: */
596