From 374b442cbc5bea4424e85fb958fe24cd15af55b2 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 2 Jun 2020 17:46:16 +0200 Subject: [PATCH] REORG: include: split common/xref.h into haproxy/xref{,-t}.h The type is the only element needed by applet.h and hlua.h, while hlua.c needs the various functions. XREF_BUSY was placed into the types as well since it's better to have the special values there. --- include/haproxy/xref-t.h | 45 ++++++++++++++++++++++++++++++ include/{common => haproxy}/xref.h | 40 ++++++++++++++++++++------ include/types/applet.h | 2 +- include/types/hlua.h | 2 +- src/hlua.c | 2 +- 5 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 include/haproxy/xref-t.h rename include/{common => haproxy}/xref.h (56%) diff --git a/include/haproxy/xref-t.h b/include/haproxy/xref-t.h new file mode 100644 index 000000000..a2aed5471 --- /dev/null +++ b/include/haproxy/xref-t.h @@ -0,0 +1,45 @@ +/* + * include/haproxy/xref-t.h + * Atomic cross-references between two elements - types + * + * Copyright (C) 2017 Thierry Fournier + * Copyright (C) 2020 Willy Tarreau - w@1wt.eu + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef __HAPROXY_XREF_T_H__ +#define __HAPROXY_XREF_T_H__ + +/* xref is used to create relation between two elements. + * Once an element is released, it breaks the relation. If the + * relation is already broken, it frees the xref struct. + * The pointer between two elements is sort of a refcount with + * max value 1. The relation is only between two elements. + * The pointer and the type of elements a and b are conventional. + */ + +#define XREF_BUSY ((struct xref *)1) + +struct xref { + struct xref *peer; +}; + +#endif /* __HAPROXY_XREF_T_H__ */ diff --git a/include/common/xref.h b/include/haproxy/xref.h similarity index 56% rename from include/common/xref.h rename to include/haproxy/xref.h index bdf292d88..e76638599 100644 --- a/include/common/xref.h +++ b/include/haproxy/xref.h @@ -1,7 +1,35 @@ -#ifndef __XREF_H__ -#define __XREF_H__ +/* + * include/haproxy/xref.h + * Atomic cross-references between two elements - functions + * + * Copyright (C) 2017 Thierry Fournier + * Copyright (C) 2020 Willy Tarreau - w@1wt.eu + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef __HAPROXY_XREF_H__ +#define __HAPROXY_XREF_H__ #include +#include /* xref is used to create relation between two elements. * Once an element is released, it breaks the relation. If the @@ -11,12 +39,6 @@ * The pointer and the type of elements a and b are conventional. */ -struct xref { - struct xref *peer; -}; - -#define XREF_BUSY ((struct xref *)1) - static inline void xref_create(struct xref *xref_a, struct xref *xref_b) { xref_a->peer = xref_b; @@ -81,4 +103,4 @@ static inline void xref_disconnect(struct xref *xref, struct xref *peer) xref->peer = NULL; } -#endif /* __XREF_H__ */ +#endif /* __HAPROXY_XREF_H__ */ diff --git a/include/types/applet.h b/include/types/applet.h index 7b21f9ab3..d6b34a373 100644 --- a/include/types/applet.h +++ b/include/types/applet.h @@ -26,11 +26,11 @@ #include #include #include +#include #include #include #include #include -#include struct appctx; diff --git a/include/types/hlua.h b/include/types/hlua.h index 10a33036c..990f9bc71 100644 --- a/include/types/hlua.h +++ b/include/types/hlua.h @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include diff --git a/src/hlua.c b/src/hlua.c index 5513a7dcd..0a3362a30 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include