+static
+struct declaration *ctf_declaration_floating_point_visit(int fd, int depth,
+ struct cds_list_head *expressions,
+ struct ctf_trace *trace)
+{
+ struct node *expression;
+ uint64_t alignment, exp_dig, mant_dig, byte_order = trace->byte_order;
+ int has_alignment = 0, has_exp_dig = 0, has_mant_dig = 0;
+ struct declaration_float *float_declaration;
+
+ cds_list_for_each_entry(expression, expressions, siblings) {
+ struct node *left, *right;
+
+ left = expression->u.ctf_expression.left;
+ right = expression->u.ctf_expression.right;
+ assert(left->u.unary_expression.type == UNARY_STRING);
+ if (!strcmp(left->u.unary_expression.u.string, "byte_order")) {
+ byte_order = get_byte_order(fd, depth, right);
+ if (byte_order < 0)
+ return NULL;
+ } else if (!strcmp(left->u.unary_expression.u.string, "exp_dig")) {
+ if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) {
+ fprintf(stderr, "[error] %s: exp_dig: expecting unsigned constant\n",
+ __func__);
+ return NULL;
+ }
+ exp_dig = right->u.unary_expression.u.unsigned_constant;
+ has_exp_dig = 1;
+ } else if (!strcmp(left->u.unary_expression.u.string, "mant_dig")) {
+ if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) {
+ fprintf(stderr, "[error] %s: mant_dig: expecting unsigned constant\n",
+ __func__);
+ return NULL;
+ }
+ mant_dig = right->u.unary_expression.u.unsigned_constant;
+ has_mant_dig = 1;
+ } else if (!strcmp(left->u.unary_expression.u.string, "align")) {
+ if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) {
+ fprintf(stderr, "[error] %s: align: expecting unsigned constant\n",
+ __func__);
+ return NULL;
+ }
+ alignment = right->u.unary_expression.u.unsigned_constant;
+ has_alignment = 1;
+ } else {
+ fprintf(stderr, "[error] %s: unknown attribute name %s\n",
+ __func__, left->u.unary_expression.u.string);
+ return NULL;
+ }
+ }
+ if (!has_mant_dig) {
+ fprintf(stderr, "[error] %s: missing mant_dig attribute\n", __func__);
+ return NULL;
+ }
+ if (!has_exp_dig) {
+ fprintf(stderr, "[error] %s: missing exp_dig attribute\n", __func__);
+ return NULL;
+ }
+ if (!has_alignment) {
+ if ((mant_dig + exp_dig) % CHAR_BIT) {
+ /* bit-packed alignment */
+ alignment = 1;
+ } else {
+ /* byte-packed alignment */
+ alignment = CHAR_BIT;
+ }
+ }
+ float_declaration = float_declaration_new(mant_dig, exp_dig,
+ byte_order, alignment);
+ return &float_declaration->p;
+}
+
+static
+struct declaration *ctf_declaration_string_visit(int fd, int depth,
+ struct cds_list_head *expressions,
+ struct ctf_trace *trace)
+{
+ struct node *expression;
+ const char *encoding_c = NULL;
+ enum ctf_string_encoding encoding = CTF_STRING_UTF8;
+ struct declaration_string *string_declaration;
+
+ cds_list_for_each_entry(expression, expressions, siblings) {
+ struct node *left, *right;
+
+ left = expression->u.ctf_expression.left;
+ right = expression->u.ctf_expression.right;
+ assert(left->u.unary_expression.type == UNARY_STRING);
+ if (!strcmp(left->u.unary_expression.u.string, "encoding")) {
+ if (right->u.unary_expression.type != UNARY_UNSIGNED_STRING) {
+ fprintf(stderr, "[error] %s: encoding: expecting string\n",
+ __func__);
+ return NULL;
+ }
+ encoding_c = right->u.unary_expression.u.string;
+ } else {
+ fprintf(stderr, "[error] %s: unknown attribute name %s\n",
+ __func__, left->u.unary_expression.u.string);
+ return NULL;
+ }
+ }
+ if (encoding_c && !strcmp(encoding_c, "ASCII"))
+ encoding = CTF_STRING_ASCII;
+ string_declaration = string_declaration_new(encoding);
+ return &string_declaration->p;
+}
+
+