Commit 76f72a39 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

cache: Move the txt declaration to vdef.h

There are other components than the cache process that could benefit
from it, in particular libvcc. The relationship with vas.h is somewhat
unfortunate but that also centralize the Tcheck() logic in pdiff() and
doesn't actually require vas.h unless the macros are used, in which
case it's almost guaranteed that the calling code already included
vas.h in the first place.

The benefits should outweigh the drawbacks.
parent 33fa4953
......@@ -112,13 +112,6 @@ struct worker_priv;
/*--------------------------------------------------------------------*/
typedef struct {
const char *b;
const char *e;
} txt;
/*--------------------------------------------------------------------*/
struct lock { void *priv; }; // Opaque
/*--------------------------------------------------------------------
......@@ -833,24 +826,6 @@ int RFC2616_Do_Cond(const struct req *sp);
void RFC2616_Weaken_Etag(struct http *hp);
void RFC2616_Vary_AE(struct http *hp);
#define Tcheck(t) do { \
AN((t).b); \
AN((t).e); \
assert((t).b <= (t).e); \
} while(0)
/*
* unsigned length of a txt
*/
static inline unsigned
Tlen(const txt t)
{
Tcheck(t);
return ((unsigned)(t.e - t.b));
}
/*
* We want to cache the most recent timestamp in wrk->lastused to avoid
* extra timestamps in cache_pool.c. Hide this detail with a macro
......
......@@ -127,6 +127,8 @@ static inline size_t
pdiff(const void *b, const void *e)
{
AN(b);
AN(e);
assert(b <= e);
return ((size_t)((const char *)e - (const char *)b));
}
......
......@@ -197,3 +197,15 @@ int __llvm_gcov_flush(void);
typedef double vtim_mono;
typedef double vtim_real;
typedef double vtim_dur;
/**********************************************************************
* txt (vas.h needed for the macros)
*/
typedef struct {
const char *b;
const char *e;
} txt;
#define Tcheck(t) do { (void)pdiff((t).b, (t).e); } while (0)
#define Tlen(t) (pdiff((t).b, (t).e))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment