X-Git-Url: http://git.cascardo.info/?a=blobdiff_plain;f=lib%2Fsset.h;h=7d1d496285dfd7a02dc3144305b8f554b88bcce3;hb=585a5beaa2a45dd43f41543b7c9800d13083bc1a;hp=1e864efce6d5a71e0bbcb902c287485ca8a6ed87;hpb=55d2690646769467b6d26ad55516ff6eeb12869d;p=cascardo%2Fovs.git diff --git a/lib/sset.h b/lib/sset.h index 1e864efce..7d1d49628 100644 --- a/lib/sset.h +++ b/lib/sset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, 2013 Nicira, Inc. + * Copyright (c) 2011, 2012, 2013, 2015, 2016 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,6 +67,9 @@ bool sset_equals(const struct sset *, const struct sset *); struct sset_node *sset_at_position(const struct sset *, uint32_t *bucketp, uint32_t *offsetp); +/* Set operations. */ +void sset_intersect(struct sset *, const struct sset *); + /* Iteration macros. */ #define SSET_FOR_EACH(NAME, SSET) \ for ((NAME) = SSET_FIRST(SSET); \ @@ -80,6 +83,7 @@ struct sset_node *sset_at_position(const struct sset *, : false); \ (NAME) = (NEXT)) +const char **sset_array(const struct sset *); const char **sset_sort(const struct sset *); /* Implementation helper macros. */ @@ -91,10 +95,13 @@ const char **sset_sort(const struct sset *); ? NULL \ : (CONST_CAST(const char *, (SSET_NODE_FROM_HMAP_NODE(HMAP_NODE)->name))) #define SSET_NODE_FROM_NAME(NAME) CONTAINER_OF(NAME, struct sset_node, name) -#define SSET_FIRST(SSET) SSET_NAME_FROM_HMAP_NODE(hmap_first(&(SSET)->map)) +#define SSET_FIRST(SSET) \ + (BUILD_ASSERT_TYPE(SSET, struct sset *), \ + SSET_NAME_FROM_HMAP_NODE(hmap_first(&(SSET)->map))) #define SSET_NEXT(SSET, NAME) \ - SSET_NAME_FROM_HMAP_NODE( \ - hmap_next(&(SSET)->map, &SSET_NODE_FROM_NAME(NAME)->hmap_node)) + (BUILD_ASSERT_TYPE(SSET, struct sset *), \ + SSET_NAME_FROM_HMAP_NODE( \ + hmap_next(&(SSET)->map, &SSET_NODE_FROM_NAME(NAME)->hmap_node))) #ifdef __cplusplus }