Add alignment power of two check
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 13 May 2011 11:14:05 +0000 (07:14 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 13 May 2011 11:14:05 +0000 (07:14 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/metadata/ctf-test/succeed/ctf-embedded-1.txt
formats/ctf/metadata/ctf-visitor-generate-io-struct.c

index 4a97cdf7a9f6dfaf82697cdbc8197dd523b74cb5..27af72332be0cdf652d1992d59e1bb770cebf45f 100644 (file)
@@ -33,3 +33,52 @@ stream {
 event { name = invalid; id = 0; };
 event { name = func_enter; id = 1; };
 event { name = func_exit; id = 2; };
+
+event {
+       name = timer_tick;      /* or sync_point... */
+       id = 3;
+       fields := {
+               uint64_t monotonic_value;
+               uint64_t tsc_value;
+               uint32_t seqnum;
+       };
+};
+
+event {
+       name = freq_change;
+       id = 4;
+       fields := {
+               uint64_t new_freq;
+       };
+}
+
+clock {
+       name = monotonic;
+       uuid = ;
+};
+
+clock {
+       name = seqnum;
+       uuid = ;
+};
+
+clock {
+       name = tsc;
+       sync_points = {
+               map {
+                       parent.clock = monotonic;
+                       parent.value = event.timer_tick.monotonic_value;
+                       value = event.timer_tick.tsc_value;
+               };
+               map {
+                       parent.clock = seqnum;
+                       parent.value = event.timer_tick.seqnum;
+                       value = event.timer_tick.tsc_value;
+               };
+       };
+
+       freq = {
+               update = event.freq_change.new_freq;
+       };
+       uuid = ;
+};
index 9da7d0d8322d8aecd55590db613de4bdab2388d2..37d17f5839e2ebb4047a4f338e6634be44c9b2e8 100644 (file)
@@ -1088,6 +1088,12 @@ struct declaration *ctf_declaration_integer_visit(FILE *fd, int depth,
                                return NULL;
                        }
                        alignment = right->u.unary_expression.u.unsigned_constant;
+                       /* Make sure alignment is a power of two */
+                       if (alignment == 0 || (alignment & (alignment - 1)) != 0) {
+                               fprintf(fd, "[error] %s: align: expecting power of two\n",
+                                       __func__);
+                               return NULL;
+                       }
                        has_alignment = 1;
                } else {
                        fprintf(fd, "[error] %s: unknown attribute name %s\n",
@@ -1156,6 +1162,12 @@ struct declaration *ctf_declaration_floating_point_visit(FILE *fd, int depth,
                                return NULL;
                        }
                        alignment = right->u.unary_expression.u.unsigned_constant;
+                       /* Make sure alignment is a power of two */
+                       if (alignment == 0 || (alignment & (alignment - 1)) != 0) {
+                               fprintf(fd, "[error] %s: align: expecting power of two\n",
+                                       __func__);
+                               return NULL;
+                       }
                        has_alignment = 1;
                } else {
                        fprintf(fd, "[error] %s: unknown attribute name %s\n",
This page took 0.0258 seconds and 4 git commands to generate.