Skip to contentSkip to conversation

Make qemu-nbd compile on OS X

PATCH Daniel P. Berrange 3 participants 3 messages Jun 2, 2008 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 8 lines · C.W. Betts

The following is a patch to make qemu-nbd compile on Mac OS X Leopard (any other versions are untested)

Index: qemu-nbd.c
===================================================================

qemu-nbd.c line 28

Quoted 8 lines
qemu-nbd.c +4 -0
@@ -21,7 +21,11 @@
 #include "block_int.h"
 #include "nbd.h"
 
+#ifdef __APPLE__
+#include <malloc/malloc.h>
+#else
 #include <malloc.h>
+#endif

The include of malloc.h looks rather bogus to me. malloc() is part of stdlib.h, and is not even used in this file anyway. It compiles fine on Linux if you remove include of malloc.h entirely

Regards,
Daniel.

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#2 lore raw
Quoted 12 lines · Daniel P. Berrange
Quoted 11 lines · C.W. Betts

The following is a patch to make qemu-nbd compile on Mac OS X Leopard (any other versions are untested)

Index: qemu-nbd.c
===================================================================

qemu-nbd.c +0 -0
@@ -21,7 +21,11 @@
 #include "block_int.h"
 #include "nbd.h"
 
Quoted 10 lines

qemu-nbd.c line 28

Quoted 5 lines
qemu-nbd.c +4 -0
+#ifdef __APPLE__
+#include <malloc/malloc.h>
+#else
 #include <malloc.h>
+#endif

The include of malloc.h looks rather bogus to me. malloc() is part of stdlib.h, and is not even used in this file anyway. It compiles fine on Linux if you remove include of malloc.h entirely

I agree, "man malloc" on MacOS X gives:

"MALLOC(3) BSD Library Functions Manual MALLOC(3)

NAME
malloc, calloc, valloc, realloc, reallocf, free, malloc_size, malloc_good_size -- memory allocation

SYNOPSIS

     #include <stdlib.h>

..."

Laurent

----------------------- Laurent Vivier ---------------------- "The best way to predict the future is to invent it."
- Alan Kay

#3 lore raw
In reply to Daniel P. Berrange

In message: <[email protected]>
"Daniel P. Berrange" <[email protected]> writes:
: On Mon, Jun 02, 2008 at 11:44:17AM -0600, C.W. Betts wrote:
: > The following is a patch to make qemu-nbd compile on Mac OS X Leopard : > (any other versions are untested)
: >
: > Index: qemu-nbd.c
: > ===================================================================
: > --- qemu-nbd.c (revision 4654)
: > +++ qemu-nbd.c (working copy)
: > @@ -21,7 +21,11 @@
: > #include "block_int.h"
: > #include "nbd.h"
: >
: > +#ifdef __APPLE__
: > +#include <malloc/malloc.h>
: > +#else
: > #include <malloc.h>
: > +#endif
:
:
: The include of malloc.h looks rather bogus to me. malloc() is part : of stdlib.h, and is not even used in this file anyway. It compiles fine : on Linux if you remove include of malloc.h entirely

Yes. Years ago, malloc.h was typically needed for SunOS 4.x compatibility. Once malloc was codified to live in stdlib.h, malloc.h was deprecated.

Warner