isl_union_templ.c: extract out shared isl_union_*_negate_type
[isl.git] / isl_union_neg.c
blob4a3e7bb23ff0810783b66c5711424f50eccfcefd
1 /*
2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
8 * 91893 Orsay, France
9 */
11 #include <isl_union_macro.h>
13 /* Replace *entry by its opposite.
15 * Return isl_stat_ok on success and isl_stat_error on error.
17 static isl_stat FN(UNION,neg_entry)(void **entry, void *user)
19 PW **pw = (PW **) entry;
21 *pw = FN(PW,neg)(*pw);
23 return *pw ? isl_stat_ok : isl_stat_error;
26 /* Return the opposite of "u".
28 __isl_give UNION *FN(UNION,neg)(__isl_take UNION *u)
30 u = FN(UNION,cow)(u);
31 if (!u)
32 return NULL;
34 if (isl_hash_table_foreach(u->space->ctx, &u->table,
35 &FN(UNION,neg_entry), NULL) < 0)
36 return FN(UNION,free)(u);
38 return u;