add isl_map_order_gt
[platform/upstream/isl.git] / isl_ctx.c
index 14910b8..1dff37b 100644 (file)
--- a/isl_ctx.c
+++ b/isl_ctx.c
@@ -9,6 +9,25 @@
 
 #include <isl_ctx_private.h>
 #include <isl/vec.h>
+#include <isl/options.h>
+
+void isl_handle_error(isl_ctx *ctx, int error, const char *msg,
+       const char *file, int line)
+{
+       isl_ctx_set_error(ctx, error);
+
+       switch (isl_options_get_on_error(ctx)) {
+       case ISL_ON_ERROR_WARN:
+               fprintf(stderr, "%s:%d: %s\n", file, line, msg);
+               return;
+       case ISL_ON_ERROR_CONTINUE:
+               return;
+       case ISL_ON_ERROR_ABORT:
+               fprintf(stderr, "%s:%d: %s\n", file, line, msg);
+               abort();
+               return;
+       }
+}
 
 static struct isl_options *find_nested_options(struct isl_args *args,
        void *opt, struct isl_args *wanted)
@@ -42,6 +61,8 @@ void *isl_ctx_peek_options(isl_ctx *ctx, struct isl_args *args)
 {
        if (!ctx)
                return NULL;
+       if (args == &isl_options_args)
+               return ctx->opt;
        return find_nested_options(ctx->user_args, ctx->user_opt, args);
 }
 
@@ -131,7 +152,11 @@ void isl_ctx_free(struct isl_ctx *ctx)
 {
        if (!ctx)
                return;
-       isl_assert(ctx, ctx->ref == 0, return);
+       if (ctx->ref != 0)
+               isl_die(ctx, isl_error_invalid,
+                       "isl_ctx freed, but some objects still reference it",
+                       return);
+
        isl_hash_table_clear(&ctx->id_table);
        isl_blk_clear_cache(ctx);
        isl_int_clear(ctx->zero);