c2ats icon indicating copy to clipboard operation
c2ats copied to clipboard

Sort trivial forward declaration

Open master-q opened this issue 9 years ago • 2 comments
trafficstars

master-q avatar Sep 12 '16 12:09 master-q

typedef union
{
  struct __pthread_mutex_s
  {
    int __lock;
    unsigned int __count;
    int __owner;

    unsigned int __nusers;



    int __kind;

    short __spins;
    short __elision;
    __pthread_list_t __list;
  } __data;
  char __size[40];
  long int __align;
} pthread_mutex_t;

Above code is translated into following:

typedef union_c2ats_anon_3971 = $extype_struct"union { struct __pthread_mutex_s __data; char __size[40]; long int __align; }" of {
  __data = struct_c2ats___pthread_mutex_s,
  __size = @[char][40],
  __align = lint
}
typedef type_c2ats_pthread_mutex_t = union_c2ats_anon_3971
typedef struct_c2ats___pthread_mutex_s = $extype_struct"struct __pthread_mutex_s" of {
  __lock = int,
  __count = uint,
  __owner = int,
  __nusers = uint,
  __kind = int,
  __spins = sint,
  __elision = sint,
  __list = type_c2ats___pthread_list_t
}

master-q avatar Sep 12 '16 12:09 master-q

Following is better:

typedef struct_c2ats___pthread_mutex_s = $extype_struct"struct __pthread_mutex_s" of {
  __lock = int,
  __count = uint,
  __owner = int,
  __nusers = uint,
  __kind = int,
  __spins = sint,
  __elision = sint,
  __list = type_c2ats___pthread_list_t
}
typedef union_c2ats_anon_3971 = $extype_struct"union { struct __pthread_mutex_s __data; char __size[40]; long int __align; }" of {
  __data = struct_c2ats___pthread_mutex_s,
  __size = @[char][40],
  __align = lint
}
typedef type_c2ats_pthread_mutex_t = union_c2ats_anon_3971

master-q avatar Sep 12 '16 12:09 master-q