/src/fftw3/kernel/problem.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2003, 2007-14 Matteo Frigo |
3 | | * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology |
4 | | * |
5 | | * This program is free software; you can redistribute it and/or modify |
6 | | * it under the terms of the GNU General Public License as published by |
7 | | * the Free Software Foundation; either version 2 of the License, or |
8 | | * (at your option) any later version. |
9 | | * |
10 | | * This program is distributed in the hope that it will be useful, |
11 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | | * GNU General Public License for more details. |
14 | | * |
15 | | * You should have received a copy of the GNU General Public License |
16 | | * along with this program; if not, write to the Free Software |
17 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
18 | | * |
19 | | */ |
20 | | |
21 | | |
22 | | #include "kernel/ifftw.h" |
23 | | |
24 | | /* constructor */ |
25 | | problem *X(mkproblem)(size_t sz, const problem_adt *adt) |
26 | 3.49k | { |
27 | 3.49k | problem *p = (problem *)MALLOC(sz, PROBLEMS); |
28 | | |
29 | 3.49k | p->adt = adt; |
30 | 3.49k | return p; |
31 | 3.49k | } |
32 | | |
33 | | /* destructor */ |
34 | | void X(problem_destroy)(problem *ego) |
35 | 3.49k | { |
36 | 3.49k | if (ego) |
37 | 3.49k | ego->adt->destroy(ego); |
38 | 3.49k | } |
39 | | |
40 | | /* management of unsolvable problems */ |
41 | | static void unsolvable_destroy(problem *ego) |
42 | 0 | { |
43 | 0 | UNUSED(ego); |
44 | 0 | } |
45 | | |
46 | | static void unsolvable_hash(const problem *p, md5 *m) |
47 | 0 | { |
48 | 0 | UNUSED(p); |
49 | 0 | X(md5puts)(m, "unsolvable"); |
50 | 0 | } |
51 | | |
52 | | static void unsolvable_print(const problem *ego, printer *p) |
53 | 0 | { |
54 | 0 | UNUSED(ego); |
55 | 0 | p->print(p, "(unsolvable)"); |
56 | 0 | } |
57 | | |
58 | | static void unsolvable_zero(const problem *ego) |
59 | 0 | { |
60 | 0 | UNUSED(ego); |
61 | 0 | } |
62 | | |
63 | | static const problem_adt padt = |
64 | | { |
65 | | PROBLEM_UNSOLVABLE, |
66 | | unsolvable_hash, |
67 | | unsolvable_zero, |
68 | | unsolvable_print, |
69 | | unsolvable_destroy |
70 | | }; |
71 | | |
72 | | /* there is no point in malloc'ing this one */ |
73 | | static problem the_unsolvable_problem = { &padt }; |
74 | | |
75 | | problem *X(mkproblem_unsolvable)(void) |
76 | 0 | { |
77 | 0 | return &the_unsolvable_problem; |
78 | 0 | } |