As with DPCPU create VNET_DEFINE_STATIC for when a variable needs to be

declaired static. This will allow us to change the definition on arm64
as it has the same issues described in r336349.

Reviewed by:	bz
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D16147
This commit is contained in:
andrew 2018-07-24 16:31:16 +00:00
parent 9df38bfa1f
commit 65d35e69cb
2 changed files with 20 additions and 6 deletions

View File

@ -66,6 +66,10 @@
.Fa "type" "name"
.Fc
.\"
.Fo VNET_DEFINE_STATIC
.Fa "type" "name"
.Fc
.\"
.Bd -literal
#define V_name VNET(name)
.Ed
@ -208,11 +212,15 @@ Variables are virtualized by using the
.Fn VNET_DEFINE
macro rather than writing them out as
.Em type name .
One can still use static initialization or storage class specifiers, e.g.,
One can still use static initialization, e.g.,
.Pp
.Dl Li static VNET_DEFINE(int, foo) = 1;
or
.Dl Li static VNET_DEFINE(SLIST_HEAD(, bar), bars);
.Dl Li VNET_DEFINE(int, foo) = 1;
.Pp
Variables declared with the static keyword can use the
.Fn VNET_DEFINE_STATIC
macro, e.g.,
.Pp
.Dl Li VNET_DEFINE_STATIC(SLIST_HEAD(, bar), bars);
.Pp
Static initialization is not possible when the virtualized variable
would need to be referenced, e.g., with

View File

@ -93,6 +93,8 @@ struct vnet {
#define VNET_PCPUSTAT_DEFINE(type, name) \
VNET_DEFINE(counter_u64_t, name[sizeof(type) / sizeof(uint64_t)])
#define VNET_PCPUSTAT_DEFINE_STATIC(type, name) \
VNET_DEFINE_STATIC(counter_u64_t, name[sizeof(type) / sizeof(uint64_t)])
#define VNET_PCPUSTAT_ALLOC(name, wait) \
COUNTER_ARRAY_ALLOC(VNET(name), \
@ -268,7 +270,10 @@ extern struct sx vnet_sxlock;
*/
#define VNET_NAME(n) vnet_entry_##n
#define VNET_DECLARE(t, n) extern t VNET_NAME(n)
#define VNET_DEFINE(t, n) t VNET_NAME(n) __section(VNET_SETNAME) __used
#define VNET_DEFINE(t, n) \
t VNET_NAME(n) __section(VNET_SETNAME) __used
#define VNET_DEFINE_STATIC(t, n) \
static t VNET_NAME(n) __section(VNET_SETNAME) __used
#define _VNET_PTR(b, n) (__typeof(VNET_NAME(n))*) \
((b) + (uintptr_t)&VNET_NAME(n))
@ -400,7 +405,8 @@ do { \
*/
#define VNET_NAME(n) n
#define VNET_DECLARE(t, n) extern t n
#define VNET_DEFINE(t, n) t n
#define VNET_DEFINE(t, n) struct _hack; t n
#define VNET_DEFINE_STATIC(t, n) static t n
#define _VNET_PTR(b, n) &VNET_NAME(n)
/*