Open MPI logo

Hardware Locality Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Hardware Locality Development mailing list

Subject: [hwloc-devel] Use of <malloc.h>
From: Jeff Squyres (jsquyres) (jsquyres_at_[hidden])
Date: 2014-01-10 11:34:57

Brice / Samuel --

In, Paul Hargrove found this compiler warning:

On OpenBSD the header malloc.h exists, but is NOT intended to be used:
-bash-4.2$ grep -B2 'is obsolete' make.log
  CC bind.lo
In file included from /home/phargrov/OMPI/openmpi-1.7-latest-openbsd5-amd64/openmpi-1.7.4rc2r30168/opal/mca/hwloc/hwloc172/hwloc/src/bind.c:17:
/usr/include/malloc.h:4:2: warning: #warning "<malloc.h> is obsolete, use <stdlib.h>"

What do you think of this patch (or something like it)?

diff --git a/src/bind.c b/src/bind.c
index 046b7cf..37921bc 100644
--- a/src/bind.c
+++ b/src/bind.c
@@ -13,8 +13,9 @@
 # include <sys/mman.h>
-# include <malloc.h>
+/* <malloc.h> is only needed if we don't have posix_memalign() */
+#if defined(hwloc_getpagesize) && !defined(HAVE_POSIX_MEMALIGN) && defined(HAVE_MEMALIGN) && defined(HAVE_MALLOC_H)
+#include <malloc.h>
 #include <unistd.h>

Jeff Squyres
For corporate legal information go to: