X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_id.c;h=ef03330e45ef6efa00f3b68ab2d1dcb86809b981;hb=e4da68b7e2c4e44ba2c9592c365779e7cea08b56;hp=81ed8a0379b7f07a38408d73952f9ad96255653c;hpb=9e4b65d0a1f40138fb0c98ae3e597e6fa1330075;p=platform%2Fupstream%2Fisl.git diff --git a/isl_id.c b/isl_id.c index 81ed8a0..ef03330 100644 --- a/isl_id.c +++ b/isl_id.c @@ -11,6 +11,17 @@ #include #include +/* A special, static isl_id to use as domains (and ranges) + * of sets and parameters domains. + * The user should never get a hold on this isl_id. + */ +isl_id isl_id_none = { + .ref = -1, + .ctx = NULL, + .name = "#none", + .user = NULL +}; + isl_ctx *isl_id_get_ctx(__isl_keep isl_id *id) { return id ? id->ctx : NULL; @@ -85,11 +96,17 @@ __isl_give isl_id *isl_id_alloc(isl_ctx *ctx, const char *name, void *user) return entry->data; } +/* If the id has a negative refcount, then it is a static isl_id + * which should not be changed. + */ __isl_give isl_id *isl_id_copy(isl_id *id) { if (!id) return NULL; + if (id->ref < 0) + return id; + id->ref++; return id; } @@ -107,6 +124,9 @@ uint32_t isl_hash_id(uint32_t hash, __isl_keep isl_id *id) return hash; } +/* If the id has a negative refcount, then it is a static isl_id + * and should not be freed. + */ void *isl_id_free(__isl_take isl_id *id) { struct isl_hash_table_entry *entry; @@ -114,6 +134,9 @@ void *isl_id_free(__isl_take isl_id *id) if (!id) return NULL; + if (id->ref < 0) + return NULL; + if (--id->ref > 0) return NULL; @@ -150,17 +173,3 @@ error: isl_printer_free(p); return NULL; } - -void isl_id_dump(__isl_keep isl_id *id) -{ - isl_printer *printer; - - if (!id) - return; - - printer = isl_printer_to_file(isl_id_get_ctx(id), stderr); - printer = isl_printer_print_id(printer, id); - printer = isl_printer_end_line(printer); - - isl_printer_free(printer); -}