itable.h File Reference

Contains functions for working with 16-bit itables. More...


Data Structures

struct  itable16_

Defines

#define ITABLE16_CANSIZE   16
#define ITABLE16_CANSHIFT   12
#define ITABLE16_CANMASK
#define ITABLE16_BUCKETS_PER_CAN   64
#define ITABLE16_CANBYTES   (ITABLE16_BUCKETS_PER_CAN * sizeof(void ***))
#define ITABLE16_MAXCANS   16
#define ITABLE16_BUCKETSIZE   64
#define ITABLE16_BUCKETSHIFT   6
#define ITABLE16_BUCKETMASK   (ITABLE16_BUCKETSIZE - 1)
#define ITABLE16_BUCKETBYTES   (ITABLE16_BUCKETSIZE * sizeof(void **))
#define ITABLE16_MAXINDEX   0x10000
#define ITABLE16_CANENTRY(idx)   ((idx) >> ITABLE16_CANSHIFT)
#define ITABLE16_BUCKET(idx)   (((idx) >> ITABLE16_BUCKETSHIFT) & ITABLE16_BUCKETMASK)
#define ITABLE16_BENTRY(idx)   ((idx) & ITABLE16_BUCKETMASK)
#define ITABLE16_BASE_INDEX(can, bkt)   (((can) << ITABLE16_CANSHIFT) + ((bkt) << ITABLE16_BUCKETSHIFT))

Typedefs

typedef itable16_ itable16_t
typedef void *(* itable_alloc_t )(void *ctxt, u_int32_t size)
typedef void(* itable_free_t )(void *ctxt, void *ptr)

Functions

static void * itable16_lookup_inline (itable16_t *table, const index16_t *target_index)
 Looks up an entry by index in the itable.
static index16_t itable16_get_highest_index (itable16_t *table)
 Determines the highest index used in the itable.
itable16_t * itable16_create (void)
 Creates and initializes a 16-bit index table.
void itable16_set_maxindex (itable16_t *table, u_int32_t maxindex)
 Sets the maximum index value for an itable.
void itable16_set_packed (itable16_t *table, boolean packed)
 Controls whether an itable is packed or not.
int itable16_destroy (itable16_t *table)
 Deallocates all can and bucket space from the itable, and then frees the itable.
status_t itable16_alloc (itable16_t *table, void *ptr, index16_t *ret_index)
 Allocates an index number in an itable and inserts a new entry.
status_t itable16_insert (itable16_t *table, void *ptr, const index16_t *target_index)
 Inserts a pointer into the itable at the specificed index.
status_t itable16_bound (itable16_t *table, void *ptr, const index16_t *target_index)
 Inserts a pointer into the itable at the specificed index.
void itable16_remove (itable16_t *table, const index16_t *target_index)
 Removes the entry identified by index from the itable.
void * itable16_getnext (itable16_t *table, const index16_t *prev_index, index16_t *ret_index)
 Gets the next lexigraphical entry in the itable starting at a specific index.
void * itable16_lookup (itable16_t *table, const index16_t *target_index)
 Looks up an entry by index in the itable.
void * itable16_replace (itable16_t *table, const index16_t *target_index, void *new_pointer)
 Looks up an index and replaces its entry with a new one.


Detailed Description

Contains functions for working with 16-bit itables.


Define Documentation

#define ITABLE16_CANMASK
 

Value:

(ITABLE16_BUCKETS_PER_CAN * \
                                                ITABLE16_BUCKETSIZE - 1)


Function Documentation

status_t itable16_alloc itable16_t *  table,
void *  ptr,
index16_t *  ret_index
 

Allocates an index number in an itable and inserts a new entry.

Parameters:
[in] table Pointer to an itable16_t
[in] ptr Pointer to entry to store in the itable
[out] ret_index Index at which the entry was stored in the itable
Returns:
EOK on success; otherwise an error code.

status_t itable16_bound itable16_t *  table,
void *  ptr,
const index16_t *  target_index
 

Inserts a pointer into the itable at the specificed index.

Used for bounding the itable and burning index zero.

Parameters:
[in] table Pointer to an itable16_t
[in] ptr Pointer to the entry to store in the itable
[in] target_index Index of entry to insert
Returns:
EOK on success; otherwise an error code.

itable16_t* itable16_create void   ) 
 

Creates and initializes a 16-bit index table.

Returns:
A pointer to a new itable; NULL if memory allocation fails.

int itable16_destroy itable16_t *  table  ) 
 

Deallocates all can and bucket space from the itable, and then frees the itable.

Parameters:
[in] table Pointer to an itable16_t
Returns:
The number of non-NULL cells in the table.

static index16_t itable16_get_highest_index itable16_t *  table  )  [inline, static]
 

Determines the highest index used in the itable.

Parameters:
[in] table Pointer to an itable16_t
Returns:
The index of the highest entry in the itable.

void* itable16_getnext itable16_t *  table,
const index16_t *  prev_index,
index16_t *  ret_index
 

Gets the next lexigraphical entry in the itable starting at a specific index.

Parameters:
[in] table Pointer to an itable16_t
[in] prev_index Pointer to the index of the previous entry
[out] ret_index Pointer to store the index of the entry found
Returns:
A pointer to the next entry in the itable.

status_t itable16_insert itable16_t *  table,
void *  ptr,
const index16_t *  target_index
 

Inserts a pointer into the itable at the specificed index.

Parameters:
[in] table Pointer to an itable16_t
[in] ptr Pointer to the entry to store in the itable
[in] target_index Index of entry to insert
Returns:
EOK on success; otherwise an error code.

void* itable16_lookup itable16_t *  table,
const index16_t *  target_index
 

Looks up an entry by index in the itable.

Parameters:
[in] table Pointer to an itable16_t
[in] target_index Pointer to the index to look up
Returns:
A pointer to the entry stored at the index.

static void* itable16_lookup_inline itable16_t *  table,
const index16_t *  target_index
[inline, static]
 

Looks up an entry by index in the itable.

Returns the entry at the specified index. (This is the inline form of the function.)

Parameters:
[in] table Pointer to an itable16_t
[in] target_index Pointer to the index to look up
Returns:
A pointer to the entry stored at target_index.

void itable16_remove itable16_t *  table,
const index16_t *  target_index
 

Removes the entry identified by index from the itable.

Parameters:
[in] table Pointer to an itable16_t
[in] target_index Pointer to the index of entry to remove

void* itable16_replace itable16_t *  table,
const index16_t *  target_index,
void *  new_pointer
 

Looks up an index and replaces its entry with a new one.

Parameters:
[in] table Pointer to an itable16_t
[in] target_index Pointer to the index to replace
[in] new_pointer Pointer to the entry to store in the itable
Returns:
A pointer to the old entry; NULL if the index could not be found.

void itable16_set_maxindex itable16_t *  table,
u_int32_t  maxindex
 

Sets the maximum index value for an itable.

The maximum index cannot be zero.

Parameters:
[in] table Pointer to an itable16_t
[in] maxindex Maximum index value (1 .. ITABLE16_MAXINDEX)

void itable16_set_packed itable16_t *  table,
boolean  packed
 

Controls whether an itable is packed or not.

Parameters:
[in] table Pointer to an itable16_t
[in] packed TRUE to pack the itable, FALSE otherwise


2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:23:40 2010 for libjuniper by Doxygen 1.4.5