/*1* Copyright © 2019 Broadcom2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#ifndef DAG_H24#define DAG_H2526#include <stdint.h>27#include "util/list.h"28#include "util/u_dynarray.h"2930#ifdef __cplusplus31extern "C" {32#endif3334struct dag_edge {35struct dag_node *child;36/* User-defined data associated with the edge. */37void *data;38};3940struct dag_node {41/* Position in the DAG heads list (or a self-link) */42struct list_head link;43/* Array struct edge to the children. */44struct util_dynarray edges;45uint32_t parent_count;46};4748struct dag {49struct list_head heads;50};5152struct dag *dag_create(void *mem_ctx);53void dag_init_node(struct dag *dag, struct dag_node *node);54void dag_add_edge(struct dag_node *parent, struct dag_node *child, void *data);55void dag_remove_edge(struct dag *dag, struct dag_edge *edge);56void dag_traverse_bottom_up(struct dag *dag, void (*cb)(struct dag_node *node,57void *data), void *data);58void dag_prune_head(struct dag *dag, struct dag_node *node);5960#ifdef __cplusplus61}62#endif6364#endif656667