view gcc/testsuite/gcc.dg/simulate-thread/strict-align-global.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
line wrap: on
line source

/* { dg-do link } */
/* { dg-final { simulate-thread } } */

#include <stdio.h>
#include "simulate-thread.h"

/* This test verifies writes to globals do not write to adjacent
   globals.  This mostly happens on strict-align targets that are not
   byte addressable (old Alphas, etc).  */

char a = 0;
char b = 77;

void simulate_thread_other_threads() 
{
}

int simulate_thread_step_verify()
{
  if (b != 77)
    {
      printf("FAIL: Unexpected value.  <b> is %d, should be 77\n", b);
      return 1;
    }
  return 0;
}

/* Verify that every variable has the correct value.  */
int simulate_thread_final_verify()
{
  int ret = simulate_thread_step_verify ();
  if (a != 66)
    {
      printf("FAIL: Unexpected value.  <a> is %d, should be 66\n", a);
      return 1;
    }
  return ret;
}

__attribute__((noinline))
void simulate_thread_main()
{
  a = 66;
}

int main ()
{
  simulate_thread_main();
  simulate_thread_done();
  return 0;
}