File indexing completed on 2026-05-10 08:48:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef ISL_CTX_H
0011 #define ISL_CTX_H
0012
0013 #include <stdio.h>
0014 #include <stdlib.h>
0015
0016 #include <isl/arg.h>
0017
0018 #ifndef __isl_give
0019 #define __isl_give
0020 #endif
0021 #ifndef __isl_take
0022 #define __isl_take
0023 #endif
0024 #ifndef __isl_keep
0025 #define __isl_keep
0026 #endif
0027 #ifndef __isl_null
0028 #define __isl_null
0029 #endif
0030 #ifndef __isl_export
0031 #define __isl_export
0032 #endif
0033 #ifndef __isl_overload
0034 #define __isl_overload
0035 #endif
0036 #ifndef __isl_constructor
0037 #define __isl_constructor
0038 #endif
0039 #ifndef __isl_subclass
0040 #define __isl_subclass(super)
0041 #endif
0042
0043 #if defined(__cplusplus)
0044 extern "C" {
0045 #endif
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071 struct isl_stats {
0072 long gbr_solved_lps;
0073 };
0074 enum isl_error {
0075 isl_error_none = 0,
0076 isl_error_abort,
0077 isl_error_alloc,
0078 isl_error_unknown,
0079 isl_error_internal,
0080 isl_error_invalid,
0081 isl_error_quota,
0082 isl_error_unsupported
0083 };
0084 typedef enum {
0085 isl_stat_error = -1,
0086 isl_stat_ok = 0
0087 } isl_stat;
0088 isl_stat isl_stat_non_null(void *obj);
0089 typedef enum {
0090 isl_bool_error = -1,
0091 isl_bool_false = 0,
0092 isl_bool_true = 1
0093 } isl_bool;
0094 isl_bool isl_bool_not(isl_bool b);
0095 isl_bool isl_bool_ok(int b);
0096 typedef int isl_size;
0097 #define isl_size_error ((int) -1)
0098 struct isl_ctx;
0099 typedef struct isl_ctx isl_ctx;
0100
0101
0102
0103 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
0104 #define ISL_DEPRECATED __attribute__((__deprecated__))
0105 #else
0106 #define ISL_DEPRECATED
0107 #endif
0108
0109 #define ISL_FL_INIT(l, f) (l) = (f)
0110 #define ISL_FL_SET(l, f) ((l) |= (f))
0111 #define ISL_FL_CLR(l, f) ((l) &= ~(f))
0112 #define ISL_FL_ISSET(l, f) (!!((l) & (f)))
0113
0114 #define ISL_F_INIT(p, f) ISL_FL_INIT((p)->flags, f)
0115 #define ISL_F_SET(p, f) ISL_FL_SET((p)->flags, f)
0116 #define ISL_F_CLR(p, f) ISL_FL_CLR((p)->flags, f)
0117 #define ISL_F_ISSET(p, f) ISL_FL_ISSET((p)->flags, f)
0118
0119 void *isl_malloc_or_die(isl_ctx *ctx, size_t size);
0120 void *isl_calloc_or_die(isl_ctx *ctx, size_t nmemb, size_t size);
0121 void *isl_realloc_or_die(isl_ctx *ctx, void *ptr, size_t size);
0122
0123 #define isl_alloc(ctx,type,size) ((type *)isl_malloc_or_die(ctx, size))
0124 #define isl_calloc(ctx,type,size) ((type *)isl_calloc_or_die(ctx,\
0125 1, size))
0126 #define isl_realloc(ctx,ptr,type,size) ((type *)isl_realloc_or_die(ctx,\
0127 ptr, size))
0128 #define isl_alloc_type(ctx,type) isl_alloc(ctx,type,sizeof(type))
0129 #define isl_calloc_type(ctx,type) isl_calloc(ctx,type,sizeof(type))
0130 #define isl_realloc_type(ctx,ptr,type) isl_realloc(ctx,ptr,type,sizeof(type))
0131 #define isl_alloc_array(ctx,type,n) isl_alloc(ctx,type,(n)*sizeof(type))
0132 #define isl_calloc_array(ctx,type,n) ((type *)isl_calloc_or_die(ctx,\
0133 n, sizeof(type)))
0134 #define isl_realloc_array(ctx,ptr,type,n) \
0135 isl_realloc(ctx,ptr,type,(n)*sizeof(type))
0136
0137 #define isl_die(ctx,errno,msg,code) \
0138 do { \
0139 isl_handle_error(ctx, errno, msg, __FILE__, __LINE__); \
0140 code; \
0141 } while (0)
0142
0143 void isl_handle_error(isl_ctx *ctx, enum isl_error error, const char *msg,
0144 const char *file, int line);
0145
0146 #define isl_assert4(ctx,test,code,errno) \
0147 do { \
0148 if (test) \
0149 break; \
0150 isl_die(ctx, errno, "Assertion \"" #test "\" failed", code); \
0151 } while (0)
0152 #define isl_assert(ctx,test,code) \
0153 isl_assert4(ctx,test,code,isl_error_unknown)
0154
0155 #define isl_min(a,b) ((a < b) ? (a) : (b))
0156
0157
0158
0159 struct isl_options *isl_ctx_options(isl_ctx *ctx);
0160
0161 isl_ctx *isl_ctx_alloc_with_options(struct isl_args *args,
0162 __isl_take void *opt);
0163 isl_ctx *isl_ctx_alloc(void);
0164 void *isl_ctx_peek_options(isl_ctx *ctx, struct isl_args *args);
0165 int isl_ctx_parse_options(isl_ctx *ctx, int argc, char **argv, unsigned flags);
0166 void isl_ctx_ref(struct isl_ctx *ctx);
0167 void isl_ctx_deref(struct isl_ctx *ctx);
0168 void isl_ctx_free(isl_ctx *ctx);
0169
0170 void isl_ctx_abort(isl_ctx *ctx);
0171 void isl_ctx_resume(isl_ctx *ctx);
0172 int isl_ctx_aborted(isl_ctx *ctx);
0173
0174 void isl_ctx_set_max_operations(isl_ctx *ctx, unsigned long max_operations);
0175 unsigned long isl_ctx_get_max_operations(isl_ctx *ctx);
0176 void isl_ctx_reset_operations(isl_ctx *ctx);
0177
0178 #define ISL_ARG_CTX_DECL(prefix,st,args) \
0179 st *isl_ctx_peek_ ## prefix(isl_ctx *ctx);
0180
0181 #define ISL_ARG_CTX_DEF(prefix,st,args) \
0182 st *isl_ctx_peek_ ## prefix(isl_ctx *ctx) \
0183 { \
0184 return (st *)isl_ctx_peek_options(ctx, &(args)); \
0185 }
0186
0187 #define ISL_CTX_GET_INT_DEF(prefix,st,args,field) \
0188 int prefix ## _get_ ## field(isl_ctx *ctx) \
0189 { \
0190 st *options; \
0191 options = isl_ctx_peek_ ## prefix(ctx); \
0192 if (!options) \
0193 isl_die(ctx, isl_error_invalid, \
0194 "isl_ctx does not reference " #prefix, \
0195 return -1); \
0196 return options->field; \
0197 }
0198
0199 #define ISL_CTX_SET_INT_DEF(prefix,st,args,field) \
0200 isl_stat prefix ## _set_ ## field(isl_ctx *ctx, int val) \
0201 { \
0202 st *options; \
0203 options = isl_ctx_peek_ ## prefix(ctx); \
0204 if (!options) \
0205 isl_die(ctx, isl_error_invalid, \
0206 "isl_ctx does not reference " #prefix, \
0207 return isl_stat_error); \
0208 options->field = val; \
0209 return isl_stat_ok; \
0210 }
0211
0212 #define ISL_CTX_GET_STR_DEF(prefix,st,args,field) \
0213 const char *prefix ## _get_ ## field(isl_ctx *ctx) \
0214 { \
0215 st *options; \
0216 options = isl_ctx_peek_ ## prefix(ctx); \
0217 if (!options) \
0218 isl_die(ctx, isl_error_invalid, \
0219 "isl_ctx does not reference " #prefix, \
0220 return NULL); \
0221 return options->field; \
0222 }
0223
0224 #define ISL_CTX_SET_STR_DEF(prefix,st,args,field) \
0225 isl_stat prefix ## _set_ ## field(isl_ctx *ctx, const char *val) \
0226 { \
0227 st *options; \
0228 options = isl_ctx_peek_ ## prefix(ctx); \
0229 if (!options) \
0230 isl_die(ctx, isl_error_invalid, \
0231 "isl_ctx does not reference " #prefix, \
0232 return isl_stat_error); \
0233 if (!val) \
0234 return isl_stat_error; \
0235 free(options->field); \
0236 options->field = strdup(val); \
0237 if (!options->field) \
0238 return isl_stat_error; \
0239 return isl_stat_ok; \
0240 }
0241
0242 #define ISL_CTX_GET_BOOL_DEF(prefix,st,args,field) \
0243 ISL_CTX_GET_INT_DEF(prefix,st,args,field)
0244
0245 #define ISL_CTX_SET_BOOL_DEF(prefix,st,args,field) \
0246 ISL_CTX_SET_INT_DEF(prefix,st,args,field)
0247
0248 #define ISL_CTX_GET_CHOICE_DEF(prefix,st,args,field) \
0249 ISL_CTX_GET_INT_DEF(prefix,st,args,field)
0250
0251 #define ISL_CTX_SET_CHOICE_DEF(prefix,st,args,field) \
0252 ISL_CTX_SET_INT_DEF(prefix,st,args,field)
0253
0254 enum isl_error isl_ctx_last_error(isl_ctx *ctx);
0255 const char *isl_ctx_last_error_msg(isl_ctx *ctx);
0256 const char *isl_ctx_last_error_file(isl_ctx *ctx);
0257 int isl_ctx_last_error_line(isl_ctx *ctx);
0258 void isl_ctx_reset_error(isl_ctx *ctx);
0259 void isl_ctx_set_error(isl_ctx *ctx, enum isl_error error);
0260
0261 #if defined(__cplusplus)
0262 }
0263 #endif
0264
0265 #endif