qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock)
@ 2008-11-22 20:43 Blue Swirl
  2008-11-23  9:10 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Blue Swirl @ 2008-11-22 20:43 UTC (permalink / raw)
  To: qemu-devel

Revision: 5778
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5778
Author:   blueswir1
Date:     2008-11-22 20:43:01 +0000 (Sat, 22 Nov 2008)

Log Message:
-----------
Use MAP_ANON also for FreeBSD (Juergen Lock)

Modified Paths:
--------------
    trunk/osdep.c

Modified: trunk/osdep.c
===================================================================
--- trunk/osdep.c	2008-11-22 20:34:45 UTC (rev 5777)
+++ trunk/osdep.c	2008-11-22 20:43:01 UTC (rev 5778)
@@ -75,8 +75,10 @@
 #include <sys/types.h>
 #include <sys/mount.h>
 #else
+#ifndef __FreeBSD__
 #include <sys/vfs.h>
 #endif
+#endif
 
 #include <sys/mman.h>
 #include <fcntl.h>
@@ -87,7 +89,8 @@
     static int phys_ram_size = 0;
     void *ptr;
 
-#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
+/* no need (?) for a dummy file on OpenBSD/FreeBSD */
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
     int map_anon = MAP_ANON;
 #else
     int map_anon = 0;
@@ -154,7 +157,7 @@
     }
     size = (size + 4095) & ~4095;
     ftruncate(phys_ram_fd, phys_ram_size + size);
-#endif /* !__OpenBSD__ */
+#endif /* !(__OpenBSD__ || __FreeBSD__) */
     ptr = mmap(NULL,
                size,
                PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock)
  2008-11-22 20:43 [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock) Blue Swirl
@ 2008-11-23  9:10 ` Christoph Hellwig
  2008-11-24 10:44   ` Christoph Egger
  2008-11-23 10:03 ` Jamie Lokier
  2008-11-24  9:35 ` Christoph Egger
  2 siblings, 1 reply; 12+ messages in thread
From: Christoph Hellwig @ 2008-11-23  9:10 UTC (permalink / raw)
  To: qemu-devel

On Sat, Nov 22, 2008 at 08:43:01PM +0000, Blue Swirl wrote:
> -#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
> +/* no need (?) for a dummy file on OpenBSD/FreeBSD */
> +#if defined(__OpenBSD__) || defined(__FreeBSD__)

The same is true for Linux, btw.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock)
  2008-11-22 20:43 [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock) Blue Swirl
  2008-11-23  9:10 ` Christoph Hellwig
@ 2008-11-23 10:03 ` Jamie Lokier
  2008-11-23 12:00   ` Christoph Hellwig
  2008-11-24  9:35 ` Christoph Egger
  2 siblings, 1 reply; 12+ messages in thread
From: Jamie Lokier @ 2008-11-23 10:03 UTC (permalink / raw)
  To: qemu-devel

Blue Swirl wrote:
> -#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
> +/* no need (?) for a dummy file on OpenBSD/FreeBSD */
> +#if defined(__OpenBSD__) || defined(__FreeBSD__)
>      int map_anon = MAP_ANON;
>  #else
>      int map_anon = 0;

How about, simply:

#ifdef MAP_ANON

(Btw, on some OSes it has the name MAP_ANONYMOUS, so in my own
portable code I look for both.)

-- Jamie

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock)
  2008-11-23 10:03 ` Jamie Lokier
@ 2008-11-23 12:00   ` Christoph Hellwig
  2008-11-23 12:41     ` Jamie Lokier
  0 siblings, 1 reply; 12+ messages in thread
From: Christoph Hellwig @ 2008-11-23 12:00 UTC (permalink / raw)
  To: qemu-devel

On Sun, Nov 23, 2008 at 10:03:10AM +0000, Jamie Lokier wrote:
> Blue Swirl wrote:
> > -#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
> > +/* no need (?) for a dummy file on OpenBSD/FreeBSD */
> > +#if defined(__OpenBSD__) || defined(__FreeBSD__)
> >      int map_anon = MAP_ANON;
> >  #else
> >      int map_anon = 0;
> 
> How about, simply:
> 
> #ifdef MAP_ANON
> 
> (Btw, on some OSes it has the name MAP_ANONYMOUS, so in my own
> portable code I look for both.)

I'm pretty sure there are OSes around that have MAP_ANON/MAP_ANONYMOUS
but don't support it in combination with MAP_SHARED.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock)
  2008-11-23 12:00   ` Christoph Hellwig
