]> git.proxmox.com Git - mirror_ovs.git/blame - lib/hmapx.h
netdev-offload-tc: Use single 'once' variable for probing tc features
[mirror_ovs.git] / lib / hmapx.h
CommitLineData
f4ac3fc1 1/*
bc8d7dfa 2 * Copyright (c) 2011, 2016 Nicira, Inc.
f4ac3fc1
BP
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef HMAPX_H
18#define HMAPX_H
19
ee89ea7b 20#include "openvswitch/hmap.h"
f4ac3fc1
BP
21
22struct hmapx_node {
23 struct hmap_node hmap_node;
24 void *data;
25};
26
27/* A set of "void *" pointers. */
28struct hmapx {
29 struct hmap map;
30};
31
32#define HMAPX_INITIALIZER(HMAPX) { HMAP_INITIALIZER(&(HMAPX)->map) }
33
34/* Basics. */
35void hmapx_init(struct hmapx *);
36void hmapx_destroy(struct hmapx *);
37void hmapx_clone(struct hmapx *, const struct hmapx *);
38void hmapx_swap(struct hmapx *, struct hmapx *);
39void hmapx_moved(struct hmapx *);
40
41/* Count. */
42bool hmapx_is_empty(const struct hmapx *);
43size_t hmapx_count(const struct hmapx *);
44
45/* Insertion. */
46struct hmapx_node *hmapx_add(struct hmapx *, void *);
47void hmapx_add_assert(struct hmapx *, void *);
48
49/* Deletion. */
50void hmapx_clear(struct hmapx *);
51void hmapx_delete(struct hmapx *, struct hmapx_node *);
52bool hmapx_find_and_delete(struct hmapx *, const void *);
53void hmapx_find_and_delete_assert(struct hmapx *, const void *);
54
55/* Search. */
56struct hmapx_node *hmapx_find(const struct hmapx *, const void *);
57bool hmapx_contains(const struct hmapx *, const void *);
58bool hmapx_equals(const struct hmapx *, const struct hmapx *);
59
60/* Iteration. */
61
62/* Iterates through every hmapx_node in HMAPX. */
bc8d7dfa
BP
63#define HMAPX_FOR_EACH(NODE, HMAPX) \
64 HMAP_FOR_EACH_INIT(NODE, hmap_node, &(HMAPX)->map, \
65 BUILD_ASSERT_TYPE(NODE, struct hmapx_node *), \
66 BUILD_ASSERT_TYPE(HMAPX, struct hmapx *))
f4ac3fc1
BP
67
68/* Safe when NODE may be freed (not needed when NODE may be removed from the
69 * hash map but its members remain accessible and intact). */
bc8d7dfa
BP
70#define HMAPX_FOR_EACH_SAFE(NODE, NEXT, HMAPX) \
71 HMAP_FOR_EACH_SAFE_INIT(NODE, NEXT, hmap_node, &(HMAPX)->map, \
72 BUILD_ASSERT_TYPE(NODE, struct hmapx_node *), \
73 BUILD_ASSERT_TYPE(NEXT, struct hmapx_node *), \
74 BUILD_ASSERT_TYPE(HMAPX, struct hmapx *))
f4ac3fc1
BP
75
76#endif /* hmapx.h */