summaryrefslogtreecommitdiff
path: root/memcached.h
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2019-05-14 21:18:23 -0700
committerdormando <dormando@rydia.net>2019-05-20 13:14:44 -0700
commitf28cbc5e9a31c0b0910898cf082e2f2a95a0bed0 (patch)
tree2c4de47ec1ad279805836251dce03e9ca0b682ee /memcached.h
parent31208e8fbeceea163c2fd95dd1031ec684d88fc3 (diff)
downloadmemcached-f28cbc5e9a31c0b0910898cf082e2f2a95a0bed0.tar.gz
widen internal item flags to 16bits.
did a weird dance. nsuffix is no longer an 8bit length, replaced with ITEM_CFLAGS bit. This indicates whether there is a 32bit set of client flags in the item or not. possible after removing the inlined ascii response header via previous commit.
Diffstat (limited to 'memcached.h')
-rw-r--r--memcached.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/memcached.h b/memcached.h
index df1e7d5..d861803 100644
--- a/memcached.h
+++ b/memcached.h
@@ -116,11 +116,12 @@
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#define ITEM_data(item) ((char*) &((item)->data) + (item)->nkey + 1 \
- + (item)->nsuffix \
+ + (((item)->it_flags & ITEM_CFLAGS) ? sizeof(uint32_t) : 0) \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#define ITEM_ntotal(item) (sizeof(struct _stritem) + (item)->nkey + 1 \
- + (item)->nsuffix + (item)->nbytes \
+ + (item)->nbytes \
+ + (((item)->it_flags & ITEM_CFLAGS) ? sizeof(uint32_t) : 0) \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#define ITEM_clsid(item) ((item)->slabs_clsid & ~(3<<6))
@@ -146,13 +147,15 @@
/** Item client flag conversion */
#define FLAGS_CONV(it, flag) { \
- if ((it)->nsuffix > 0) { \
+ if ((it)->it_flags & ITEM_CFLAGS) { \
flag = *((uint32_t *)ITEM_suffix((it))); \
} else { \
flag = 0; \
} \
}
+#define FLAGS_SIZE(item) (((item)->it_flags & ITEM_CFLAGS) ? sizeof(uint32_t) : 0)
+
/**
* Callback for any function producing stats.
*
@@ -467,10 +470,11 @@ extern struct settings settings;
/* If an item's storage are chained chunks. */
#define ITEM_CHUNKED 32
#define ITEM_CHUNK 64
-#ifdef EXTSTORE
/* ITEM_data bulk is external to item */
#define ITEM_HDR 128
-#endif
+/* additional 4 bytes for item client flags */
+#define ITEM_CFLAGS 256
+/* 7 bits free! */
/**
* Structure for storing items within memcached.
@@ -485,8 +489,7 @@ typedef struct _stritem {
rel_time_t exptime; /* expire time */
int nbytes; /* size of data */
unsigned short refcount;
- uint8_t nsuffix; /* length of flags-and-length string */
- uint8_t it_flags; /* ITEM_* above */
+ uint16_t it_flags; /* ITEM_* above */
uint8_t slabs_clsid;/* which slab class we're in */
uint8_t nkey; /* key length, w/terminating null and padding */
/* this odd type prevents type-punning issues when we do
@@ -514,8 +517,7 @@ typedef struct {
rel_time_t exptime; /* expire time */
int nbytes; /* size of data */
unsigned short refcount;
- uint8_t nsuffix; /* length of flags-and-length string */
- uint8_t it_flags; /* ITEM_* above */
+ uint16_t it_flags; /* ITEM_* above */
uint8_t slabs_clsid;/* which slab class we're in */
uint8_t nkey; /* key length, w/terminating null and padding */
uint32_t remaining; /* Max keys to crawl per slab per invocation */
@@ -533,15 +535,16 @@ typedef struct _strchunk {
int used; /* chunk space used */
int nbytes; /* used. */
unsigned short refcount; /* used? */
- uint8_t orig_clsid; /* For obj hdr chunks slabs_clsid is fake. */
- uint8_t it_flags; /* ITEM_* above. */
+ uint16_t it_flags; /* ITEM_* above. */
uint8_t slabs_clsid; /* Same as above. */
+ uint8_t orig_clsid; /* For obj hdr chunks slabs_clsid is fake. */
char data[];
} item_chunk;
#ifdef NEED_ALIGN
static inline char *ITEM_schunk(item *it) {
- int offset = it->nkey + 1 + it->nsuffix
+ int offset = it->nkey + 1
+ + ((it->it_flags & ITEM_CFLAGS) ? sizeof(uint32_t) : 0)
+ ((it->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0);
int remain = offset % 8;
if (remain != 0) {
@@ -551,7 +554,7 @@ static inline char *ITEM_schunk(item *it) {
}
#else
#define ITEM_schunk(item) ((char*) &((item)->data) + (item)->nkey + 1 \
- + (item)->nsuffix \
+ + (((item)->it_flags & ITEM_CFLAGS) ? sizeof(uint32_t) : 0) \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#endif