forked from Imagelibrary/binutils-gdb
libctf: types: add ctf_struct_bitfield (NEEDS REVIEW)
This new public API function allows you to find out if a struct has the bitfield flag set or not. (There are no other properties specific to a struct, so we needed a new function for it. I am open to a ctf_struct_info() function handing back a struct if people prefer.) New API: int ctf_struct_bitfield (ctf_dict_t *, ctf_id_t);
This commit is contained in:
@@ -685,6 +685,9 @@ extern int ctf_type_cmp (ctf_dict_t *, ctf_id_t, ctf_dict_t *, ctf_id_t);
|
|||||||
|
|
||||||
extern const char *ctf_enum_name (ctf_dict_t *, ctf_id_t, int);
|
extern const char *ctf_enum_name (ctf_dict_t *, ctf_id_t, int);
|
||||||
extern int ctf_enum_value (ctf_dict_t *, ctf_id_t, const char *, int *);
|
extern int ctf_enum_value (ctf_dict_t *, ctf_id_t, const char *, int *);
|
||||||
|
/* Return nonzero if this struct or union uses bitfield encoding. */
|
||||||
|
|
||||||
|
extern int ctf_struct_bitfield (ctf_dict_t *, ctf_id_t);
|
||||||
|
|
||||||
/* Get the size and member type of an array. */
|
/* Get the size and member type of an array. */
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef roundup
|
||||||
|
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Determine whether a type is a parent or a child. Bad IDs are not
|
/* Determine whether a type is a parent or a child. Bad IDs are not
|
||||||
diagnosed! */
|
diagnosed! */
|
||||||
|
|
||||||
@@ -1800,6 +1804,25 @@ ctf_enum_value (ctf_dict_t *fp, ctf_id_t type, const char *name, int *valp)
|
|||||||
return ctf_set_errno (ofp, ECTF_NOENUMNAM);
|
return ctf_set_errno (ofp, ECTF_NOENUMNAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return nonzero if this struct or union uses bitfield encoding. */
|
||||||
|
int
|
||||||
|
ctf_struct_bitfield (ctf_dict_t * fp, ctf_id_t type)
|
||||||
|
{
|
||||||
|
int kind;
|
||||||
|
const ctf_type_t *tp; /* The suffixed kind, if prefixed */
|
||||||
|
|
||||||
|
if ((kind = ctf_type_kind (fp, type)) < 0)
|
||||||
|
return -1; /* errno is set for us. */
|
||||||
|
|
||||||
|
if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
|
||||||
|
return (ctf_set_errno (fp, ECTF_NOTSOU));
|
||||||
|
|
||||||
|
if (ctf_lookup_by_id (&fp, type, &tp) == NULL)
|
||||||
|
return -1; /* errno is set for us. */
|
||||||
|
|
||||||
|
return CTF_INFO_KFLAG (tp->ctt_info);
|
||||||
|
}
|
||||||
|
|
||||||
/* Given a type ID relating to a function type, return info on return types and
|
/* Given a type ID relating to a function type, return info on return types and
|
||||||
arg counts for that function. */
|
arg counts for that function. */
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ LIBCTF_2.0 {
|
|||||||
ctf_member_next;
|
ctf_member_next;
|
||||||
ctf_array_info;
|
ctf_array_info;
|
||||||
ctf_member_count;
|
ctf_member_count;
|
||||||
|
ctf_struct_bitfield;
|
||||||
|
|
||||||
ctf_enum_name;
|
ctf_enum_name;
|
||||||
ctf_enum_value;
|
ctf_enum_value;
|
||||||
|
|||||||
Reference in New Issue
Block a user