Patchwork [1/3] Add FreeBSD/ppc host ppc_init_cacheline_sizes() implementation.

login
register
mail settings
Submitter Juergen Lock
Date Feb. 14, 2010, 8:12 p.m.
Message ID <20100214201209.GA97896@triton8.kn-bremen.de>
Download mbox | patch
Permalink /patch/45336/
State New
Headers show

Comments

Juergen Lock - Feb. 14, 2010, 8:12 p.m.
Submitted by: Andreas Tobler <andreast@fgznet.ch>

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
malc - Feb. 15, 2010, 3:15 a.m.
On Sun, 14 Feb 2010, Juergen Lock wrote:

> Submitted by: Andreas Tobler <andreast@fgznet.ch>
> 
> Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
> 
> --- a/cache-utils.c
> +++ b/cache-utils.c
> @@ -57,6 +57,23 @@
>  }
>  #endif
>  
> +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
> +#include <stdio.h>
> +#include <sys/types.h>
> +#include <sys/sysctl.h>
> +
> +static void ppc_init_cacheline_sizes(void)
> +{
> +    size_t len = 4;
> +    unsigned cacheline;
> +
> +    sysctlbyname ("machdep.cacheline_size", &cacheline, &len, NULL, 0);

Error handling missing.

> +
> +    qemu_cache_conf.dcache_bsize = cacheline;
> +    qemu_cache_conf.icache_bsize = cacheline;
> +}
> +#endif    
> +
>  #ifdef __linux__
>  void qemu_cache_utils_init(char **envp)
>  {
> 
>
malc - Feb. 15, 2010, 3:16 a.m.
On Sun, 14 Feb 2010, Juergen Lock wrote:

> Submitted by: Andreas Tobler <andreast@fgznet.ch>
> 
> Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
> 
> --- a/cache-utils.c
> +++ b/cache-utils.c
> @@ -57,6 +57,23 @@
>  }
>  #endif
>  
> +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)

__FreeBSD_kernel__ is for something like Debian/kFreeBSD?

> +#include <stdio.h>
> +#include <sys/types.h>
> +#include <sys/sysctl.h>
> +
> +static void ppc_init_cacheline_sizes(void)
> +{
> +    size_t len = 4;
> +    unsigned cacheline;
> +
> +    sysctlbyname ("machdep.cacheline_size", &cacheline, &len, NULL, 0);
> +
> +    qemu_cache_conf.dcache_bsize = cacheline;
> +    qemu_cache_conf.icache_bsize = cacheline;
> +}
> +#endif    
> +
>  #ifdef __linux__
>  void qemu_cache_utils_init(char **envp)
>  {
> 
>
Juergen Lock - Feb. 15, 2010, 10:40 p.m.
On Mon, Feb 15, 2010 at 06:16:07AM +0300, malc wrote:
> On Sun, 14 Feb 2010, Juergen Lock wrote:
> 
> > Submitted by: Andreas Tobler <andreast@fgznet.ch>
> > 
> > Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
> > 
> > --- a/cache-utils.c
> > +++ b/cache-utils.c
> > @@ -57,6 +57,23 @@
> >  }
> >  #endif
> >  
> > +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
> 
> __FreeBSD_kernel__ is for something like Debian/kFreeBSD?

Yep, it is.  Support for it was added to qemu some time ago so I
figured I should do the same.

 Cheers,
	Juergen
malc - Feb. 16, 2010, 6:52 a.m.
On Mon, 15 Feb 2010, Juergen Lock wrote:

> On Mon, Feb 15, 2010 at 06:16:07AM +0300, malc wrote:
> > On Sun, 14 Feb 2010, Juergen Lock wrote:
> > 
> > > Submitted by: Andreas Tobler <andreast@fgznet.ch>
> > > 
> > > Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
> > > 
> > > --- a/cache-utils.c
> > > +++ b/cache-utils.c
> > > @@ -57,6 +57,23 @@
> > >  }
> > >  #endif
> > >  
> > > +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
> > 
> > __FreeBSD_kernel__ is for something like Debian/kFreeBSD?
> 
> Yep, it is.  Support for it was added to qemu some time ago so I
> figured I should do the same.
> 

Perhaps it would be better to avoid this particular ifdefery and
just go with _CALL_SYSV, can you verify that:

~$ gcc -E -dM -x c /dev/null | grep SYSV

yields

#define _CALL_SYSV 1

on FreeBSD and Debian/kFreeBSD?
Juergen Lock - Feb. 16, 2010, 5:56 p.m.
On Tue, Feb 16, 2010 at 09:52:50AM +0300, malc wrote:
> On Mon, 15 Feb 2010, Juergen Lock wrote:
> 
> > On Mon, Feb 15, 2010 at 06:16:07AM +0300, malc wrote:
> > > On Sun, 14 Feb 2010, Juergen Lock wrote:
> > > 
> > > > Submitted by: Andreas Tobler <andreast@fgznet.ch>
> > > > 
> > > > Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
> > > > 
> > > > --- a/cache-utils.c
> > > > +++ b/cache-utils.c
> > > > @@ -57,6 +57,23 @@
> > > >  }
> > > >  #endif
> > > >  
> > > > +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
> > > 
> > > __FreeBSD_kernel__ is for something like Debian/kFreeBSD?
> > 
> > Yep, it is.  Support for it was added to qemu some time ago so I
> > figured I should do the same.
> > 
> 
> Perhaps it would be better to avoid this particular ifdefery and
> just go with _CALL_SYSV, can you verify that:
> 
> ~$ gcc -E -dM -x c /dev/null | grep SYSV
> 
> yields
> 
> #define _CALL_SYSV 1
> 
> on FreeBSD and Debian/kFreeBSD?

