2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-11 13:57:52 +00:00
Files
openvswitch/lib/id-pool.h
Simon Horman 27c247496f id-pool: Refactor id_pool_alloc_id to allow any 32 bit value to be an id
id_pool_alloc_id() was created by breaking out the recirculation
allocation code. As it is now a library call it makes sense to remove
the restriction that id 0 is reserved.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2014-11-10 08:39:57 -08:00

46 lines
1.1 KiB
C

/*
* Copyright (c) 2014 Nicira, Inc.
* Copyright (c) 2014 Netronome.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ID_POOL_H
#define ID_POOL_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
struct id_pool;
struct id_pool *id_pool_create(uint32_t base, uint32_t n_ids);
void id_pool_destroy(struct id_pool *);
bool id_pool_alloc_id(struct id_pool *, uint32_t *id);
void id_pool_free_id(struct id_pool *, uint32_t id);
void id_pool_add(struct id_pool *, uint32_t id);
/*
* ID pool.
* ========
*
* Pool of unique 32bit ids.
*
*
* Thread-safety
* =============
*
* APIs are not thread safe.
*/
#endif /* id-pool.h */