1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
  
     | 
    
      /*
 * Copyright 2017      Sven Verdoolaege
 *
 * Use of this software is governed by the MIT license
 *
 * Written by Sven Verdoolaege.
 */
#include <stdlib.h>
#include <isl/arg.h>
#include <isl/options.h>
#include <isl/schedule.h>
struct options {
	struct isl_options *isl;
	char *schedule1;
	char *schedule2;
};
ISL_ARGS_START(struct options, options_args)
ISL_ARG_CHILD(struct options, isl, "isl", &isl_options_args, "isl options")
ISL_ARG_ARG(struct options, schedule1, "schedule1", NULL)
ISL_ARG_ARG(struct options, schedule2, "schedule2", NULL)
ISL_ARGS_END
ISL_ARG_DEF(options, struct options, options_args)
static void die(const char *msg)
{
	fprintf(stderr, "%s\n", msg);
	exit(EXIT_FAILURE);
}
static FILE *open_or_die(const char *filename)
{
	FILE *file;
	file = fopen(filename, "r");
	if (!file) {
		fprintf(stderr, "Unable to open %s\n", filename);
		exit(EXIT_FAILURE);
	}
	return file;
}
/* Given two YAML descriptions of isl_schedule objects, check whether
 * they are equivalent.
 * Return EXIT_SUCCESS if they are and EXIT_FAILURE if they are not
 * or if anything else went wrong.
 */
int main(int argc, char **argv)
{
	isl_ctx *ctx;
	struct options *options;
	FILE *input1, *input2;
	isl_bool equal;
	isl_schedule *s1, *s2;
	options = options_new_with_defaults();
	if (!options)
		return EXIT_FAILURE;
	ctx = isl_ctx_alloc_with_options(&options_args, options);
	argc = options_parse(options, argc, argv, ISL_ARG_ALL);
	input1 = open_or_die(options->schedule1);
	input2 = open_or_die(options->schedule2);
	s1 = isl_schedule_read_from_file(ctx, input1);
	s2 = isl_schedule_read_from_file(ctx, input2);
	equal = isl_schedule_plain_is_equal(s1, s2);
	if (equal < 0)
		return EXIT_FAILURE;
	if (!equal)
		die("schedules differ");
	isl_schedule_free(s1);
	isl_schedule_free(s2);
	fclose(input1);
	fclose(input2);
	isl_ctx_free(ctx);
	return EXIT_SUCCESS;
}
 
     |