From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzKdd-00020B-Om for qemu-devel@nongnu.org; Mon, 01 Jun 2015 04:00:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YzKdY-0001fM-Oq for qemu-devel@nongnu.org; Mon, 01 Jun 2015 04:00:01 -0400 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:36061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzKdY-0001fE-Hq for qemu-devel@nongnu.org; Mon, 01 Jun 2015 03:59:56 -0400 Received: by wibdq8 with SMTP id dq8so20796954wib.1 for ; Mon, 01 Jun 2015 00:59:55 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <556C10F2.9080607@redhat.com> Date: Mon, 01 Jun 2015 09:59:46 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC v2 14/34] cpu-defs: Allow multiple inclusions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, rth@twiddle.net, edgar.iglesias@gmail.com, afaerber@suse.de, Peter Crosthwaite On 31/05/2015 08:11, Peter Crosthwaite wrote: > Allow subsequent inclusion of cpu-defs.h. This allows including > multiple cpu.h's and each getting the right set of definitions for > its env structure definition. All define symbols are undeffed and > redeffed to the new values. > > CPUTLBEntry and CPUIOTLBEntry need to be renamed via #define by > the caller to avoid namespace collisions. Please document these things (#undeffing of preprocessor symbols and what needs to be renamed) in the header. Also the same is true for include/exec/target-long.h---where additionally I am not sure about how you'd deal with a redefined typedef. Some compilers flag it as an error even if the source type is the same. Paolo > Signed-off-by: Peter Crosthwaite > --- > include/exec/cpu-defs.h | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h > index a1c418f..6b59e58 100644 > --- a/include/exec/cpu-defs.h > +++ b/include/exec/cpu-defs.h > @@ -16,8 +16,10 @@ > * You should have received a copy of the GNU Lesser General Public > * License along with this library; if not, see . > */ > -#ifndef CPU_DEFS_H > -#define CPU_DEFS_H > + > +/* No multiple include guard intended. Multi-arch setups may require multiple > + * cpu.h's included which means this can be and should be reached twice. > + */ > > #ifndef NEED_CPU_H > #error cpu.h included from common code > @@ -34,12 +36,19 @@ > > #include "exec/target-long.h" > > +#undef CPU_COMMON > +#undef CPU_COMMON_TLB > + > #if !defined(CONFIG_USER_ONLY) > +#undef CPU_TLB_BITS > +#undef CPU_TLB_SIZE > +#undef CPU_VTLB_SIZE > #define CPU_TLB_BITS 8 > #define CPU_TLB_SIZE (1 << CPU_TLB_BITS) > /* use a fully associative victim tlb of 8 entries */ > #define CPU_VTLB_SIZE 8 > > +#undef CPU_TLB_ENTRY_BITS > #if HOST_LONG_BITS == 32 && TARGET_LONG_BITS == 32 > #define CPU_TLB_ENTRY_BITS 4 > #else > @@ -100,4 +109,3 @@ typedef struct CPUIOTLBEntry { > /* soft mmu support */ \ > CPU_COMMON_TLB \ > > -#endif >