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 */
X(mkproblem)25 problem *X(mkproblem)(size_t sz, const problem_adt *adt)
26 {
27      problem *p = (problem *)MALLOC(sz, PROBLEMS);
28 
29      p->adt = adt;
30      return p;
31 }
32 
33 /* destructor */
X(problem_destroy)34 void X(problem_destroy)(problem *ego)
35 {
36      if (ego)
37 	  ego->adt->destroy(ego);
38 }
39 
40 /* management of unsolvable problems */
unsolvable_destroy(problem * ego)41 static void unsolvable_destroy(problem *ego)
42 {
43      UNUSED(ego);
44 }
45 
unsolvable_hash(const problem * p,md5 * m)46 static void unsolvable_hash(const problem *p, md5 *m)
47 {
48      UNUSED(p);
49      X(md5puts)(m, "unsolvable");
50 }
51 
unsolvable_print(const problem * ego,printer * p)52 static void unsolvable_print(const problem *ego, printer *p)
53 {
54      UNUSED(ego);
55      p->print(p, "(unsolvable)");
56 }
57 
unsolvable_zero(const problem * ego)58 static void unsolvable_zero(const problem *ego)
59 {
60      UNUSED(ego);
61 }
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 
X(mkproblem_unsolvable)75 problem *X(mkproblem_unsolvable)(void)
76 {
77      return &the_unsolvable_problem;
78 }
79