void VSL_Init(void);
#ifdef SHMLOGHEAD_MAGIC
-void VSLR(enum shmlogtag tag, unsigned id, const char *b, const char *e);
-void VSL(enum shmlogtag tag, unsigned id, const char *fmt, ...);
-void WSLR(struct worker *w, enum shmlogtag tag, unsigned id, const char *b, const char *e);
-void WSL(struct worker *w, enum shmlogtag tag, unsigned id, const char *fmt, ...);
+void VSLR(enum shmlogtag tag, int id, const char *b, const char *e);
+void VSL(enum shmlogtag tag, int id, const char *fmt, ...);
+void WSLR(struct worker *w, enum shmlogtag tag, int id, const char *b, const char *e);
+void WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...);
void WSL_Flush(struct worker *w);
#define INCOMPL() do { \
VSL(SLT_Debug, 0, "INCOMPLETE AT: %s(%d)", __func__, __LINE__); \
/*--------------------------------------------------------------------*/
void
-VSLR(enum shmlogtag tag, unsigned id, const char *b, const char *e)
+VSLR(enum shmlogtag tag, int id, const char *b, const char *e)
{
unsigned char *p;
unsigned l;
e = strchr(b, '\0');
/* Truncate */
- l = e - b;
+ l = pdiff(b, e);
if (l > 255) {
l = 255;
e = b + l;
/*--------------------------------------------------------------------*/
void
-VSL(enum shmlogtag tag, unsigned id, const char *fmt, ...)
+VSL(enum shmlogtag tag, int id, const char *fmt, ...)
{
va_list ap;
unsigned char *p;
unsigned n;
+ AN(fmt);
va_start(ap, fmt);
if (strchr(fmt, '%') == NULL) {
p = logstart + loghead->ptr;
n = 0;
- if (fmt != NULL) {
- n = vsnprintf((char *)(p + 4), 256, fmt, ap);
- if (n > 255)
- n = 255; /* we truncate long fields */
- }
+ n = vsnprintf((char *)(p + 4), 256, fmt, ap);
+ if (n > 255)
+ n = 255; /* we truncate long fields */
p[1] = n & 0xff;
p[2] = (id >> 8) & 0xff;
p[3] = id & 0xff;
if (w->wlp == w->wlog)
return;
- l = w->wlp - w->wlog;
+ l = pdiff(w->wlog, w->wlp);
LOCKSHM(&vsl_mtx);
VSL_stats->shm_writes++;
VSL_stats->shm_records += w->wlr;
/*--------------------------------------------------------------------*/
void
-WSLR(struct worker *w, enum shmlogtag tag, unsigned id, const char *b, const char *e)
+WSLR(struct worker *w, enum shmlogtag tag, int id, const char *b, const char *e)
{
unsigned char *p;
unsigned l;
e = strchr(b, '\0');
/* Truncate */
- l = e - b;
+ l = pdiff(b, e);
if (l > 255) {
l = 255;
e = b + l;
/*--------------------------------------------------------------------*/
void
-WSL(struct worker *w, enum shmlogtag tag, unsigned id, const char *fmt, ...)
+WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...)
{
va_list ap;
unsigned char *p;
unsigned n;
+ AN(fmt);
va_start(ap, fmt);
if (strchr(fmt, '%') == NULL) {
p = w->wlp;
n = 0;
- if (fmt != NULL) {
- n = vsnprintf((char *)(p + 4), 256, fmt, ap);
- if (n > 255)
- n = 255; /* we truncate long fields */
- }
+ n = vsnprintf((char *)(p + 4), 256, fmt, ap);
+ if (n > 255)
+ n = 255; /* we truncate long fields */
p[1] = n & 0xff;
p[2] = (id >> 8) & 0xff;
p[3] = id & 0xff;