Remove dead code, enable optimized integer read/write
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 7 May 2011 05:55:05 +0000 (01:55 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 7 May 2011 05:55:05 +0000 (01:55 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf-text/ctf-text.c
formats/ctf/types/integer.c

index 8d84c37f932163462659d32633905f1e590b5d9d..aabf6283295010ceac69bbd7a26301935afb7e4d 100644 (file)
 struct trace_descriptor *ctf_text_open_trace(const char *path, int flags);
 void ctf_text_close_trace(struct trace_descriptor *descriptor);
 
-static
-rw_dispatch read_dispatch_table[] = {
-       /* All unimplemented */
-};
-
 static
 rw_dispatch write_dispatch_table[] = {
        [ CTF_TYPE_INTEGER ] = ctf_text_integer_write,
index e43e5547217011e5d3680574d18f87f825be4508..3381b585cd61e203eb21a8be3adb2a717e56145a 100644 (file)
 #include <glib.h>
 #include <endian.h>
 
+/*
+ * The aligned read/write functions are expected to be faster than the
+ * bitfield variants. They will be enabled eventually as an
+ * optimisation.
+ */
+
 static
 void _aligned_integer_read(struct stream_pos *ppos,
                           struct definition *definition)
@@ -42,7 +48,7 @@ void _aligned_integer_read(struct stream_pos *ppos,
                {
                        uint8_t v;
 
-                       v = *(const uint8_t *)pos->base;
+                       v = *(const uint8_t *) ctf_get_pos_addr(pos);
                        integer_definition->value._unsigned = v;
                        break;
                }
@@ -50,7 +56,7 @@ void _aligned_integer_read(struct stream_pos *ppos,
                {
                        uint16_t v;
 
-                       v = *(const uint16_t *)pos->base;
+                       v = *(const uint16_t *) ctf_get_pos_addr(pos);
                        integer_definition->value._unsigned =
                                rbo ? GUINT16_SWAP_LE_BE(v) : v;
                        break;
@@ -59,7 +65,7 @@ void _aligned_integer_read(struct stream_pos *ppos,
                {
                        uint32_t v;
 
-                       v = *(const uint32_t *)pos->base;
+                       v = *(const uint32_t *) ctf_get_pos_addr(pos);
                        integer_definition->value._unsigned =
                                rbo ? GUINT32_SWAP_LE_BE(v) : v;
                        break;
@@ -68,7 +74,7 @@ void _aligned_integer_read(struct stream_pos *ppos,
                {
                        uint64_t v;
 
-                       v = *(const uint64_t *)pos->base;
+                       v = *(const uint64_t *) ctf_get_pos_addr(pos);
                        integer_definition->value._unsigned =
                                rbo ? GUINT64_SWAP_LE_BE(v) : v;
                        break;
@@ -82,7 +88,7 @@ void _aligned_integer_read(struct stream_pos *ppos,
                {
                        int8_t v;
 
-                       v = *(const int8_t *)pos->base;
+                       v = *(const int8_t *) ctf_get_pos_addr(pos);
                        integer_definition->value._signed = v;
                        break;
                }
@@ -90,7 +96,7 @@ void _aligned_integer_read(struct stream_pos *ppos,
                {
                        int16_t v;
 
-                       v = *(const int16_t *)pos->base;
+                       v = *(const int16_t *) ctf_get_pos_addr(pos);
                        integer_definition->value._signed =
                                rbo ? GUINT16_SWAP_LE_BE(v) : v;
                        break;
@@ -99,7 +105,7 @@ void _aligned_integer_read(struct stream_pos *ppos,
                {
                        int32_t v;
 
-                       v = *(const int32_t *)pos->base;
+                       v = *(const int32_t *) ctf_get_pos_addr(pos);
                        integer_definition->value._signed =
                                rbo ? GUINT32_SWAP_LE_BE(v) : v;
                        break;
@@ -108,7 +114,7 @@ void _aligned_integer_read(struct stream_pos *ppos,
                {
                        int64_t v;
 
-                       v = *(const int64_t *)pos->base;
+                       v = *(const int64_t *) ctf_get_pos_addr(pos);
                        integer_definition->value._signed =
                                rbo ? GUINT64_SWAP_LE_BE(v) : v;
                        break;
@@ -195,6 +201,12 @@ void ctf_integer_read(struct stream_pos *ppos, struct definition *definition)
                integer_definition->declaration;
        struct ctf_stream_pos *pos = ctf_pos(ppos);
 
+       if (!(integer_declaration->p.alignment % CHAR_BIT)
+           && !(integer_declaration->len % CHAR_BIT)) {
+               _aligned_integer_read(ppos, definition);
+               return;
+       }
+
        ctf_align_pos(pos, integer_declaration->p.alignment);
        if (!integer_declaration->signedness) {
                if (integer_declaration->byte_order == LITTLE_ENDIAN)
@@ -226,6 +238,12 @@ void ctf_integer_write(struct stream_pos *ppos, struct definition *definition)
                integer_definition->declaration;
        struct ctf_stream_pos *pos = ctf_pos(ppos);
 
+       if (!(integer_declaration->p.alignment % CHAR_BIT)
+           && !(integer_declaration->len % CHAR_BIT)) {
+               _aligned_integer_write(ppos, definition);
+               return;
+       }
+
        ctf_align_pos(pos, integer_declaration->p.alignment);
        if (pos->dummy)
                goto end;
This page took 0.027456 seconds and 4 git commands to generate.