Merge branch 'osl_strings_add_strings+osl_generic_nclone' of https://github.com/Haere...
[openscop.git] / source / relation_list.c
blob42be078317c0640a8b13baefd05805bd0f937b12
2 /*+-----------------------------------------------------------------**
3 ** OpenScop Library **
4 **-----------------------------------------------------------------**
5 ** relation_list.c **
6 **-----------------------------------------------------------------**
7 ** First version: 08/10/2010 **
8 **-----------------------------------------------------------------**
11 *****************************************************************************
12 * OpenScop: Structures and formats for polyhedral tools to talk together *
13 *****************************************************************************
14 * ,___,,_,__,,__,,__,,__,,_,__,,_,__,,__,,___,_,__,,_,__, *
15 * / / / // // // // / / / // // / / // / /|,_, *
16 * / / / // // // // / / / // // / / // / / / /\ *
17 * |~~~|~|~~~|~~~|~~~|~~~|~|~~~|~|~~~|~~~|~~~|~|~~~|~|~~~|/_/ \ *
18 * | G |C| P | = | L | P |=| = |C| = | = | = |=| = |=| C |\ \ /\ *
19 * | R |l| o | = | e | l |=| = |a| = | = | = |=| = |=| L | \# \ /\ *
20 * | A |a| l | = | t | u |=| = |n| = | = | = |=| = |=| o | |\# \ \ *
21 * | P |n| l | = | s | t |=| = |d| = | = | = | | |=| o | | \# \ \ *
22 * | H | | y | | e | o | | = |l| | | = | | | | G | | \ \ \ *
23 * | I | | | | e | | | | | | | | | | | | | \ \ \ *
24 * | T | | | | | | | | | | | | | | | | | \ \ \ *
25 * | E | | | | | | | | | | | | | | | | | \ \ \ *
26 * | * |*| * | * | * | * |*| * |*| * | * | * |*| * |*| * | / \* \ \ *
27 * | O |p| e | n | S | c |o| p |-| L | i | b |r| a |r| y |/ \ \ / *
28 * '---'-'---'---'---'---'-'---'-'---'---'---'-'---'-'---' '--' *
29 * *
30 * Copyright (C) 2008 University Paris-Sud 11 and INRIA *
31 * *
32 * (3-clause BSD license) *
33 * Redistribution and use in source and binary forms, with or without *
34 * modification, are permitted provided that the following conditions *
35 * are met: *
36 * *
37 * 1. Redistributions of source code must retain the above copyright notice, *
38 * this list of conditions and the following disclaimer. *
39 * 2. Redistributions in binary form must reproduce the above copyright *
40 * notice, this list of conditions and the following disclaimer in the *
41 * documentation and/or other materials provided with the distribution. *
42 * 3. The name of the author may not be used to endorse or promote products *
43 * derived from this software without specific prior written permission. *
44 * *
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
46 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
47 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
48 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
55 * *
56 * OpenScop Library, a library to manipulate OpenScop formats and data *
57 * structures. Written by: *
58 * Cedric Bastoul <Cedric.Bastoul@u-psud.fr> and *
59 * Louis-Noel Pouchet <Louis-Noel.pouchet@inria.fr> *
60 * *
61 *****************************************************************************/
64 #include <stdlib.h>
65 #include <stdio.h>
66 #include <string.h>
67 #include <ctype.h>
69 #include <osl/macros.h>
70 #include <osl/util.h>
71 #include <osl/relation.h>
72 #include <osl/relation_list.h>
75 /*+***************************************************************************
76 * Structure display function *
77 *****************************************************************************/
80 /**
81 * osl_relation_list_idump function:
82 * Displays a osl_relation_list_t structure (a list of relations) into a
83 * file (file, possibly stdout). See osl_relation_print_structure for
84 * more details.
85 * \param file File where informations are printed.
86 * \param l The list of relations whose information has to be printed.
87 * \param level Number of spaces before printing, for each line.
89 void osl_relation_list_idump(FILE * file, osl_relation_list_p l, int level) {
90 int j, first = 1;
92 // Go to the right level.
93 for (j = 0; j < level; j++)
94 fprintf(file,"|\t");
96 if (l != NULL)
97 fprintf(file, "+-- osl_relation_list_t\n");
98 else
99 fprintf(file, "+-- NULL relation list\n");
101 while (l != NULL) {
102 if (!first) {
103 // Go to the right level.
104 for (j = 0; j < level; j++)
105 fprintf(file, "|\t");
106 fprintf(file, "| osl_relation_list_t\n");
108 else
109 first = 0;
111 // A blank line.
112 for (j = 0; j <= level+1; j++)
113 fprintf(file, "|\t");
114 fprintf(file, "\n");
116 // Print a relation.
117 osl_relation_idump(file, l->elt, level+1);
119 l = l->next;
121 // Next line.
122 if (l != NULL) {
123 for (j = 0; j <= level; j++)
124 fprintf(file, "|\t");
125 fprintf(file, "V\n");
129 // The last line.
130 for (j = 0; j <= level; j++)
131 fprintf(file, "|\t");
132 fprintf(file, "\n");
137 * osl_relation_dump function:
138 * This function prints the content of a osl_relation_list_t into
139 * a file (file, possibly stdout).
140 * \param file File where informations are printed.
141 * \param list The relation whose information has to be printed.
143 void osl_relation_list_dump(FILE * file, osl_relation_list_p list) {
144 osl_relation_list_idump(file, list, 0);
149 * osl_relation_list_pprint_elts function:
150 * This function pretty-prints the elements of a osl_relation_list_t structure
151 * into a file (file, possibly stdout) in the OpenScop format. I.e., it prints
152 * only the elements and not the number of elements. It prints an element of the
153 * list only if it is not NULL.
154 * \param file File where informations are printed.
155 * \param list The relation list whose information has to be printed.
156 * \param[in] names Array of constraint columns names.
158 void osl_relation_list_pprint_elts(FILE * file, osl_relation_list_p list,
159 osl_names_p names) {
160 size_t i;
161 osl_relation_list_p head = list;
163 // Count the number of elements in the list with non-NULL content.
164 i = osl_relation_list_count(list);
166 // Print each element of the relation list.
167 if (i > 0) {
168 i = 0;
169 while (head) {
170 if (head->elt != NULL) {
171 osl_relation_pprint(file, head->elt, names);
172 if (head->next != NULL)
173 fprintf(file, "\n");
174 i++;
176 head = head->next;
179 else {
180 fprintf(file, "# NULL relation list\n");
186 * osl_relation_list_pprint_access_array_scoplib function:
187 * This function pretty-prints the elements of a osl_relation_list_t structure
188 * into a file (file, possibly stdout) in the SCoPLib format. I.e., it prints
189 * only the elements and not the number of elements. It prints an element of the
190 * list only if it is not NULL.
191 * \param file File where informations are printed.
192 * \param list The relation list whose information has to be printed.
193 * \param[in] names Array of constraint columns names.
194 * \param[in] add_fakeiter True of False
196 void osl_relation_list_pprint_access_array_scoplib(FILE * file,
197 osl_relation_list_p list, osl_names_p names, int add_fakeiter) {
198 size_t i;
199 int nb_rows_read = 0, nb_columns_read = 0;
200 int nb_rows_write = 0, nb_columns_write = 0;
201 int nb_rows_may_write = 0, nb_columns_may_write = 0;
202 osl_relation_list_p head ;
204 // Count the number of elements in the list with non-NULL content.
205 i = osl_relation_list_count(list);
207 // Print each element of the relation list.
208 if (i > 0) {
210 // Read/Write arrays size
211 head = list;
212 while (head) {
213 if (head->elt != NULL) {
214 if (head->elt->type == OSL_TYPE_READ) {
215 if (head->elt->nb_rows == 1)
216 nb_rows_read++;
217 else
218 nb_rows_read += head->elt->nb_rows - 1; // remove the 'Arr'
220 nb_columns_read = head->elt->nb_columns - head->elt->nb_output_dims;
222 } else if (head->elt->type == OSL_TYPE_WRITE) {
223 if (head->elt->nb_rows == 1)
224 nb_rows_write++;
225 else
226 nb_rows_write += head->elt->nb_rows - 1; // remove the 'Arr'
228 nb_columns_write = head->elt->nb_columns - head->elt->nb_output_dims;
230 } else if (head->elt->type == OSL_TYPE_MAY_WRITE) {
231 if (head->elt->nb_rows == 1)
232 nb_rows_may_write++;
233 else
234 nb_rows_may_write += head->elt->nb_rows - 1; // remove the 'Arr'
236 nb_columns_may_write = head->elt->nb_columns -
237 head->elt->nb_output_dims;
240 head = head->next;
243 if (add_fakeiter) {
244 nb_columns_read++;
245 nb_columns_write++;
246 nb_columns_may_write++;
249 fprintf(file, "# Read access informations\n%d %d\n",
250 nb_rows_read, nb_columns_read);
251 head = list;
252 while (head) {
253 if (head->elt != NULL && head->elt->type == OSL_TYPE_READ) {
254 osl_relation_pprint_scoplib(file, head->elt, names, 0, add_fakeiter);
256 head = head->next;
259 fprintf(file, "# Write access informations\n%d %d\n",
260 nb_rows_write, nb_columns_write);
261 head = list;
262 while (head) {
263 if (head->elt != NULL && head->elt->type == OSL_TYPE_WRITE) {
264 osl_relation_pprint_scoplib(file, head->elt, names, 0, add_fakeiter);
266 head = head->next;
269 if (nb_rows_may_write > 0) {
270 fprintf(file, "# May Write access informations\n%d %d\n",
271 nb_rows_may_write, nb_columns_may_write);
272 head = list;
273 while (head) {
274 if (head->elt != NULL && head->elt->type == OSL_TYPE_MAY_WRITE) {
275 osl_relation_pprint_scoplib(file, head->elt, names, 0, add_fakeiter);
277 head = head->next;
281 else {
282 fprintf(file, "# NULL relation list\n");
288 * osl_relation_list_pprint function:
289 * This function pretty-prints the content of a osl_relation_list_t structure
290 * into a file (file, possibly stdout) in the OpenScop format. It prints
291 * an element of the list only if it is not NULL.
292 * \param[in] file File where informations are printed.
293 * \param[in] list The relation list whose information has to be printed.
294 * \param[in] names Array of constraint columns names.
296 void osl_relation_list_pprint(FILE * file, osl_relation_list_p list,
297 osl_names_p names) {
298 size_t i;
300 // Count the number of elements in the list with non-NULL content.
301 i = osl_relation_list_count(list);
303 // Print it.
304 if (i > 1)
305 fprintf(file,"# List of %lu elements\n%lu\n", i, i);
306 else
307 fprintf(file,"# List of %lu element \n%lu\n", i, i);
309 // Print each element of the relation list.
310 osl_relation_list_pprint_elts(file, list, names);
315 * osl_relation_list_print function:
316 * This function prints the content of a osl_relation_list_t structure
317 * into a file (file, possibly stdout) in the OpenScop format. It prints
318 * an element of the list only if it is not NULL.
319 * \param file File where informations are printed.
320 * \param list The relation list whose information has to be printed.
322 void osl_relation_list_print(FILE * file, osl_relation_list_p list) {
324 osl_relation_list_pprint(file, list, NULL);
327 /*****************************************************************************
328 * Reading function *
329 *****************************************************************************/
333 * osl_relation_list_pread function ("precision read"):
334 * this function reads a list of relations into a file (foo,
335 * posibly stdin) and returns a pointer this relation list.
336 * \param[in] file The input stream.
337 * \param[in] precision The precision of the relation elements.
338 * \return A pointer to the relation list structure that has been read.
340 osl_relation_list_p osl_relation_list_pread(FILE * file, int precision) {
341 int i;
342 osl_relation_list_p list;
343 osl_relation_list_p res;
344 int nb_mat;
346 // Read the number of relations to read.
347 nb_mat = osl_util_read_int(file, NULL);
349 if (nb_mat < 0)
350 OSL_error("negative number of relations");
352 // Allocate the header of the list and start reading each element.
353 res = list = osl_relation_list_malloc();
354 for (i = 0; i < nb_mat; ++i) {
355 list->elt = osl_relation_pread(file, precision);
356 if (i < nb_mat - 1)
357 list->next = osl_relation_list_malloc();
358 list = list->next;
361 return res;
366 * osl_relation_list_read function:
367 * this function is equivalent to osl_relation_list_pread() except that
368 * the precision corresponds to the precision environment variable or
369 * to the highest available precision if it is not defined.
370 * \see{osl_relation_list_pread}
372 osl_relation_list_p osl_relation_list_read(FILE * foo) {
373 int precision = osl_util_get_precision();
374 return osl_relation_list_pread(foo, precision);
378 /*+***************************************************************************
379 * Memory allocation/deallocation function *
380 *****************************************************************************/
384 * osl_relation_list_malloc function:
385 * This function allocates the memory space for a osl_relation_list_t
386 * structure and sets its fields with default values. Then it returns
387 * a pointer to the allocated space.
388 * \return A pointer to an empty relation list with fields set to default
389 * values.
391 osl_relation_list_p osl_relation_list_malloc() {
392 osl_relation_list_p res;
394 OSL_malloc(res, osl_relation_list_p, sizeof(osl_relation_list_t));
395 res->elt = NULL;
396 res->next = NULL;
398 return res;
404 * osl_relation_list_free function:
405 * This function frees the allocated memory for a osl_relation_list_t
406 * structure, and all the relations stored in the list.
407 * \param list The pointer to the relation list we want to free.
409 void osl_relation_list_free(osl_relation_list_p list) {
410 osl_relation_list_p tmp;
412 if (list == NULL)
413 return;
415 while (list != NULL) {
416 if (list->elt != NULL)
417 osl_relation_free(list->elt);
418 tmp = list->next;
419 free(list);
420 list = tmp;
425 /*+***************************************************************************
426 * Processing functions *
427 *****************************************************************************/
431 * osl_relation_list_node function:
432 * This function builds an osl_relation_list_t node and sets its
433 * relation element as a copy of the one provided as parameter.
434 * If the relation provided as an argument is NULL, NULL is returned.
435 * \param r The pointer to the relation to copy/paste in a list node.
436 * \return A pointer to a relation list node containing a copy of "relation".
438 osl_relation_list_p osl_relation_list_node(osl_relation_p r) {
439 osl_relation_list_p new = NULL;
441 if (r != NULL) {
442 new = osl_relation_list_malloc();
443 new->elt = osl_relation_clone(r);
445 return new;
450 * osl_relation_list_clone function:
451 * This functions builds and returns a quasi-"hard copy" (not a pointer copy)
452 * of a osl_relation_list_t data structure provided as parameter.
453 * \param list The pointer to the relation list we want to copy.
454 * \return A pointer to the full copy of the relation list in parameter.
456 osl_relation_list_p osl_relation_list_clone(osl_relation_list_p list) {
458 osl_relation_list_p clone = NULL, node, previous = NULL;
459 int first = 1;
461 while (list != NULL) {
462 node = osl_relation_list_malloc();
463 node->elt = osl_relation_clone(list->elt);
465 if (first) {
466 first = 0;
467 clone = node;
468 previous = node;
470 else {
471 previous->next = node;
472 previous = previous->next;
475 list = list->next;
478 return clone;
483 * osl_relation_list_concat function:
484 * this function builds a new relation list as the concatenation of the
485 * two lists sent as parameters.
486 * \param l1 The first relation list.
487 * \param l2 The second relation list.
488 * \return A pointer to the relation list resulting from the concatenation of
489 * l1 and l2.
491 osl_relation_list_p osl_relation_list_concat(osl_relation_list_p l1,
492 osl_relation_list_p l2) {
493 osl_relation_list_p new, end;
495 if (l1 == NULL)
496 return osl_relation_list_clone(l2);
498 if (l2 == NULL)
499 return osl_relation_list_clone(l1);
501 new = osl_relation_list_clone(l1);
502 end = new;
503 while (end->next != NULL)
504 end = end->next;
505 end->next = osl_relation_list_clone(l2);
507 return new;
512 * osl_relation_list_add function:
513 * this function adds a relation list at the end of the relation list
514 * pointed by l1. No new list is created: this functions links the two
515 * input lists. If the first relation list is NULL, it is set to the
516 * second relation list.
517 * \param[in,out] l1 Pointer to the first relation list.
518 * \param[in] l2 The second relation list.
520 void osl_relation_list_add(osl_relation_list_p *l1, osl_relation_list_p l2) {
521 while (*l1 != NULL)
522 l1 = &((*l1)->next);
524 *l1 = l2;
529 * osl_relation_list_push function:
530 * this function sees a list of relations as a stack of relations and
531 * performs the push operation onto this stack.
532 * \param[in,out] head Pointer to the head of the relation stack.
533 * \param[in,out] node Relation node to add to the stack. Its next field is
534 * updated to the previous head of the stack.
536 void osl_relation_list_push(osl_relation_list_p *head,
537 osl_relation_list_p node) {
538 if (node != NULL) {
539 node->next = *head;
540 *head = node;
546 * osl_relation_list_pop function:
547 * this function sees a list of relations as a stack of relations and
548 * performs the pop operation onto this stack.
549 * \param[in,out] head Pointer to the head of the relation stack. It is
550 * updated to the previous element in the stack (NULL
551 * if there is none).
552 * \return The top element of the stack (detached from the list).
554 osl_relation_list_p osl_relation_list_pop(osl_relation_list_p *head) {
555 osl_relation_list_p top = NULL;
557 if (*head != NULL) {
558 top = *head;
559 *head = (*head)->next;
560 top->next = NULL;
563 return top;
568 * osl_relation_list_dup function:
569 * this function sees a list of relations as a stack of relations and
570 * performs the dup operation (duplicate the top element) onto
571 * this stack.
572 * \param[in,out] head Pointer to the head of the relation stack. It is
573 * updated to the new element after duplication.
575 void osl_relation_list_dup(osl_relation_list_p *head) {
576 osl_relation_list_p top = osl_relation_list_pop(head);
577 osl_relation_list_push(head, osl_relation_list_clone(top));
578 osl_relation_list_push(head, top);
583 * osl_relation_list_drop function:
584 * this function sees a list of relations as a stack of relations and
585 * performs the drop operation (pop and destroy popped element) onto
586 * this stack.
587 * \param[in,out] head Pointer to the head of the relation stack. It is
588 * updated to the previous element in the stack (NULL
589 * if there is none).
591 void osl_relation_list_drop(osl_relation_list_p *head) {
592 osl_relation_list_p top = osl_relation_list_pop(head);
593 osl_relation_list_free(top);
598 * osl_relation_list_destroy function:
599 * this function sees a list of relations as a stack of relations and
600 * performs the destroy operation onto this stack, i.e., it completely
601 * free it.
602 * \param[in,out] head Pointer to the head of the relation stack.
603 * Updated to NULL.
605 void osl_relation_list_destroy(osl_relation_list_p *head) {
607 while (*head != NULL)
608 osl_relation_list_drop(head);
613 * osl_relation_list_equal function:
614 * This function returns true if the two relation lists are the same, false
615 * otherwise..
616 * \param l1 The first relation list.
617 * \param l2 The second relation list.
618 * \return 1 if l1 and l2 are the same (content-wise), 0 otherwise.
620 int osl_relation_list_equal(osl_relation_list_p l1, osl_relation_list_p l2) {
621 while ((l1 != NULL) && (l2 != NULL)) {
622 if (l1 == l2)
623 return 1;
625 if (!osl_relation_equal(l1->elt, l2->elt))
626 return 0;
628 l1 = l1->next;
629 l2 = l2->next;
632 if (((l1 == NULL) && (l2 != NULL)) || ((l1 != NULL) && (l2 == NULL)))
633 return 0;
635 return 1;
640 * osl_relation_integrity_check function:
641 * This function checks that a list of relation is "well formed" according to
642 * some expected properties (setting an expected value to OSL_UNDEFINED
643 * means that we do not expect a specific value) and what the relations are
644 * supposed to represent (all relations of a list are supposed to have the
645 * same semantics). It returns 0 if the check failed or 1 if no problem has
646 * been detected.
647 * \param list The relation list we want to check.
648 * \param type Semantics about this relation (domain, access...).
649 * \param expected_nb_output_dims Expected number of output dimensions.
650 * \param expected_nb_input_dims Expected number of input dimensions.
651 * \param expected_nb_parameters Expected number of parameters.
652 * \return 0 if the integrity check fails, 1 otherwise.
654 int osl_relation_list_integrity_check(osl_relation_list_p list,
655 int type,
656 int expected_nb_output_dims,
657 int expected_nb_input_dims,
658 int expected_nb_parameters) {
659 while (list != NULL) {
660 // Check the access function.
661 if (!osl_relation_integrity_check(list->elt,
662 type,
663 expected_nb_output_dims,
664 expected_nb_input_dims,
665 expected_nb_parameters)) {
666 return 0;
669 list = list->next;
672 return 1;
676 /**
677 * osl_relation_list_set_type function:
678 * this function sets the type of each relation in the relation list to the
679 * one provided as parameter.
680 * \param list The list of relations to set the type.
681 * \param type The type.
683 void osl_relation_list_set_type(osl_relation_list_p list, int type) {
685 while (list != NULL) {
686 if (list->elt != NULL) {
687 list->elt->type = type;
689 list = list->next;
694 /**
695 * osl_relation_list_filter function:
696 * this function returns a copy of the input relation list, restricted to
697 * the relations of a given type. The special type OSL_TYPE_ACCESS
698 * filters any kind of access (read, write, rdwr etc.).
699 * \param list The relation list to copy/filter.
700 * \param type The filtering type.
701 * \return A copy of the input list with only relation of the given type.
703 osl_relation_list_p osl_relation_list_filter(osl_relation_list_p list,
704 int type) {
706 osl_relation_list_p copy = osl_relation_list_clone(list);
707 osl_relation_list_p filtered = NULL;
708 osl_relation_list_p previous = NULL;
709 osl_relation_list_p trash;
710 int first = 1;
712 while (copy != NULL) {
713 if ((copy->elt != NULL) &&
714 (((type == OSL_TYPE_ACCESS) &&
715 (osl_relation_is_access(copy->elt))) ||
716 ((type != OSL_TYPE_ACCESS) &&
717 (type == copy->elt->type)))) {
718 if (first) {
719 filtered = copy;
720 first = 0;
723 previous = copy;
724 copy = copy->next;
726 else {
727 trash = copy;
728 if (!first)
729 previous->next = copy->next;
730 copy = copy->next;
731 trash->next = NULL;
732 osl_relation_list_free(trash);
736 return filtered;
741 * osl_relation_list_count function:
742 * this function returns the number of elements with non-NULL content
743 * in a relation list.
744 * \param list The relation list to count the number of elements.
745 * \return The number of nodes with non-NULL content in the relation list.
747 size_t osl_relation_list_count(osl_relation_list_p list) {
748 size_t i = 0;
750 while (list != NULL) {
751 if (list->elt != NULL)
752 i++;
753 list = list->next;
756 return i;
761 * osl_relation_list_get_attributes function:
762 * this function returns, through its parameters, the maximum values of the
763 * relation attributes (nb_iterators, nb_parameters etc) in the relation list,
764 * depending on its type. HOWEVER, it updates the parameter value iff the
765 * attribute is greater than the input parameter value. Hence it may be used
766 * to get the attributes as well as to find the maximum attributes for several
767 * relation lists. The array identifier 0 is used when there is no array
768 * identifier (AND this is OK), OSL_UNDEFINED is used to report it is
769 * impossible to provide the property while it should. This function is not
770 * intended for checking, the input relation list should be correct.
771 * \param[in] list The relation list to extract attribute values.
772 * \param[in,out] nb_parameters Number of parameter attribute.
773 * \param[in,out] nb_iterators Number of iterators attribute.
774 * \param[in,out] nb_scattdims Number of scattering dimensions attribute.
775 * \param[in,out] nb_localdims Number of local dimensions attribute.
776 * \param[in,out] array_id Maximum array identifier attribute.
778 void osl_relation_list_get_attributes(osl_relation_list_p list,
779 int * nb_parameters,
780 int * nb_iterators,
781 int * nb_scattdims,
782 int * nb_localdims,
783 int * array_id) {
784 int local_nb_parameters = OSL_UNDEFINED;
785 int local_nb_iterators = OSL_UNDEFINED;
786 int local_nb_scattdims = OSL_UNDEFINED;
787 int local_nb_localdims = OSL_UNDEFINED;
788 int local_array_id = OSL_UNDEFINED;
790 while (list != NULL) {
791 osl_relation_get_attributes(list->elt,
792 &local_nb_parameters,
793 &local_nb_iterators,
794 &local_nb_scattdims,
795 &local_nb_localdims,
796 &local_array_id);
797 // Update.
798 *nb_parameters = OSL_max(*nb_parameters, local_nb_parameters);
799 *nb_iterators = OSL_max(*nb_iterators, local_nb_iterators);
800 *nb_scattdims = OSL_max(*nb_scattdims, local_nb_scattdims);
801 *nb_localdims = OSL_max(*nb_localdims, local_nb_localdims);
802 *array_id = OSL_max(*array_id, local_array_id);
803 list = list->next;