Nope, not found on FreeBSD.  (Also I would kinda doubt that sysctl is
standardized?)

 Cheers,
	Juergen
malc - Feb. 16, 2010, 7:07 p.m.
On Tue, 16 Feb 2010, Juergen Lock wrote:

> On Tue, Feb 16, 2010 at 09:52:50AM +0300, malc wrote:
> > On Mon, 15 Feb 2010, Juergen Lock wrote:
> > 
> > > On Mon, Feb 15, 2010 at 06:16:07AM +0300, malc wrote:
> > > > On Sun, 14 Feb 2010, Juergen Lock wrote:
> > > > 
> > > > > Submitted by: Andreas Tobler <andreast@fgznet.ch>
> > > > > 
> > > > > Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
> > > > > 
> > > > > --- a/cache-utils.c
> > > > > +++ b/cache-utils.c
> > > > > @@ -57,6 +57,23 @@
> > > > >  }
> > > > >  #endif
> > > > >  
> > > > > +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
> > > > 
> > > > __FreeBSD_kernel__ is for something like Debian/kFreeBSD?
> > > 
> > > Yep, it is.  Support for it was added to qemu some time ago so I
> > > figured I should do the same.
> > > 
> > 
> > Perhaps it would be better to avoid this particular ifdefery and
> > just go with _CALL_SYSV, can you verify that:
> > 
> > ~$ gcc -E -dM -x c /dev/null | grep SYSV
> > 
> > yields
> > 
> > #define _CALL_SYSV 1
> > 
> > on FreeBSD and Debian/kFreeBSD?
> 
> Nope, not found on FreeBSD.  (Also I would kinda doubt that sysctl is
> standardized?)

_CALL_SYSV means that calling convention is SysV one, nothing to do with
sysctl, and i wanted you/patch author to run it on FreeBSD/PPC...
Paolo Bonzini - Feb. 16, 2010, 7:50 p.m.
>> Nope, not found on FreeBSD.  (Also I would kinda doubt that sysctl is
>> standardized?)
>
> _CALL_SYSV means that calling convention is SysV one, nothing to do with
> sysctl, and i wanted you/patch author to run it on FreeBSD/PPC...

Yes, one of _CALL_SYSV, _CALL_AIX, _CALL_DARWIN is always defined by GCC 
on PPC.  Don't know about other compilers.

Paolo
Juergen Lock - Feb. 16, 2010, 8:34 p.m.
On Tue, Feb 16, 2010 at 08:50:49PM +0100, Paolo Bonzini wrote:
> 
> >> Nope, not found on FreeBSD.  (Also I would kinda doubt that sysctl is
> >> standardized?)
> >
> > _CALL_SYSV means that calling convention is SysV one, nothing to do with
> > sysctl, and i wanted you/patch author to run it on FreeBSD/PPC...
> 
> Yes, one of _CALL_SYSV, _CALL_AIX, _CALL_DARWIN is always defined by GCC 
> on PPC.  Don't know about other compilers.

Aaah, now I understand, malc meant this patch:
	[PATCH 3/3] Add FreeBSD/ppc host
	 TCG_TARGET_CALL_{ALIGN_ARGS,STACK_OFFSET} definitions.
not the ppc_init_cacheline_sizes() one, right? :)

 Anyway, I'll pass the question on...
	Juergen
Juergen Lock - Feb. 16, 2010, 9:19 p.m.
On Tue, Feb 16, 2010 at 09:34:12PM +0100, Juergen Lock wrote:
> On Tue, Feb 16, 2010 at 08:50:49PM +0100, Paolo Bonzini wrote:
> > 
> > >> Nope, not found on FreeBSD.  (Also I would kinda doubt that sysctl is
> > >> standardized?)
> > >
> > > _CALL_SYSV means that calling convention is SysV one, nothing to do with
> > > sysctl, and i wanted you/patch author to run it on FreeBSD/PPC...
> > 
> > Yes, one of _CALL_SYSV, _CALL_AIX, _CALL_DARWIN is always defined by GCC 
> > on PPC.  Don't know about other compilers.
> 
> Aaah, now I understand, malc meant this patch:
> 	[PATCH 3/3] Add FreeBSD/ppc host
> 	 TCG_TARGET_CALL_{ALIGN_ARGS,STACK_OFFSET} definitions.
> not the ppc_init_cacheline_sizes() one, right? :)
> 
>  Anyway, I'll pass the question on...

Yup, confirmed, _CALL_SYSV is defined on FreeBSD/ppc.

Patch

--- a/cache-utils.c
+++ b/cache-utils.c
@@ -57,6 +57,23 @@ 
 }
 #endif
 
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+static void ppc_init_cacheline_sizes(void)
+{
+    size_t len = 4;
+    unsigned cacheline;
+
+    sysctlbyname ("machdep.cacheline_size", &cacheline, &len, NULL, 0);
+
+    qemu_cache_conf.dcache_bsize = cacheline;
+    qemu_cache_conf.icache_bsize = cacheline;
+}
+#endif    
+
 #ifdef __linux__
 void qemu_cache_utils_init(char **envp)
 {