@ 2008-11-23 12:41     ` Jamie Lokier
  0 siblings, 0 replies; 12+ messages in thread
From: Jamie Lokier @ 2008-11-23 12:41 UTC (permalink / raw)
  To: qemu-devel

Christoph Hellwig wrote:
> I'm pretty sure there are OSes around that have MAP_ANON/MAP_ANONYMOUS
> but don't support it in combination with MAP_SHARED.

Sorry, I wasn't paying attention.  You're right, there are several
such OSes, and I believe Linux was one of them once.

-- Jamie (will pay closer attention in future...)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock)
  2008-11-22 20:43 [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock) Blue Swirl
  2008-11-23  9:10 ` Christoph Hellwig
  2008-11-23 10:03 ` Jamie Lokier
@ 2008-11-24  9:35 ` Christoph Egger
  2008-11-24 17:40   ` M. Warner Losh
  2 siblings, 1 reply; 12+ messages in thread
From: Christoph Egger @ 2008-11-24  9:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl

On Saturday 22 November 2008 21:43:01 Blue Swirl wrote:
> Revision: 5778
>           http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5778
> Author:   blueswir1
> Date:     2008-11-22 20:43:01 +0000 (Sat, 22 Nov 2008)
>
> Log Message:
> -----------
> Use MAP_ANON also for FreeBSD (Juergen Lock)

This is for *BSD in general.

> @@ -87,7 +89,8 @@
>      static int phys_ram_size = 0;
>      void *ptr;
>
> -#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
> +/* no need (?) for a dummy file on OpenBSD/FreeBSD */
> +#if defined(__OpenBSD__) || defined(__FreeBSD__)

This should be:

#ifdef _BSD

>      int map_anon = MAP_ANON;
>  #else
>      int map_anon = 0;
> @@ -154,7 +157,7 @@
>      }
>      size = (size + 4095) & ~4095;
>      ftruncate(phys_ram_fd, phys_ram_size + size);
> -#endif /* !__OpenBSD__ */
> +#endif /* !(__OpenBSD__ || __FreeBSD__) */

This should be

#endif /* !_BSD */

>      ptr = mmap(NULL,
>                 size,
>                 PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,



-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock)
  2008-11-23  9:10 ` Christoph Hellwig
@ 2008-11-24 10:44   ` Christoph Egger
  2008-11-24 11:07     ` Christoph Hellwig
  0 siblings, 1 reply; 12+ messages in thread
From: Christoph Egger @ 2008-11-24 10:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: Christoph Hellwig

On Sunday 23 November 2008 10:10:06 Christoph Hellwig wrote:
> On Sat, Nov 22, 2008 at 08:43:01PM +0000, Blue Swirl wrote:
> > -#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
> > +/* no need (?) for a dummy file on OpenBSD/FreeBSD */
> > +#if defined(__OpenBSD__) || defined(__FreeBSD__)
>
> The same is true for Linux, btw.

and NetBSD, too. and Solaris, too.

Actually, this is POSIX.
Therefore, the #if line should be turned into

#ifndef _WIN32

Christoph


-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock)
  2008-11-24 10:44   ` Christoph Egger
@ 2008-11-24 11:07     ` Christoph Hellwig
  2008-11-24 11:54       ` Christoph Egger
  0 siblings, 1 reply; 12+ messages in thread
From: Christoph Hellwig @ 2008-11-24 11:07 UTC (permalink / raw)
  To: Christoph Egger; +Cc: qemu-devel, Christoph Hellwig

On Mon, Nov 24, 2008 at 12:44:21PM +0200, Christoph Egger wrote:
> On Sunday 23 November 2008 10:10:06 Christoph Hellwig wrote:
> > On Sat, Nov 22, 2008 at 08:43:01PM +0000, Blue Swirl wrote:
> > > -#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
> > > +/* no need (?) for a dummy file on OpenBSD/FreeBSD */
> > > +#if defined(__OpenBSD__) || defined(__FreeBSD__)
> >
> > The same is true for Linux, btw.
> 
> and NetBSD, too. and Solaris, too.
> 
> Actually, this is POSIX.

MAP_ANON/MAP_ANONYMOUS are not in Posix. 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock)
  2008-11-24 11:07     ` Christoph Hellwig
@ 2008-11-24 11:54       ` Christoph Egger
  0 siblings, 0 replies; 12+ messages in thread
From: Christoph Egger @ 2008-11-24 11:54 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: qemu-devel

On Monday 24 November 2008 12:07:45 Christoph Hellwig wrote:
> On Mon, Nov 24, 2008 at 12:44:21PM +0200, Christoph Egger wrote:
> > On Sunday 23 November 2008 10:10:06 Christoph Hellwig wrote:
> > > On Sat, Nov 22, 2008 at 08:43:01PM +0000, Blue Swirl wrote:
> > > > -#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
> > > > +/* no need (?) for a dummy file on OpenBSD/FreeBSD */
> > > > +#if defined(__OpenBSD__) || defined(__FreeBSD__)
> > >
> > > The same is true for Linux, btw.
> >
> > and NetBSD, too. and Solaris, too.
> >
> > Actually, this is POSIX.
>
> MAP_ANON/MAP_ANONYMOUS are not in Posix.

MAP_ANONYMOUS is GNU, MAP_ANON is Unix at least.

Christoph


-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock)
  2008-11-24  9:35 ` Christoph Egger
