poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] pickles: btf.pk: Add BTF_KIND_ENUM64


From: David Faust
Subject: Re: [PATCH] pickles: btf.pk: Add BTF_KIND_ENUM64
Date: Wed, 12 Jul 2023 10:58:45 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

Ha, right after I finished this I was scrolling through my backlog
of the list and found:

https://lists.gnu.org/archive/html/poke-devel/2022-08/msg00005.html

Looks like the same patch... but I guess it never got pushed?

On 7/12/23 10:53, David Faust wrote:
> 2023-07-12  David Faust  <david.faust@oracle.com>
> 
>       * pickles/btf.pk (BTF_KIND_ENUM64): New.
>       (BTF_KIND_LAST): Update accordingly.
>       (btf_kind_names): Add "enum64".
>       (type BTF_Enum64): New type.
>       (type BTF_Type): Support BTF_Enum64 here.
>       * pickles/btf-dump.pk (btf_dump_enum64): New function.
>       (btf_dump_type_vdata): Call it here.
> ---
>  ChangeLog           | 11 +++++++++++
>  pickles/btf-dump.pk | 12 ++++++++++++
>  pickles/btf.pk      | 22 ++++++++++++++++++++--
>  3 files changed, 43 insertions(+), 2 deletions(-)
> 
> diff --git a/ChangeLog b/ChangeLog
> index 200db0a9..bd0afb51 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,14 @@
> +2023-07-12  David Faust  <david.faust@oracle.com>
> +
> +     * pickles/btf.pk (BTF_KIND_ENUM64): New.
> +     (BTF_KIND_LAST): Update accordingly.
> +     (btf_kind_names): Add "enum64".
> +     (type BTF_Enum64): New type.
> +     (type BTF_Type): Support BTF_Enum64 here.
> +     * pickles/btf-dump.pk (btf_dump_enum64): New function.
> +     (btf_dump_type_vdata): Call it here.
> +
> +
>  2023-07-06  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
>  
>       * libpoke/pkl-gen.pks (struct_mapper): Make sure `@field' is of
> diff --git a/pickles/btf-dump.pk b/pickles/btf-dump.pk
> index f18479d0..c60591fc 100644
> --- a/pickles/btf-dump.pk
> +++ b/pickles/btf-dump.pk
> @@ -47,6 +47,17 @@ fun btf_dump_enum = (BTF_Section btf, BTF_Enum[] e) void:
>                member.val);
>    }
>  
> +/* Dump 64-bit enumerators.  */
> +
> +fun btf_dump_enum64 = (BTF_Section btf, BTF_Enum64[] e) void:
> +  {
> +    for (member in e)
> +      printf ("\n\t '%s'(%v) value=%i64d",
> +              btf.get_string (member.name),
> +              member.name,
> +              member.value ());
> +  }
> +
>  /* Dump function prototype members.  */
>  
>  fun btf_dump_proto = (BTF_Section btf, BTF_Param[] ps) void:
> @@ -119,6 +130,7 @@ fun btf_dump_type_vdata = (BTF_Section btf, BTF_Type t) 
> void:
>      ({ btf_dump_int (t.data.integer); } ?! E_elem)
>        && ({ btf_dump_array (t.data.array); } ?! E_elem)
>        && ({ btf_dump_enum (btf, t.data._enum); } ?! E_elem)
> +      && ({ btf_dump_enum64 (btf, t.data.enum64); } ?! E_elem)
>        && ({ btf_dump_proto (btf, t.data.func_proto.params); } ?! E_elem)
>        && ({ btf_dump_var (t.data.variable); } ?! E_elem)
>        && ({ btf_dump_sou (btf, t); } ?! E_elem)
> diff --git a/pickles/btf.pk b/pickles/btf.pk
> index 24d7cea3..1bf4c18b 100644
> --- a/pickles/btf.pk
> +++ b/pickles/btf.pk
> @@ -39,12 +39,14 @@ var BTF_KIND_UNKNOWN = 0 as uint<5>,
>      BTF_KIND_FLOAT = 16 as uint<5>,
>      BTF_KIND_DECL_TAG = 17 as uint<5>,
>      BTF_KIND_TYPE_TAG = 18 as uint<5>,
> -    BTF_KIND_LAST = BTF_KIND_TYPE_TAG;
> +    BTF_KIND_ENUM64 = 19 as uint<5>,
> +    BTF_KIND_LAST = BTF_KIND_ENUM64;
>  
>  var btf_kind_names =
>    ["unkn", "int", "ptr", "array", "struct", "union", "enum",
>     "fwd", "typedef", "volatile", "const", "restrict", "func",
> -   "func_proto", "var", "datasec", "float", "decl_tag", "type_tag"];
> +   "func_proto", "var", "datasec", "float", "decl_tag", "type_tag",
> +   "enum64"];
>  
>  assert (btf_kind_names'length == BTF_KIND_LAST + 1);
>  
> @@ -95,6 +97,20 @@ type BTF_Enum =
>      int<32> val;
>    };
>  
> +type BTF_Enum64 =
> +  struct
> +  {
> +    offset<uint<32>,B> name;
> +    int<32> val_lo32;           /* Low 32 bits of 64-bit value.  */
> +    int<32> val_hi32;           /* High 32 bits of 64-bit value.  */
> +
> +    /* Convenience method to re-assemble the value.  */
> +    method value = int<64>:
> +    {
> +        return (((val_hi32 as uint<64>) <<. 32) | (val_lo32 as uint<32>)) as 
> int<64>;
> +    }
> +  };
> +
>  type BTF_Param =
>    struct
>    {
> @@ -160,6 +176,7 @@ type BTF_Type =
>        offset<uint<32>,B> size : (info.kind in [BTF_KIND_INT,
>                                                 BTF_KIND_FLOAT,
>                                                 BTF_KIND_ENUM,
> +                                               BTF_KIND_ENUM64,
>                                                 BTF_KIND_STRUCT,
>                                                 BTF_KIND_UNION,
>                                                 BTF_KIND_DATASEC]);
> @@ -196,6 +213,7 @@ type BTF_Type =
>        BTF_Int integer                    : info.kind == BTF_KIND_INT;
>        BTF_Array array                    : info.kind == BTF_KIND_ARRAY;
>        BTF_Enum[info.vlen] _enum          : info.kind == BTF_KIND_ENUM;
> +      BTF_Enum64[info.vlen] enum64       : info.kind == BTF_KIND_ENUM64;
>        BTF_Func_Proto func_proto          : info.kind == BTF_KIND_FUNC_PROTO;
>        BTF_Variable variable              : info.kind == BTF_KIND_VAR;
>        BTF_Member[info.vlen] members      : (info.kind == BTF_KIND_UNION



reply via email to

[Prev in Thread] Current Thread [Next in Thread]