+static
+int save_map_attributes(struct config_writer *writer,
+ struct lttng_map *map)
+{
+ int ret;
+ unsigned int i;
+
+ ret = config_writer_write_element_unsigned_int(writer,
+ config_element_bitness,
+ lttng_map_get_bitness(map)==LTTNG_MAP_BITNESS_32BITS ? 32: 64);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+
+ assert( lttng_map_get_boundary_policy(map) == LTTNG_MAP_BOUNDARY_POLICY_OVERFLOW);
+ ret = config_writer_write_element_string(writer,
+ config_element_boundary_policy, config_boundary_policy_overflow);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+
+ ret = config_writer_write_element_bool(writer,
+ config_element_coalesce_hits,
+ lttng_map_get_coalesce_hits(map));
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+
+ ret = config_writer_open_element(writer,
+ config_element_dimensions);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+ for (i = 0; i < lttng_map_get_dimension_count(map); i++) {
+ enum lttng_map_status map_status;
+ uint64_t dim_len;
+
+ ret = config_writer_open_element(writer,
+ config_element_dimension);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+
+ map_status = lttng_map_get_dimension_length(map, i, &dim_len);
+ if (map_status != LTTNG_MAP_STATUS_OK) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+
+ ret = config_writer_write_element_unsigned_int(writer,
+ config_element_dimension_size, dim_len);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+
+ /* dimension */
+ ret = config_writer_close_element(writer);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+ }
+
+ /* dimensions */
+ ret = config_writer_close_element(writer);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+
+end:
+ return ret;
+}
+
+