Commit 9ea6149a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a tiny bit of compile time type-safety, just because we can.

parent f9909907
...@@ -62,7 +62,7 @@ struct vmod { ...@@ -62,7 +62,7 @@ struct vmod {
static VTAILQ_HEAD(,vmod) vmods = VTAILQ_HEAD_INITIALIZER(vmods); static VTAILQ_HEAD(,vmod) vmods = VTAILQ_HEAD_INITIALIZER(vmods);
int int
VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, VRT_Vmod_Init(struct vmod **hdl, void *ptr, int len, const char *nm,
const char *path, const char *file_id, VRT_CTX) const char *path, const char *file_id, VRT_CTX)
{ {
struct vmod *v; struct vmod *v;
...@@ -73,6 +73,8 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, ...@@ -73,6 +73,8 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
ASSERT_CLI(); ASSERT_CLI();
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(ctx->cli); AN(ctx->cli);
AN(hdl);
AZ(*hdl);
dlhdl = dlopen(path, RTLD_NOW | RTLD_LOCAL); dlhdl = dlopen(path, RTLD_NOW | RTLD_LOCAL);
if (dlhdl == NULL) { if (dlhdl == NULL) {
...@@ -141,15 +143,16 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, ...@@ -141,15 +143,16 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
} }
void void
VRT_Vmod_Fini(void **hdl) VRT_Vmod_Fini(struct vmod **hdl)
{ {
struct vmod *v; struct vmod *v;
ASSERT_CLI(); ASSERT_CLI();
AN(*hdl); AN(hdl);
CAST_OBJ_NOTNULL(v, *hdl, VMOD_MAGIC); v = *hdl;
*hdl = NULL; *hdl = NULL;
CHECK_OBJ_NOTNULL(v, VMOD_MAGIC);
#ifndef DONT_DLCLOSE_VMODS #ifndef DONT_DLCLOSE_VMODS
/* /*
......
...@@ -58,6 +58,7 @@ struct cli; ...@@ -58,6 +58,7 @@ struct cli;
struct director; struct director;
struct VCL_conf; struct VCL_conf;
struct suckaddr; struct suckaddr;
struct vmod;
/*********************************************************************** /***********************************************************************
* This is the central definition of the mapping from VCL types to * This is the central definition of the mapping from VCL types to
...@@ -243,9 +244,9 @@ void VRT_fini_vbe(VRT_CTX, struct director **, const struct vrt_backend *); ...@@ -243,9 +244,9 @@ void VRT_fini_vbe(VRT_CTX, struct director **, const struct vrt_backend *);
int VRT_VSA_GetPtr(const struct suckaddr *sua, const unsigned char ** dst); int VRT_VSA_GetPtr(const struct suckaddr *sua, const unsigned char ** dst);
/* VMOD/Modules related */ /* VMOD/Modules related */
int VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, int VRT_Vmod_Init(struct vmod **hdl, void *ptr, int len, const char *nm,
const char *path, const char *file_id, VRT_CTX); const char *path, const char *file_id, VRT_CTX);
void VRT_Vmod_Fini(void **hdl); void VRT_Vmod_Fini(struct vmod **hdl);
struct vmod_priv; struct vmod_priv;
typedef void vmod_priv_free_f(void *); typedef void vmod_priv_free_f(void *);
......
...@@ -218,7 +218,7 @@ vcc_ParseImport(struct vcc *tl) ...@@ -218,7 +218,7 @@ vcc_ParseImport(struct vcc *tl)
} }
Fh(tl, 0, "\n/* --- BEGIN VMOD %.*s --- */\n\n", PF(mod)); Fh(tl, 0, "\n/* --- BEGIN VMOD %.*s --- */\n\n", PF(mod));
Fh(tl, 0, "static void *VGC_vmod_%.*s;\n", PF(mod)); Fh(tl, 0, "static struct vmod *VGC_vmod_%.*s;\n", PF(mod));
Fh(tl, 0, "static struct vmod_priv vmod_priv_%.*s;\n", PF(mod)); Fh(tl, 0, "static struct vmod_priv vmod_priv_%.*s;\n", PF(mod));
Fh(tl, 0, "\n%s\n", vmd->proto); Fh(tl, 0, "\n%s\n", vmd->proto);
Fh(tl, 0, "\n/* --- END VMOD %.*s --- */\n\n", PF(mod)); Fh(tl, 0, "\n/* --- END VMOD %.*s --- */\n\n", PF(mod));
......
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