(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
pr87793.c
       1  /* { dg-do compile } */
       2  /* { dg-skip-if "No section attribute" { { hppa*-*-hpux* } && { ! lp64 } } } */
       3  /* { dg-options "-fpic -Os -g" } */
       4  /* { dg-require-effective-target fpic } */
       5  
       6  struct fit_loadable_tbl {
       7  	int type;
       8  	void (*handler)(int data, int size);
       9  };
      10  
      11  #define ll_entry_start(_type, _list)					\
      12  ({									\
      13  	static char start[0] __attribute__((aligned(4)))		\
      14  		__attribute__((unused, section(".u_boot_list_2_"#_list"_1")));	\
      15  	(_type *)&start;						\
      16  })
      17  
      18  #define ll_entry_end(_type, _list)					\
      19  ({									\
      20  	static char end[0] __attribute__((aligned(4)))			\
      21  		__attribute__((unused, section(".u_boot_list_2_"#_list"_3")));	\
      22  	(_type *)&end;							\
      23  })
      24  
      25  #define ll_entry_count(_type, _list)					\
      26  	({								\
      27  		_type *start = ll_entry_start(_type, _list);		\
      28  		_type *end = ll_entry_end(_type, _list);		\
      29  		unsigned int _ll_result = end - start;			\
      30  		_ll_result;						\
      31  	})
      32  
      33  void test(int img_type, int img_data, int img_len)
      34  {
      35  	int i;
      36  	const unsigned int count =
      37  		ll_entry_count(struct fit_loadable_tbl, fit_loadable);
      38  	struct fit_loadable_tbl *fit_loadable_handler =
      39  		ll_entry_start(struct fit_loadable_tbl, fit_loadable);
      40  
      41  	for (i = 0; i < count; i++, fit_loadable_handler++)
      42  		if (fit_loadable_handler->type == img_type)
      43  			fit_loadable_handler->handler(img_data, img_len);
      44  }