1 /* SWI-Prolog extended foreign language interface: definitions.
2    Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3    Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #include "swi_efli.hh"
25 
26 namespace Parma_Polyhedra_Library {
27 
28 namespace Interfaces {
29 
30 namespace Prolog {
31 
32 namespace SWI {
33 
34 bool Prolog_has_unbounded_integers;
35 
36 long Prolog_min_integer;
37 
38 long Prolog_max_integer;
39 
40 void
ppl_Prolog_sysdep_init()41 ppl_Prolog_sysdep_init() {
42   Prolog_has_unbounded_integers = true;
43   Prolog_min_integer = 0;
44   Prolog_max_integer = 0;
45 }
46 
47 void
ppl_Prolog_sysdep_deinit()48 ppl_Prolog_sysdep_deinit() {
49 }
50 
51 int
Prolog_get_Coefficient(Prolog_term_ref t,Coefficient & n)52 Prolog_get_Coefficient(Prolog_term_ref t, Coefficient& n) {
53   assert(Prolog_is_integer(t));
54   // FIXME: avoid the temporary when Coefficient is mpz_class.
55   PPL_DIRTY_TEMP(mpz_class, tmp);
56   int r;
57 #if PLVERSION >= 50800
58   r = PL_get_mpz(t, tmp.get_mpz_t());
59 #else
60   PL_get_mpz(t, tmp.get_mpz_t());
61   r = 1;
62 #endif
63   n = tmp;
64   return r;
65 }
66 
67 int
Prolog_unify_Coefficient(Prolog_term_ref t,const Coefficient & n)68 Prolog_unify_Coefficient(Prolog_term_ref t, const Coefficient& n) {
69   PPL_DIRTY_TEMP(mpz_class, tmp);
70   assign_r(tmp, n, ROUND_NOT_NEEDED);
71   return PL_unify_mpz(t, tmp.get_mpz_t());
72 }
73 
74 int
Prolog_put_Coefficient(Prolog_term_ref t,const Coefficient & n)75 Prolog_put_Coefficient(Prolog_term_ref t, const Coefficient& n) {
76   PL_put_variable(t);
77   return Prolog_unify_Coefficient(t, n);
78 }
79 
80 } // namespace SWI
81 
82 } // namespace Prolog
83 
84 } // namespace Interfaces
85 
86 } // namespace Parma_Polyhedra_Library
87