emit: Emit typedefs for atomic_ prefixed base types

That appear as DW_TAG_base_type, and since:

  atomic_int foo;

is equivalent to:

  _Atomic int foo;

Emit:

  typedef _Atomic int atomic_int;

So that we can make 'pahole --compile' work in these cases as well.

This will be selectable in pahole, in case we find some compiler that
either emits DWARF tags for these typedefs or that recognizes them
directly, without the need for these typedefs.

Doing this with an openvswitch file:

  $ pahole --compile eelco/ovs-vswitchd_rhel8 > vswitchd_rhel8.c ; echo "static struct dpif_userdata data;" >> vswitchd_rhel8.c ; gcc -g -c vswitchd_rhel8.c -o vswitchd_rhel8.o |& head
  vswitchd_rhel8.c:8493:33: error: redeclaration of enumerator ‘ADD’
   8493 |                                 ADD    = 0,
        |                                 ^~~
  vswitchd_rhel8.c:6229:9: note: previous definition of ‘ADD’ with type ‘enum bond_op’
   6229 |         ADD = 0,
        |         ^~~
  vswitchd_rhel8.c:12910:9: error: redeclaration of enumerator ‘ADD’
  12910 |         ADD = 0,
        |         ^~~
  vswitchd_rhel8.c:8493:33: note: previous definition of ‘ADD’ with type ‘enum <anonymous>’

Fails at first for some unrelated reason, i.e. multiple different enums
from multiple compile units that have the sane enumerator, if we
manually go and make them unique, adding some different suffixes, we go
to:

  $ vim vswitchd_rhel8.c
  $ gcc -g -c vswitchd_rhel8.c -o vswitchd_rhel8.o
  $ grep "typedef _Atomic " vswitchd_rhel8.c
  typedef _Atomic  size_t atomic_size_t;
  typedef _Atomic unsigned long atomic_ulong;
  typedef _Atomic unsigned int atomic_uint;
  typedef _Atomic _Bool atomic_bool;
  typedef _Atomic long long atomic_llong;
  typedef _Atomic unsigned int atomic_uint32_t;
  typedef _Atomic unsigned long long atomic_ullong;
  typedef _Atomic unsigned short atomic_uint16_t;
  typedef _Atomic unsigned char atomic_uint8_t;
  typedef _Atomic int atomic_int;
  $

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
6 files changed