REORG: stick-table: move composite address functions to stick_table.h
These caddr_* functions were once placed into tools.h in the hope they would be useful but nobody knows they exist. They could deserve being moved to their own file with other pointer manipulation functions maybe, but for now they're the only reason left for stick_table.h to include tools.h, so let's move them directly there since it's its only user. This allows to remove tools.h from stick_table.h and slightly reduce the overall build time.
This commit is contained in:
parent
3b63ca20f4
commit
6ec1f25bc5
@ -31,7 +31,6 @@
|
||||
#include <haproxy/stick_table-t.h>
|
||||
#include <haproxy/ticks.h>
|
||||
#include <haproxy/time.h>
|
||||
#include <haproxy/tools.h>
|
||||
|
||||
extern struct stktable *stktables_list;
|
||||
extern struct stktable_type stktable_types[];
|
||||
@ -70,6 +69,56 @@ int stktable_get_data_type(char *name);
|
||||
int stktable_trash_oldest(struct stktable *t, int to_batch);
|
||||
int __stksess_kill(struct stktable *t, struct stksess *ts);
|
||||
|
||||
/************************* Composite address manipulation *********************
|
||||
* Composite addresses are simply unsigned long data in which the higher bits
|
||||
* represent a pointer, and the two lower bits are flags. There are several
|
||||
* places where we just want to associate one or two flags to a pointer (eg,
|
||||
* to type it), and these functions permit this. The pointer is necessarily a
|
||||
* 32-bit aligned pointer, as its two lower bits will be cleared and replaced
|
||||
* with the flags.
|
||||
*****************************************************************************/
|
||||
|
||||
/* Masks the two lower bits of a composite address and converts it to a
|
||||
* pointer. This is used to mix some bits with some aligned pointers to
|
||||
* structs and to retrieve the original (32-bit aligned) pointer.
|
||||
*/
|
||||
static inline void *caddr_to_ptr(unsigned long caddr)
|
||||
{
|
||||
return (void *)(caddr & ~3UL);
|
||||
}
|
||||
|
||||
/* Only retrieves the two lower bits of a composite address. This is used to mix
|
||||
* some bits with some aligned pointers to structs and to retrieve the original
|
||||
* data (2 bits).
|
||||
*/
|
||||
static inline unsigned int caddr_to_data(unsigned long caddr)
|
||||
{
|
||||
return (caddr & 3UL);
|
||||
}
|
||||
|
||||
/* Combines the aligned pointer whose 2 lower bits will be masked with the bits
|
||||
* from <data> to form a composite address. This is used to mix some bits with
|
||||
* some aligned pointers to structs and to retrieve the original (32-bit aligned)
|
||||
* pointer.
|
||||
*/
|
||||
static inline unsigned long caddr_from_ptr(void *ptr, unsigned int data)
|
||||
{
|
||||
return (((unsigned long)ptr) & ~3UL) + (data & 3);
|
||||
}
|
||||
|
||||
/* sets the 2 bits of <data> in the <caddr> composite address */
|
||||
static inline unsigned long caddr_set_flags(unsigned long caddr, unsigned int data)
|
||||
{
|
||||
return caddr | (data & 3);
|
||||
}
|
||||
|
||||
/* clears the 2 bits of <data> in the <caddr> composite address */
|
||||
static inline unsigned long caddr_clr_flags(unsigned long caddr, unsigned int data)
|
||||
{
|
||||
return caddr & ~(unsigned long)(data & 3);
|
||||
}
|
||||
|
||||
|
||||
/* return allocation size for standard data type <type> */
|
||||
static inline int stktable_type_size(int type)
|
||||
{
|
||||
|
@ -934,55 +934,6 @@ static inline int fix_pointer_if_wrap(const char **chunks, const char **ptr)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/************************* Composite address manipulation *********************
|
||||
* Composite addresses are simply unsigned long data in which the higher bits
|
||||
* represent a pointer, and the two lower bits are flags. There are several
|
||||
* places where we just want to associate one or two flags to a pointer (eg,
|
||||
* to type it), and these functions permit this. The pointer is necessarily a
|
||||
* 32-bit aligned pointer, as its two lower bits will be cleared and replaced
|
||||
* with the flags.
|
||||
*****************************************************************************/
|
||||
|
||||
/* Masks the two lower bits of a composite address and converts it to a
|
||||
* pointer. This is used to mix some bits with some aligned pointers to
|
||||
* structs and to retrieve the original (32-bit aligned) pointer.
|
||||
*/
|
||||
static inline void *caddr_to_ptr(unsigned long caddr)
|
||||
{
|
||||
return (void *)(caddr & ~3UL);
|
||||
}
|
||||
|
||||
/* Only retrieves the two lower bits of a composite address. This is used to mix
|
||||
* some bits with some aligned pointers to structs and to retrieve the original
|
||||
* data (2 bits).
|
||||
*/
|
||||
static inline unsigned int caddr_to_data(unsigned long caddr)
|
||||
{
|
||||
return (caddr & 3UL);
|
||||
}
|
||||
|
||||
/* Combines the aligned pointer whose 2 lower bits will be masked with the bits
|
||||
* from <data> to form a composite address. This is used to mix some bits with
|
||||
* some aligned pointers to structs and to retrieve the original (32-bit aligned)
|
||||
* pointer.
|
||||
*/
|
||||
static inline unsigned long caddr_from_ptr(void *ptr, unsigned int data)
|
||||
{
|
||||
return (((unsigned long)ptr) & ~3UL) + (data & 3);
|
||||
}
|
||||
|
||||
/* sets the 2 bits of <data> in the <caddr> composite address */
|
||||
static inline unsigned long caddr_set_flags(unsigned long caddr, unsigned int data)
|
||||
{
|
||||
return caddr | (data & 3);
|
||||
}
|
||||
|
||||
/* clears the 2 bits of <data> in the <caddr> composite address */
|
||||
static inline unsigned long caddr_clr_flags(unsigned long caddr, unsigned int data)
|
||||
{
|
||||
return caddr & ~(unsigned long)(data & 3);
|
||||
}
|
||||
|
||||
unsigned char utf8_next(const char *s, int len, unsigned int *c);
|
||||
|
||||
static inline unsigned char utf8_return_code(unsigned int code)
|
||||
|
Loading…
x
Reference in New Issue
Block a user