8e6806e280ba9ad2d95f6a33829aa7df6f8f5a24 galt Sat Jun 13 02:32:07 2020 -0700 Adding Clang pragma to disable optimization only for function dlSort() in dlist.c so that BLAT on mac will give the same output as it does on linux. refs #25700 diff --git src/lib/dlist.c src/lib/dlist.c index 3d1f22d..f3cf9ef 100644 --- src/lib/dlist.c +++ src/lib/dlist.c @@ -200,59 +200,69 @@ { struct dlNode *node; }; static int (*compareFunc)(const void *elem1, const void *elem2); /* Node comparison pointer, just used by dlSortNodes and helpers. */ static int dlNodeCmp(const void *elem1, const void *elem2) /* Compare two dlSorters indirectly, by calling compareFunc. */ { struct dlSorter *a = (struct dlSorter *)elem1; struct dlSorter *b = (struct dlSorter *)elem2; return compareFunc(&a->node->val, &b->node->val); } +// BLAT compiled on the mac Clang version 11.0.0 build 33.17 (gcc version 4.2.1) +// failed unless compiler optimization is set to level 1 when compiling dlSort(). +// Clang pragma supports turning optimization off, but not setting it to a specific level. +#if defined(__clang__) +#pragma clang optimize off +#endif + void dlSort(struct dlList *list, int (*compare )(const void *elem1, const void *elem2)) /* Sort a singly linked list with Qsort and a temporary array. * The arguments to the compare function in real, non-void, life * are pointers to pointers of the type that is in the val field of * the nodes of the list. */ { int len = dlCount(list); if (len > 1) { /* Move val's onto an array, sort, and then put back into list. */ struct dlSorter *sorter = needLargeMem(len * sizeof(sorter[0])), *s; struct dlNode *node; int i; for (i=0, node = list->head; i<len; ++i, node = node->next) { s = &sorter[i]; s->node = node; } compareFunc = compare; qsort(sorter, len, sizeof(sorter[0]), dlNodeCmp); dlListInit(list); for (i=0; i<len; ++i) dlAddTail(list, sorter[i].node); freeMem(sorter); } } +#if defined(__clang__) +#pragma clang optimize on +#endif boolean dlEmpty(struct dlList *list) /* Return TRUE if list is empty. */ { return dlIsEmpty(list); } struct dlNode *dlGetBeforeHead(struct dlList *list) /* Get the node before the head of the list */ { if (dlEmpty(list)) return list->head; else return list->head->prev;