isl_ilp.c \
isl_input.c \
isl_list.c \
+ isl_list_private.h \
isl_local_space_private.h \
isl_local_space.c \
isl_lp.c \
EXTRA_DIST = \
basis_reduction_templ.c \
+ isl_list_templ.c \
+ isl_list_templ.h \
isl_pw_templ.c \
isl_union_templ.c \
isl.py \
__isl_give isl_union_map *isl_union_map_lexmax(
__isl_take isl_union_map *umap);
+=head2 Lists
+
+Lists are defined over several element types, including
+C<isl_basic_set> and C<isl_set>.
+Here we take lists of C<isl_set>s as an example.
+
+ #include <isl/list.h>
+ __isl_give isl_set_list *isl_set_list_alloc(
+ isl_ctx *ctx, int n);
+ __isl_give isl_set_list *isl_set_list_add(
+ __isl_take isl_set_list *list,
+ __isl_take isl_set *el);
+ void isl_set_list_free(__isl_take isl_set_list *list);
+
+C<isl_set_list_alloc> creates an empty list with a capacity for
+C<n> elements.
+
=head2 Matrices
Matrices can be created, copied and freed using the following functions.
extern "C" {
#endif
-struct isl_basic_set;
-
-struct isl_basic_set_list {
- int ref;
- struct isl_ctx *ctx;
-
- int n;
-
- size_t size;
- struct isl_basic_set *p[1];
-};
-
-struct isl_basic_set_list *isl_basic_set_list_alloc(struct isl_ctx *ctx, int n);
-void isl_basic_set_list_free(struct isl_basic_set_list *list);
-struct isl_basic_set_list *isl_basic_set_list_add(
- struct isl_basic_set_list *list,
- struct isl_basic_set *bset);
+#define ISL_DECLARE_LIST(EL) \
+struct isl_##EL; \
+struct isl_##EL##_list; \
+typedef struct isl_##EL##_list isl_##EL##_list; \
+__isl_give isl_##EL##_list *isl_##EL##_list_alloc(isl_ctx *ctx, int n); \
+void isl_##EL##_list_free(__isl_take isl_##EL##_list *list); \
+__isl_give isl_##EL##_list *isl_##EL##_list_add( \
+ __isl_take isl_##EL##_list *list, \
+ __isl_take struct isl_##EL *el);
+
+ISL_DECLARE_LIST(basic_set)
+ISL_DECLARE_LIST(set)
#if defined(__cplusplus)
}
* Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
*/
-#include <isl/list.h>
+#include <isl_list_private.h>
#include <isl/set.h>
-struct isl_basic_set_list *isl_basic_set_list_alloc(struct isl_ctx *ctx, int n)
-{
- struct isl_basic_set_list *list;
+#undef BASE
+#define BASE basic_set
- isl_assert(ctx, n >= 0, return NULL);
- list = isl_alloc(ctx, struct isl_basic_set_list,
- sizeof(struct isl_basic_set_list) +
- (n - 1) * sizeof(struct isl_basic_set *));
- if (!list)
- return NULL;
+#include <isl_list_templ.c>
- list->ctx = ctx;
- isl_ctx_ref(ctx);
- list->ref = 1;
- list->size = n;
- list->n = 0;
- return list;
-}
+#undef BASE
+#define BASE set
-struct isl_basic_set_list *isl_basic_set_list_add(
- struct isl_basic_set_list *list,
- struct isl_basic_set *bset)
-{
- if (!list || !bset)
- goto error;
- isl_assert(list->ctx, list->n < list->size, goto error);
- list->p[list->n] = bset;
- list->n++;
- return list;
-error:
- isl_basic_set_free(bset);
- isl_basic_set_list_free(list);
- return NULL;
-}
-
-void isl_basic_set_list_free(struct isl_basic_set_list *list)
-{
- int i;
-
- if (!list)
- return;
-
- if (--list->ref > 0)
- return;
-
- isl_ctx_deref(list->ctx);
- for (i = 0; i < list->n; ++i)
- isl_basic_set_free(list->p[i]);
- free(list);
-}
+#include <isl_list_templ.c>
--- /dev/null
+#ifndef ISL_LIST_PRIVATE_H
+#define ISL_LIST_PRIVATE_H
+
+#include <isl/list.h>
+
+#undef EL
+#define EL isl_basic_set
+
+#include <isl_list_templ.h>
+
+#undef EL
+#define EL isl_set
+
+#include <isl_list_templ.h>
+
+#endif
--- /dev/null
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ * Copyright 2011 INRIA Saclay
+ *
+ * Use of this software is governed by the GNU LGPLv2.1 license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ * and INRIA Saclay - Ile-de-France, Parc Club Orsay Universite,
+ * ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France
+ */
+
+#define xCAT(A,B) A ## B
+#define CAT(A,B) xCAT(A,B)
+#undef EL
+#define EL CAT(isl_,BASE)
+#define xFN(TYPE,NAME) TYPE ## _ ## NAME
+#define FN(TYPE,NAME) xFN(TYPE,NAME)
+#define xLIST(EL) EL ## _list
+#define LIST(EL) xLIST(EL)
+
+__isl_give LIST(EL) *FN(LIST(EL),alloc)(isl_ctx *ctx, int n)
+{
+ LIST(EL) *list;
+
+ if (n < 0)
+ isl_die(ctx, isl_error_invalid,
+ "cannot create list of negative length",
+ return NULL);
+ list = isl_alloc(ctx, LIST(EL),
+ sizeof(LIST(EL)) + (n - 1) * sizeof(struct EL *));
+ if (!list)
+ return NULL;
+
+ list->ctx = ctx;
+ isl_ctx_ref(ctx);
+ list->ref = 1;
+ list->size = n;
+ list->n = 0;
+ return list;
+}
+
+__isl_give LIST(EL) *FN(LIST(EL),add)(__isl_take LIST(EL) *list,
+ __isl_take struct EL *el)
+{
+ if (!list || !el)
+ goto error;
+ isl_assert(list->ctx, list->n < list->size, goto error);
+ list->p[list->n] = el;
+ list->n++;
+ return list;
+error:
+ FN(EL,free)(el);
+ FN(LIST(EL),free)(list);
+ return NULL;
+}
+
+void FN(LIST(EL),free)(__isl_take LIST(EL) *list)
+{
+ int i;
+
+ if (!list)
+ return;
+
+ if (--list->ref > 0)
+ return;
+
+ isl_ctx_deref(list->ctx);
+ for (i = 0; i < list->n; ++i)
+ FN(EL,free)(list->p[i]);
+ free(list);
+}
--- /dev/null
+#define xFN(TYPE,NAME) TYPE ## _ ## NAME
+#define FN(TYPE,NAME) xFN(TYPE,NAME)
+#define xLIST(EL) EL ## _list
+#define LIST(EL) xLIST(EL)
+
+struct LIST(EL) {
+ int ref;
+ isl_ctx *ctx;
+
+ int n;
+
+ size_t size;
+ struct EL *p[1];
+};
#include <isl/blk.h>
#include "isl_dim_private.h"
#include "isl_equalities.h"
-#include <isl/list.h>
+#include <isl_list_private.h>
#include <isl/lp.h>
#include <isl/seq.h>
#include <isl/set.h>
#define isl_basic_set isl_basic_map
#define isl_set isl_map
+#define isl_basic_set_list isl_basic_map_list
#include <isl/set.h>
#include <isl/map.h>
#include <isl_reordering.h>