Fix: add missing bt_ctf_get_int_len API
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 2 May 2012 15:47:50 +0000 (11:47 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 2 May 2012 15:47:50 +0000 (11:47 -0400)
Useful to track the overflow of integer values.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/events.c
include/babeltrace/ctf/events.h
include/babeltrace/types.h
types/integer.c

index 27a5fe7bff89bc40e7efdbad21b3f18d23cafb4b..4fa8f3036b7b0364bd6eef2e16205c95de682b0b 100644 (file)
@@ -357,6 +357,20 @@ int bt_ctf_get_int_byte_order(const struct definition *field)
        return ret;
 }
 
        return ret;
 }
 
+ssize_t bt_ctf_get_int_len(const struct definition *field)
+{
+       ssize_t ret;
+
+       if (field && bt_ctf_field_type(field) == CTF_TYPE_INTEGER) {
+               ret = (ssize_t) get_int_len(field);
+       } else {
+               ret = -1;
+               bt_ctf_field_set_error(-EINVAL);
+       }
+
+       return ret;
+}
+
 enum ctf_string_encoding bt_ctf_get_encoding(const struct definition *field)
 {
        enum ctf_string_encoding ret = 0;
 enum ctf_string_encoding bt_ctf_get_encoding(const struct definition *field)
 {
        enum ctf_string_encoding ret = 0;
index 30365aaabbafd80d41e2aa6a7f2da7ec87faaff3..1cfa9e3b39cd6f37d63b004db5eaa7d3d8a5177d 100644 (file)
@@ -155,6 +155,12 @@ int bt_ctf_get_int_base(const struct definition *field);
  */
 int bt_ctf_get_int_byte_order(const struct definition *field);
 
  */
 int bt_ctf_get_int_byte_order(const struct definition *field);
 
+/*
+ * bt_ctf_get_int_len: return the size, in bits, of an int or a negative
+ * value on error
+ */
+ssize_t bt_ctf_get_int_len(const struct definition *field);
+
 /*
  * bt_ctf_get_encoding: return the encoding of an int or a string.
  * return a negative value on error
 /*
  * bt_ctf_get_encoding: return the encoding of an int or a string.
  * return a negative value on error
index 845a8ae91500a4744e82c520cd2cfc8c9cd8320d..a0ad283d1a064831e4f1c2ecee877cd51e8fdbe0 100644 (file)
@@ -371,6 +371,7 @@ int64_t get_signed_int(const struct definition *field);
 int get_int_signedness(const struct definition *field);
 int get_int_byte_order(const struct definition *field);
 int get_int_base(const struct definition *field);
 int get_int_signedness(const struct definition *field);
 int get_int_byte_order(const struct definition *field);
 int get_int_base(const struct definition *field);
+size_t get_int_len(const struct definition *field);    /* in bits */
 enum ctf_string_encoding get_int_encoding(const struct definition *field);
 
 /*
 enum ctf_string_encoding get_int_encoding(const struct definition *field);
 
 /*
index 808a4893680d3dc302a62d93f9b400299da9cffd..af5cc39fe8d98d589eb1ed2c5a6c249b546d592e 100644 (file)
@@ -129,6 +129,17 @@ int get_int_base(const struct definition *field)
        return integer_declaration->base;
 }
 
        return integer_declaration->base;
 }
 
+size_t get_int_len(const struct definition *field)
+{
+       struct definition_integer *integer_definition;
+       const struct declaration_integer *integer_declaration;
+
+       integer_definition = container_of(field, struct definition_integer, p);
+       integer_declaration = integer_definition->declaration;
+
+       return integer_declaration->len;
+}
+
 int get_int_byte_order(const struct definition *field)
 {
        struct definition_integer *integer_definition;
 int get_int_byte_order(const struct definition *field)
 {
        struct definition_integer *integer_definition;
This page took 0.02611 seconds and 4 git commands to generate.