Changeset 1c256e6 in rtems


Ignore:
Timestamp:
Jul 20, 2017, 9:32:53 AM (2 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
b264998
Parents:
b965f461
git-author:
Sebastian Huber <sebastian.huber@…> (07/20/17 09:32:53)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/20/17 09:39:07)
Message:

tmtests/tmcontext01: Prevent GCC 7.1 optimizations

It is getting harder to prevent the compiler from optimizing away the
recursive function calls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/tmtests/tmcontext01/init.c

    rb965f461 r1c256e6  
    11/*
    2  * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2014, 2017 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    3737static rtems_counter_ticks t[SAMPLES];
    3838
    39 static volatile bool always_true = true;
     39static volatile int prevent_optimization;
    4040
    4141static size_t cache_line_size;
     
    6060}
    6161
    62 static int prevent_opt_func(int m, int n)
    63 {
    64   if (m == 0) {
    65     return n + 1;
    66   } else if (m > 0 && n == 0) {
    67     return prevent_opt_func(m - 1, 1);
    68   } else {
    69     return prevent_opt_func(m - 1, prevent_opt_func(m, n - 1));
    70   }
    71 }
    72 
    73 static int call_at_level(int start, int fl, int s, bool dirty)
    74 {
     62static int call_at_level(
     63  int start,
     64  int fl,
     65  int s,
     66  bool dirty
     67)
     68{
     69  int prevent_optimization;;
     70
     71  prevent_optimization = start + fl;
     72
    7573  if (fl == start) {
    7674    /*
     
    8381
    8482  if (fl > 0) {
    85     if (always_true) {
    86       return call_at_level(start, fl - 1, s, dirty);
    87     } else {
    88       return prevent_opt_func(fl - 1, fl - 2);
    89     }
     83    call_at_level(
     84      start,
     85      fl - 1,
     86      s,
     87      dirty
     88    );
    9089  } else {
    9190    char *volatile space;
     
    108107    b = rtems_counter_read();
    109108    t[s] = rtems_counter_difference(b, a);
    110 
    111     return 0;
    112   }
     109  }
     110
     111  return prevent_optimization;
    113112}
    114113
     
    148147  uint64_t q3;
    149148  uint64_t max;
     149
     150  fl += prevent_optimization;
    150151
    151152  rtems_interrupt_lock_initialize(&lock, "test");
Note: See TracChangeset for help on using the changeset viewer.