(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
atomic-store-1.c
       1  /* Test __atomic routines for existence and proper execution on 1 byte 
       2     values with each valid memory model.  */
       3  /* { dg-do run } */
       4  /* { dg-require-effective-target sync_char_short } */
       5  
       6  /* Test the execution of the __atomic_store_n builtin for a char.  */
       7  
       8  extern void abort(void);
       9  
      10  char v, count;
      11  
      12  int
      13  main ()
      14  {
      15    v = 0;
      16    count = 0;
      17  
      18    __atomic_store_n (&v, count + 1, __ATOMIC_RELAXED);
      19    if (v != ++count)
      20      abort ();
      21  
      22    __atomic_store_n (&v, count + 1, __ATOMIC_RELEASE);
      23    if (v != ++count)
      24      abort ();
      25  
      26    __atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST);
      27    if (v != ++count)
      28      abort ();
      29  
      30    /* Now test the generic variant.  */
      31    count++;
      32  
      33    __atomic_store (&v, &count, __ATOMIC_RELAXED);
      34    if (v != count++)
      35      abort ();
      36  
      37    __atomic_store (&v, &count, __ATOMIC_RELEASE);
      38    if (v != count++)
      39      abort ();
      40  
      41    __atomic_store (&v, &count, __ATOMIC_SEQ_CST);
      42    if (v != count)
      43      abort ();
      44  
      45  
      46    return 0;
      47  }
      48