@ 2008-11-24 17:40   ` M. Warner Losh
  2008-11-25 10:19     ` Christoph Egger
  0 siblings, 1 reply; 12+ messages in thread
From: M. Warner Losh @ 2008-11-24 17:40 UTC (permalink / raw)
  To: qemu-devel, Christoph.Egger; +Cc: blauwirbel

In message: <200811241035.06359.Christoph.Egger@amd.com>
            Christoph Egger <Christoph.Egger@amd.com> writes:
: On Saturday 22 November 2008 21:43:01 Blue Swirl wrote:
: > Revision: 5778
: >           http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5778
: > Author:   blueswir1
: > Date:     2008-11-22 20:43:01 +0000 (Sat, 22 Nov 2008)
: >
: > Log Message:
: > -----------
: > Use MAP_ANON also for FreeBSD (Juergen Lock)
: 
: This is for *BSD in general.
: 
: > @@ -87,7 +89,8 @@
: >      static int phys_ram_size = 0;
: >      void *ptr;
: >
: > -#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
: > +/* no need (?) for a dummy file on OpenBSD/FreeBSD */
: > +#if defined(__OpenBSD__) || defined(__FreeBSD__)
: 
: This should be:
: 
: #ifdef _BSD

What defines _BSD?  It is in the compiler's name space, but _BSD isn't
defined by the compiler...

Warner

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock)
  2008-11-24 17:40   ` M. Warner Losh
@ 2008-11-25 10:19     ` Christoph Egger
  2008-11-28 20:02       ` Stuart Brady
  0 siblings, 1 reply; 12+ messages in thread
From: Christoph Egger @ 2008-11-25 10:19 UTC (permalink / raw)
  To: M. Warner Losh; +Cc: blauwirbel, qemu-devel

On Monday 24 November 2008 18:40:56 M. Warner Losh wrote:
> In message: <200811241035.06359.Christoph.Egger@amd.com>
>
>             Christoph Egger <Christoph.Egger@amd.com> writes:
> : On Saturday 22 November 2008 21:43:01 Blue Swirl wrote:
> : > Revision: 5778
> : >          
> : > http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5778 Author: 
> : >  blueswir1
> : > Date:     2008-11-22 20:43:01 +0000 (Sat, 22 Nov 2008)
> : >
> : > Log Message:
> : > -----------
> : > Use MAP_ANON also for FreeBSD (Juergen Lock)
> :
> : This is for *BSD in general.
> :
> : > @@ -87,7 +89,8 @@
> : >      static int phys_ram_size = 0;
> : >      void *ptr;
> : >
> : > -#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
> : > +/* no need (?) for a dummy file on OpenBSD/FreeBSD */
> : > +#if defined(__OpenBSD__) || defined(__FreeBSD__)
> :
> : This should be:
> :
> : #ifdef _BSD
>
> What defines _BSD? It is in the compiler's name space, but _BSD isn't 
> defined by the compiler...

config-host.h generated by configure.

Christoph

-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock)
  2008-11-25 10:19     ` Christoph Egger
@ 2008-11-28 20:02       ` Stuart Brady
  0 siblings, 0 replies; 12+ messages in thread
From: Stuart Brady @ 2008-11-28 20:02 UTC (permalink / raw)
  To: qemu-devel

On Tue, Nov 25, 2008 at 12:19:29PM +0200, Christoph Egger wrote:
> On Monday 24 November 2008 18:40:56 M. Warner Losh wrote:
> 
> > What defines _BSD? It is in the compiler's name space, but _BSD isn't 
> > defined by the compiler...
> 
> config-host.h generated by configure.

Hmm, why don't we have CONFIG_BSD?  (We have CONFIG_WIN32,
CONFIG_DARWIN, CONFIG_AIX and HOST_SOLARIS...)
-- 
Stuart Brady

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-11-28 20:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-22 20:43 [Qemu-devel] [5778] Use MAP_ANON also for FreeBSD (Juergen Lock) Blue Swirl
2008-11-23  9:10 ` Christoph Hellwig
2008-11-24 10:44   ` Christoph Egger
2008-11-24 11:07     ` Christoph Hellwig
2008-11-24 11:54       ` Christoph Egger
2008-11-23 10:03 ` Jamie Lokier
2008-11-23 12:00   ` Christoph Hellwig
2008-11-23 12:41     ` Jamie Lokier
2008-11-24  9:35 ` Christoph Egger
2008-11-24 17:40   ` M. Warner Losh
2008-11-25 10:19     ` Christoph Egger
2008-11-28 20:02       ` Stuart Brady

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).