[master] ac6f9ca Convert from enum to erzatz-but-type-safe-enum
Poul-Henning Kamp
phk at FreeBSD.org
Wed Jun 7 13:37:05 CEST 2017
commit ac6f9ca1b7a30f2d5cbad813e488592a40c380ef
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jun 7 08:47:10 2017 +0000
Convert from enum to erzatz-but-type-safe-enum
diff --git a/include/vapi/vsm.h b/include/vapi/vsm.h
index 0739c96..bd26bc9 100644
--- a/include/vapi/vsm.h
+++ b/include/vapi/vsm.h
@@ -153,13 +153,15 @@ int VSM__itern(const struct VSM_data *vd, struct VSM_fantom *vf);
* vd = "struct VSM_data *"
*/
-enum VSM_valid_e {
- VSM_invalid,
- VSM_valid,
- VSM_similar,
+struct vsm_valid {
+ const char *name;
};
-enum VSM_valid_e VSM_StillValid(const struct VSM_data *vd,
+extern const struct vsm_valid VSM_invalid[];
+extern const struct vsm_valid VSM_valid[];
+extern const struct vsm_valid VSM_similar[];
+
+const struct vsm_valid *VSM_StillValid(const struct VSM_data *vd,
struct VSM_fantom *vf);
/*
* Check the validity of a previously looked up VSM_fantom.
diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map
index 14c4418..7d76489 100644
--- a/lib/libvarnishapi/libvarnishapi.map
+++ b/lib/libvarnishapi/libvarnishapi.map
@@ -179,4 +179,7 @@ LIBVARNISHAPI_1.6 {
LIBVARNISHAPI_1.7 {
global:
VSC_ChangeLevel;
+ VSM_invalid;
+ VSM_valid;
+ VSM_similar;
} LIBVARNISHAPI_1.0;
diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index 35551d4..5835014 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -58,6 +58,9 @@
#define MAP_HASSEMAPHORE 0 /* XXX Linux */
#endif
+const struct vsm_valid VSM_invalid[1] = {{"invalid"}};
+const struct vsm_valid VSM_valid[1] = {{"valid"}};
+const struct vsm_valid VSM_similar[1] = {{"similar"}};
/*--------------------------------------------------------------------*/
@@ -390,7 +393,7 @@ VSM__itern(const struct VSM_data *vd, struct VSM_fantom *vf)
/*--------------------------------------------------------------------*/
-enum VSM_valid_e
+const struct vsm_valid *
VSM_StillValid(const struct VSM_data *vd, struct VSM_fantom *vf)
{
struct VSM_fantom f2;
More information about the varnish-commit
mailing list