(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
torture/
tls/
tls-reload-1.c
       1  /* { dg-do run } */
       2  /* { dg-require-effective-target tls_runtime } */
       3  /* { dg-add-options tls } */
       4  
       5  #define ARRAY(X) X##_array
       6  #define DECLARE(X) \
       7    __thread int X; \
       8    __thread int ARRAY(X)[4]; \
       9    int *volatile *__attribute__((noinline)) \
      10    check##X (int *volatile *y) \
      11    { \
      12      if (!y || *y++ != &X || *y++ != &ARRAY(X)[3]) \
      13        return 0; \
      14      return y; \
      15    }
      16  #define COPY(X) *y++ = &X; *y++ = &ARRAY(X)[3];
      17  #define CHECK(X) y = check##X (y);
      18  #define A(M, X) M(X##0) M(X##1) M(X##2) M(X##3) M(X##4) M(X##5) M(X##6) M(X##7)
      19  #define B(M, X) A(M, X##0) A(M, X##1) A(M, X##2)
      20  #define C(M, X) B(M, X) B(M, X) B(M, X)
      21  
      22  #define NM 2
      23  #define NA (NM * 8)
      24  #define NB (NA * 3)
      25  #define NC (NB * 3)
      26  
      27  extern void abort (void);
      28  
      29  B(DECLARE, tls)
      30  
      31  void __attribute__ ((noinline))
      32  setup (int *volatile *y)
      33  {
      34    C(COPY, tls)
      35  }
      36  
      37  int
      38  main (void)
      39  {
      40    int *volatile array[NC];
      41    int *volatile *y = array;
      42    int i;
      43  
      44    setup (array);
      45    C(CHECK, tls);
      46    if (!y)
      47      abort ();
      48    return 0;
      49  }