* [PATCH] HPUX: fix dlmalloc build
@ 2010-12-30 11:04 Oren Held
2010-12-30 16:58 ` Oren Held
0 siblings, 1 reply; 3+ messages in thread
From: Oren Held @ 2010-12-30 11:04 UTC (permalink / raw)
To: libffi-discuss; +Cc: Oren Held
Prevent redefinition of struct mallinfo in HPUX.
HPUX' /usr/include/stdlib.h redefines this struct, unless _STRUCT_MALLINFO is
defined.
---
src/dlmalloc.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/dlmalloc.c b/src/dlmalloc.c
index 0fa235a..5c9f9c2 100644
--- a/src/dlmalloc.c
+++ b/src/dlmalloc.c
@@ -622,6 +622,9 @@ DEFAULT_MMAP_THRESHOLD default: 256K
#include "/usr/include/malloc.h"
#else /* HAVE_USR_INCLUDE_MALLOC_H */
+/* HP-UX's stdlib.h redefines mallinfo unless _STRUCT_MALLINFO is defined */
+#define _STRUCT_MALLINFO
+
struct mallinfo {
MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */
MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */
--
1.7.2.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] HPUX: fix dlmalloc build
2010-12-30 11:04 [PATCH] HPUX: fix dlmalloc build Oren Held
@ 2010-12-30 16:58 ` Oren Held
2011-02-08 15:51 ` Anthony Green
0 siblings, 1 reply; 3+ messages in thread
From: Oren Held @ 2010-12-30 16:58 UTC (permalink / raw)
To: libffi-discuss
Hello,
A bit more explanation which I meant to add:
The starting point is that 'gmake src/dlmalloc.c' fails to compile on
HP-UX, in my case it's v11.31 ia64.
It fails because of re-declaration of 'struct mallinfo', both defined in
dlmalloc.c and in /usr/include/stdlib.h:
=========================
bash-4.0# gmake src/dlmalloc.o
gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g
-fexceptions -O2 -MT src/dlmalloc.o -MD -MP -MF $depbase.Tpo -c -o
src/dlmalloc.o src/dlmalloc.c
In file included from src/dlmalloc.c:1164:
/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/include/stdlib.h:579: error:
redefinition of 'struct mallinfo'
gmake: *** [src/dlmalloc.o] Error 1
=========================
Now, there are two approaches to resolve this:
1. Take struct definition from /usr/include/stdlib.h: by defining
HAVE_USR_INCLUDE_MALLOC_H in src/dlmalloc.c (there's actually a detailed
comment which explains that in the file)
2. Take struct definition from dlmalloc.c: this needs defining
_STRUCT_MALLINFO to avoid re-definition. HP-UX, unlike many other OSes,
defines 'struct mallinfo' in its /usr/include/stdlib.h, if a special
constant named _STRUCT_MALLINFO is not defined.
My goal was to handle this automatically.
I can think of three options, but not sure what's the smartest way:
1. If we prefer the OS native mallinfo declaration: have autoconf add
#define HAVE_USR_INCLUDE_MALLOC_H if it's an HP that has 'struct
malloc' in its /usr/include/stdlib.h
2. If we prefer the libffi (dlmalloc.c) mallinfo decleration:
2.a. Simply add #define _STRUCT_MALLINFO inside dlmalloc.c, in the block
that declares the mallinfo struct. There's a very low risk that this
constant would affect other OSes badly and cause the problem.
2.b. Do the above only for HPUX - probably needs an autoconf change.
The previously attached patch is the #2.a. solution. I'm not familiar
with autoconf, and I'm not very sure which 'struct mallinfo'
impementation to prefer, thus I didn't implement solution #1 or #2.b.
Regards
Oren
On 12/30/2010 01:04 PM, Oren Held wrote:
> Prevent redefinition of struct mallinfo in HPUX.
> HPUX' /usr/include/stdlib.h redefines this struct, unless _STRUCT_MALLINFO is
> defined.
> ---
> src/dlmalloc.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/src/dlmalloc.c b/src/dlmalloc.c
> index 0fa235a..5c9f9c2 100644
> --- a/src/dlmalloc.c
> +++ b/src/dlmalloc.c
> @@ -622,6 +622,9 @@ DEFAULT_MMAP_THRESHOLD default: 256K
> #include "/usr/include/malloc.h"
> #else /* HAVE_USR_INCLUDE_MALLOC_H */
>
> +/* HP-UX's stdlib.h redefines mallinfo unless _STRUCT_MALLINFO is defined */
> +#define _STRUCT_MALLINFO
> +
> struct mallinfo {
> MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */
> MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] HPUX: fix dlmalloc build
2010-12-30 16:58 ` Oren Held
@ 2011-02-08 15:51 ` Anthony Green
0 siblings, 0 replies; 3+ messages in thread
From: Anthony Green @ 2011-02-08 15:51 UTC (permalink / raw)
To: Oren Held; +Cc: libffi-discuss
Oren Held <orenhe@il.ibm.com> writes:
> I can think of three options, but not sure what's the smartest way:
> 1. If we prefer the OS native mallinfo declaration: have autoconf add
> #define HAVE_USR_INCLUDE_MALLOC_H if it's an HP that has 'struct
> malloc' in its /usr/include/stdlib.h
>
> 2. If we prefer the libffi (dlmalloc.c) mallinfo decleration:
> 2.a. Simply add #define _STRUCT_MALLINFO inside dlmalloc.c, in the block
> that declares the mallinfo struct. There's a very low risk that this
> constant would affect other OSes badly and cause the problem.
> 2.b. Do the above only for HPUX - probably needs an autoconf change.
>
> The previously attached patch is the #2.a. solution. I'm not familiar
> with autoconf, and I'm not very sure which 'struct mallinfo'
> impementation to prefer, thus I didn't implement solution #1 or #2.b.
I went with 2.a for now. I'll make a smarter patch if we discover any
problems while testing the next release.
Thanks!
AG
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-02-08 15:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-30 11:04 [PATCH] HPUX: fix dlmalloc build Oren Held
2010-12-30 16:58 ` Oren Held
2011-02-08 15:51 ` Anthony Green
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 read-only IMAP folder(s) and NNTP newsgroup(s).