2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-27 15:18:06 +00:00

flow: Make compile with MSVC.

MSVC does not like zero sized arrays in structs.  Hence, remove the
'values' member from struct miniflow and add back the getters
miniflow_values() and miniflow_get_values().

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Jarno Rajahalme
2015-07-16 17:42:24 -07:00
parent 2cd87fce12
commit 09b0fa9c55
6 changed files with 72 additions and 54 deletions

View File

@@ -254,7 +254,7 @@ static inline uint32_t
flow_hash_in_minimask(const struct flow *flow, const struct minimask *mask,
uint32_t basis)
{
const uint64_t *mask_values = mask->masks.values;
const uint64_t *mask_values = miniflow_get_values(&mask->masks);
const uint64_t *flow_u64 = (const uint64_t *)flow;
const uint64_t *p = mask_values;
uint32_t hash;
@@ -277,7 +277,7 @@ static inline uint32_t
miniflow_hash_in_minimask(const struct miniflow *flow,
const struct minimask *mask, uint32_t basis)
{
const uint64_t *mask_values = mask->masks.values;
const uint64_t *mask_values = miniflow_get_values(&mask->masks);
const uint64_t *p = mask_values;
uint32_t hash = basis;
uint64_t flow_u64;
@@ -299,7 +299,7 @@ flow_hash_in_minimask_range(const struct flow *flow,
const struct minimask *mask,
uint8_t start, uint8_t end, uint32_t *basis)
{
const uint64_t *mask_values = mask->masks.values;
const uint64_t *mask_values = miniflow_get_values(&mask->masks);
const uint64_t *flow_u64 = (const uint64_t *)flow;
unsigned int offset;
uint64_t map;
@@ -332,14 +332,14 @@ flow_wildcards_fold_minimask_range(struct flow_wildcards *wc,
const struct minimask *mask,
uint8_t start, uint8_t end)
{
const uint64_t *p = miniflow_get_values(&mask->masks);
uint64_t *dst_u64 = (uint64_t *)&wc->masks;
unsigned int offset;
uint64_t map;
const uint64_t *p;
int idx;
map = miniflow_get_map_in_range(&mask->masks, start, end, &offset);
p = mask->masks.values + offset;
p += offset;
MAP_FOR_EACH_INDEX(idx, map) {
dst_u64[idx] |= *p++;
}
@@ -349,7 +349,7 @@ flow_wildcards_fold_minimask_range(struct flow_wildcards *wc,
static inline uint32_t
miniflow_hash(const struct miniflow *flow, uint32_t basis)
{
const uint64_t *values = flow->values;
const uint64_t *values = miniflow_get_values(flow);
const uint64_t *p = values;
uint32_t hash = basis;
uint64_t hash_map = 0;
@@ -390,15 +390,16 @@ static inline uint32_t
minimatch_hash_range(const struct minimatch *match, uint8_t start, uint8_t end,
uint32_t *basis)
{
const uint64_t *p = miniflow_get_values(match->flow);
const uint64_t *q = miniflow_get_values(&match->mask->masks);
unsigned int offset;
const uint64_t *p, *q;
uint32_t hash = *basis;
int n, i;
n = count_1bits(miniflow_get_map_in_range(&match->mask->masks, start, end,
&offset));
q = match->mask->masks.values + offset;
p = match->flow->values + offset;
q += offset;
p += offset;
for (i = 0; i < n; i++) {
hash = hash_add64(hash, p[i] & q[i]);