From 26dd7423fac86f011fc7a5e42d967e48cdddc4c8 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 2 Jul 2015 12:32:37 +0200 Subject: [PATCH] extract out isl_union_neg.c This makes the function isl_union_*_neg opt-in rather than opt-out. Signed-off-by: Sven Verdoolaege --- Makefile.am | 1 + isl_aff.c | 2 ++ isl_polynomial.c | 1 + isl_union_neg.c | 39 +++++++++++++++++++++++++++++++++++++++ isl_union_templ.c | 30 ------------------------------ 5 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 isl_union_neg.c diff --git a/Makefile.am b/Makefile.am index 7753aea0..fa982718 100644 --- a/Makefile.am +++ b/Makefile.am @@ -326,6 +326,7 @@ EXTRA_DIST = \ isl_union_macro.h \ isl_union_templ.c \ isl_union_eval.c \ + isl_union_neg.c \ isl.py \ doc/CodingStyle \ doc/SubmittingPatches \ diff --git a/isl_aff.c b/isl_aff.c index e252a213..47742cb5 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -2579,6 +2579,7 @@ __isl_give isl_pw_aff *isl_pw_aff_from_aff(__isl_take isl_aff *aff) #define PARTS pw_aff #include +#include static __isl_give isl_set *align_params_pw_pw_set_and( __isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2, @@ -4073,6 +4074,7 @@ __isl_give isl_set *isl_multi_aff_lex_ge_set(__isl_take isl_multi_aff *ma1, #define PARTS pw_multi_aff #include +#include /* Given a function "cmp" that returns the set of elements where * "ma1" is "better" than "ma2", return the intersection of this diff --git a/isl_polynomial.c b/isl_polynomial.c index eb848de9..8c9522ba 100644 --- a/isl_polynomial.c +++ b/isl_polynomial.c @@ -2819,6 +2819,7 @@ __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_qpolynomial( #include #include +#include int isl_pw_qpolynomial_is_one(__isl_keep isl_pw_qpolynomial *pwqp) { diff --git a/isl_union_neg.c b/isl_union_neg.c new file mode 100644 index 00000000..4a3e7bb2 --- /dev/null +++ b/isl_union_neg.c @@ -0,0 +1,39 @@ +/* + * Copyright 2010 INRIA Saclay + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, + * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, + * 91893 Orsay, France + */ + +#include + +/* Replace *entry by its opposite. + * + * Return isl_stat_ok on success and isl_stat_error on error. + */ +static isl_stat FN(UNION,neg_entry)(void **entry, void *user) +{ + PW **pw = (PW **) entry; + + *pw = FN(PW,neg)(*pw); + + return *pw ? isl_stat_ok : isl_stat_error; +} + +/* Return the opposite of "u". + */ +__isl_give UNION *FN(UNION,neg)(__isl_take UNION *u) +{ + u = FN(UNION,cow)(u); + if (!u) + return NULL; + + if (isl_hash_table_foreach(u->space->ctx, &u->table, + &FN(UNION,neg_entry), NULL) < 0) + return FN(UNION,free)(u); + + return u; +} diff --git a/isl_union_templ.c b/isl_union_templ.c index 9b1d5179..71977f1a 100644 --- a/isl_union_templ.c +++ b/isl_union_templ.c @@ -1152,36 +1152,6 @@ error: return isl_bool_error; } -#ifndef NO_NEG -/* Replace *entry by its opposite. - * - * Return 0 on success and -1 on error. - */ -static isl_stat FN(UNION,neg_entry)(void **entry, void *user) -{ - PW **pw = (PW **) entry; - - *pw = FN(PW,neg)(*pw); - - return *pw ? isl_stat_ok : isl_stat_error; -} - -/* Return the opposite of "u". - */ -__isl_give UNION *FN(UNION,neg)(__isl_take UNION *u) -{ - u = FN(UNION,cow)(u); - if (!u) - return NULL; - - if (isl_hash_table_foreach(u->space->ctx, &u->table, - &FN(UNION,neg_entry), NULL) < 0) - return FN(UNION,free)(u); - - return u; -} -#endif - /* Internal data structure for isl_union_*_drop_dims. * type, first and n are passed to isl_*_drop_dims. * res collects the results. -- 2.11.4.GIT