From 1120161286ee5c855b630bccc9e0b37bb8a3ee65 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Sat, 17 Oct 2020 19:07:11 -0400 Subject: Fix DIS coding style by running them all through clang-format Also fixes a missing header in DISstressmarkRNG.h and the "all" make target. No functional changes. --- dis/Update/DISstressmarkRNG.h | 1 + dis/Update/update.c | 98 ++++++++++++++++++++++--------------------- 2 files changed, 51 insertions(+), 48 deletions(-) (limited to 'dis/Update') diff --git a/dis/Update/DISstressmarkRNG.h b/dis/Update/DISstressmarkRNG.h index 4aa2620..6243606 100644 --- a/dis/Update/DISstressmarkRNG.h +++ b/dis/Update/DISstressmarkRNG.h @@ -1,3 +1,4 @@ +#include #include #define IA 16807 diff --git a/dis/Update/update.c b/dis/Update/update.c index f5e770a..a12c3df 100644 --- a/dis/Update/update.c +++ b/dis/Update/update.c @@ -1,24 +1,24 @@ /* * Sample code for the DIS Update Stressmark * - * This source code is the completely correct source code based on - * the example codes provided by Atlantic Aerospace Division, Titan + * This source code is the completely correct source code based on + * the example codes provided by Atlantic Aerospace Division, Titan * Systems Corporation, 2000. - * - * If you just compile and generate the executables from this source - * code, this code would be enough. However, if you wish to get a complete + * + * If you just compile and generate the executables from this source + * code, this code would be enough. However, if you wish to get a complete * understanding of this stressmark, it is strongly suggested that you * read the Benchmark Analysis and Specifications Document Version 1.0 * before going on since the detailed comments are given in this documents. * the comments are not repeated here. */ +#include "DISstressmarkRNG.h" +#include "extra.h" +#include #include #include #include -#include -#include "DISstressmarkRNG.h" -#include "extra.h" #define MIN_FIELD_SIZE 16 @@ -36,11 +36,11 @@ #define MAX_SEED -1 -/* - *main() +/* + *main() */ - -int main(int argc, char** argv){ + +int main(int argc, char **argv) { unsigned int *field; unsigned int f; @@ -55,13 +55,13 @@ int main(int argc, char** argv){ unsigned int hops; unsigned int l; - assert(fscanf(stdin, "%u %u %u %d %u %u %u", - &f, &l, &maxhops, &seed, &initial, &minStop, &maxStop) == 7); + assert(fscanf(stdin, "%u %u %u %d %u %u %u", &f, &l, &maxhops, &seed, + &initial, &minStop, &maxStop) == 7); assert((f >= MIN_FIELD_SIZE) && (f <= MAX_FIELD_SIZE)); - w = (unsigned int )l; + w = (unsigned int)l; assert((w >= MIN_WINDOW_SIZE) && (w <= MAX_WINDOW_SIZE)); - assert(w%2 == 1); + assert(w % 2 == 1); assert(f > w); assert((maxhops >= MIN_HOP_LIMIT) && (maxhops <= MAX_HOP_LIMIT)); assert((seed >= MIN_SEED) && (seed <= MAX_SEED)); @@ -69,14 +69,14 @@ int main(int argc, char** argv){ assert((minStop >= 0) && (minStop < f)); assert((maxStop >= 0) && (maxStop < f)); - if ((field = (unsigned int *)malloc(f*sizeof(int))) == NULL) + if ((field = (unsigned int *)malloc(f * sizeof(int))) == NULL) return (-1); - + randInit(seed); - for (l=0; l= minStop) && - (index < maxStop)))){ + while ((hops < maxhops) && (!((index >= minStop) && (index < maxStop)))) { int sum; unsigned int ll, lll; @@ -98,43 +96,47 @@ int main(int argc, char** argv){ high = 0; sum = 0; - for (ll=0; ll max) high++; - else if (x >min){ /* start else* */ - partition = x; - balance = 0; - for (lll=ll+1; lll partition) balance++; - } - if (balance+high == w/2) break; - else if (balance+high>w/2){ - min = partition; - }/* end if */ - else{ - max = partition; - high++; - } /* end else */ + if (x > max) + high++; + else if (x > min) { /* start else* */ + partition = x; + balance = 0; + for (lll = ll + 1; lll < w; lll++) { + if (field[index + lll] > partition) + balance++; + } + if (balance + high == w / 2) + break; + else if (balance + high > w / 2) { + min = partition; + } /* end if */ + else { + max = partition; + high++; + } /* end else */ } - if (min == max) break; - }/* end else* */ - field[index] = sum % (f-w); - index = (partition+hops)%(f-w); + if (min == max) + break; + } /* end else* */ + field[index] = sum % (f - w); + index = (partition + hops) % (f - w); hops++; - }/* end for loop */ + } /* end for loop */ STOP_LOOP endTime = time(NULL); volatile int _stop_optimizer = hops; - //fprintf(stdout, "%u hops\n", hops); + // fprintf(stdout, "%u hops\n", hops); fprintf(stderr, "time for update stressmark = %f seconds.\n", difftime(endTime, startTime)); free(field); WRITE_TO_FILE - return(1); + return (1); } -- cgit v1.2.2