From owner-svn-src-head@freebsd.org Tue Jul 24 16:31:17 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CC3A8104FF1D; Tue, 24 Jul 2018 16:31:17 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A0ABF75959; Tue, 24 Jul 2018 16:31:17 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 68107607D; Tue, 24 Jul 2018 16:31:17 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6OGVHnI029879; Tue, 24 Jul 2018 16:31:17 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6OGVHUt029877; Tue, 24 Jul 2018 16:31:17 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201807241631.w6OGVHUt029877@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Tue, 24 Jul 2018 16:31:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336674 - in head: share/man/man9 sys/net X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: in head: share/man/man9 sys/net X-SVN-Commit-Revision: 336674 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jul 2018 16:31:18 -0000 Author: andrew Date: Tue Jul 24 16:31:16 2018 New Revision: 336674 URL: https://svnweb.freebsd.org/changeset/base/336674 Log: 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 Modified: head/share/man/man9/vnet.9 head/sys/net/vnet.h Modified: head/share/man/man9/vnet.9 ============================================================================== --- head/share/man/man9/vnet.9 Tue Jul 24 15:42:23 2018 (r336673) +++ head/share/man/man9/vnet.9 Tue Jul 24 16:31:16 2018 (r336674) @@ -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 Modified: head/sys/net/vnet.h ============================================================================== --- head/sys/net/vnet.h Tue Jul 24 15:42:23 2018 (r336673) +++ head/sys/net/vnet.h Tue Jul 24 16:31:16 2018 (r336674) @@ -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) /*