Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vdef: introduce v_counted_by_(field) #4039

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/varnishd/hpack/vhp_gen_hufdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct tbl {
unsigned idx;
unsigned lvl;
unsigned p_idx;
struct cod e[];
struct cod e[] v_counted_by_(n);
};

static struct tbl *
Expand Down
3 changes: 2 additions & 1 deletion bin/varnishd/http2/cache_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ struct h2_rxbuf {
uint64_t tail;
uint64_t head;
struct stv_buffer *stvbuf;
uint8_t data[];
uint8_t data[]
v_counted_by_(size - PRNDUP(sizeof(struct stv_buffer)));
};

struct h2_req {
Expand Down
2 changes: 1 addition & 1 deletion bin/varnishd/proxy/cache_proxy_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct vpx_tlv {
unsigned magic;
#define VPX_TLV_MAGIC 0xdeb9a4a5
unsigned len;
char tlv[];
char tlv[] v_counted_by_(len);
};

static inline int
Expand Down
10 changes: 10 additions & 0 deletions include/vdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,16 @@ int __llvm_gcov_flush(void);
# define v_cold_
#endif

#if defined __has_attribute
# if __has_attribute(counted_by)
# define v_counted_by_(field) __attribute__((counted_by(field)))
# endif
#endif

#ifndef v_counted_by_
# define v_counted_by_(field)
#endif

/* VTIM API overhaul WIP */
typedef double vtim_mono;
typedef double vtim_real;
Expand Down
2 changes: 1 addition & 1 deletion include/vsl_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ struct VSL_head {
ssize_t segsize;
unsigned segment_n;
ssize_t offset[VSL_SEGMENTS];
uint32_t log[];
uint32_t log[] v_counted_by_(segment_n);
};
3 changes: 2 additions & 1 deletion lib/libvarnish/vte.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ struct vte {
int f_sz; /* input field size */
int f_cnt; /* actual number of fields */
int f_maxcnt; /* maximum number of fields */
int f_maxsz[]; /* maximum size per field */
int f_maxsz[]
v_counted_by_(f_cnt); /* maximum size per field */
};

struct vte *
Expand Down