merge isl_pw_*_from_* implementations
[isl.git] / check_reparse_templ.c
blob333c44cbc52ffcc370d837fe8ca85b6cefa0ad0e
1 #define xCAT(A,B) A ## B
2 #define CAT(A,B) xCAT(A,B)
3 #undef TYPE
4 #define TYPE CAT(isl_,BASE)
5 #define xFN(TYPE,NAME) TYPE ## _ ## NAME
6 #define FN(TYPE,NAME) xFN(TYPE,NAME)
8 /* Check that printing "obj" and parsing the output results
9 * in the same expression.
11 static isl_stat FN(check_reparse,BASE)(isl_ctx *ctx,
12 __isl_take TYPE *obj)
14 char *str;
15 isl_bool equal;
16 TYPE *obj2;
18 str = FN(TYPE,to_str)(obj);
19 obj2 = FN(TYPE,read_from_str)(ctx, str);
20 free(str);
21 equal = FN(TYPE,plain_is_equal)(obj, obj2);
22 FN(TYPE,free)(obj);
23 FN(TYPE,free)(obj2);
24 if (equal < 0)
25 return isl_stat_error;
26 if (!equal)
27 isl_die(ctx, isl_error_unknown,
28 "parsed function not equal to original",
29 return isl_stat_error);
31 return isl_stat_ok;