+struct lttng_ust_shm_handle *channel_handle_create(int shm_fd, int wait_fd,
+ uint64_t memory_map_size)
+{
+ struct lttng_ust_shm_handle *handle;
+ struct shm_object *object;
+
+ handle = zmalloc(sizeof(struct lttng_ust_shm_handle));
+ if (!handle)
+ return NULL;
+
+ /* Allocate table for channel + per-cpu buffers */
+ handle->table = shm_object_table_create(1 + num_possible_cpus());
+ if (!handle->table)
+ goto error_table_alloc;
+ /* Add channel object */
+ object = shm_object_table_append_shadow(handle->table,
+ shm_fd, wait_fd, memory_map_size);
+ if (!object)
+ goto error_table_object;
+ /* struct channel is at object 0, offset 0 (hardcoded) */
+ handle->chan._ref.index = 0;
+ handle->chan._ref.offset = 0;
+ return handle;
+
+error_table_object:
+ shm_object_table_destroy(handle->table);
+error_table_alloc:
+ free(handle);
+ return NULL;
+}
+
+int channel_handle_add_stream(struct lttng_ust_shm_handle *handle,
+ int shm_fd, int wait_fd, uint64_t memory_map_size)
+{
+ struct shm_object *object;
+
+ /* Add stream object */
+ object = shm_object_table_append_shadow(handle->table,
+ shm_fd, wait_fd, memory_map_size);
+ if (!object)
+ return -1;
+ return 0;
+}
+