* bug#18368: HYBRID_MALLOC broke AIX build
@ 2014-08-30 22:50 Paul Eggert
2014-08-31 1:41 ` Ken Brown
0 siblings, 1 reply; 4+ messages in thread
From: Paul Eggert @ 2014-08-30 22:50 UTC (permalink / raw)
To: 18368
The trunk's recent HYBRID_MALLOC changes broke the build on AIX. Here
are the first couple of compile-time diagnostics:
xlc -c -Demacs -I. -I. -I../lib -I../lib -g3 -O gmalloc.c
"/usr/include/unistd.h", line 201.17: 1506-343 (S) Redeclaration of
lseek64 differs from previous declaration on line 199 of
"/usr/include/unistd.h".
"/usr/include/unistd.h", line 201.17: 1506-050 (I) Return type "long
long" in redeclaration is not compatible with the previous return type
"long".
The culprit is this part of gmalloc.c:
/* If HYBRID_MALLOC is defined in config.h, then conf_post.h #defines
malloc and friends as macros before including stdlib.h. In this
file we will need the prototypes for the system malloc, so we must
include stdlib.h before config.h. And we have to do this
unconditionally, since HYBRID_MALLOC hasn't been defined yet. */
#include <stdlib.h>
#include <config.h>
This doesn't work, as <config.h> must come first for various reasons; I
suspect the AIX breakage is just the tip of the iceberg.
One possible fix is to declare the system malloc directly, if
HYBRID_MALLOC is defined. Another one, which might be safer, is to
modify config.h to capture the system malloc before it's redefined.
Since AIX does not define HYBRID_MALLOC, I have temporarily worked
around the problem on my AIX host by using this in gmalloc.c:
#ifdef HYBRID_MALLOC
#include <stdlib.h>
#endif
#include <config.h>
#include <stdlib.h>
but I suspect this is not the right way to fix the problems on platforms
that need HYBRID_MALLOC but have AIX-like problems with redefinitions.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#18368: HYBRID_MALLOC broke AIX build
2014-08-30 22:50 bug#18368: HYBRID_MALLOC broke AIX build Paul Eggert
@ 2014-08-31 1:41 ` Ken Brown
2014-08-31 2:21 ` Paul Eggert
0 siblings, 1 reply; 4+ messages in thread
From: Ken Brown @ 2014-08-31 1:41 UTC (permalink / raw)
To: Paul Eggert, 18368
On 8/30/2014 6:50 PM, Paul Eggert wrote:
> The trunk's recent HYBRID_MALLOC changes broke the build on AIX.
How's this:
=== modified file 'src/gmalloc.c'
--- src/gmalloc.c 2014-08-28 14:48:02 +0000
+++ src/gmalloc.c 2014-08-31 01:29:41 +0000
@@ -19,13 +19,6 @@
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
-/* If HYBRID_MALLOC is defined in config.h, then conf_post.h #defines
- malloc and friends as macros before including stdlib.h. In this
- file we will need the prototypes for the system malloc, so we must
- include stdlib.h before config.h. And we have to do this
- unconditionally, since HYBRID_MALLOC hasn't been defined yet. */
-#include <stdlib.h>
-
#include <config.h>
#if defined HAVE_PTHREAD && !defined HYBRID_MALLOC
@@ -1725,6 +1718,17 @@
#undef aligned_alloc
#undef free
+/* Declare system malloc and friends. */
+extern void *malloc (size_t size);
+extern void *realloc (void *ptr, size_t size);
+extern void *calloc (size_t nmemb, size_t size);
+extern void free (void *ptr);
+#ifdef HAVE_ALIGNED_ALLOC
+extern void *aligned_alloc (size_t alignment, size_t size);
+#elif defined HAVE_POSIX_MEMALIGN
+extern int posix_memalign (void **memptr, size_t alignment, size_t size);
+#endif
+
/* See the comments near the beginning of this file for explanations
of the following functions. */
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#18368: HYBRID_MALLOC broke AIX build
2014-08-31 1:41 ` Ken Brown
@ 2014-08-31 2:21 ` Paul Eggert
2014-08-31 2:42 ` Ken Brown
0 siblings, 1 reply; 4+ messages in thread
From: Paul Eggert @ 2014-08-31 2:21 UTC (permalink / raw)
To: Ken Brown, 18368
Ken Brown wrote:
> How's this:
Thanks, I verified that that patch works on AIX.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#18368: HYBRID_MALLOC broke AIX build
2014-08-31 2:21 ` Paul Eggert
@ 2014-08-31 2:42 ` Ken Brown
0 siblings, 0 replies; 4+ messages in thread
From: Ken Brown @ 2014-08-31 2:42 UTC (permalink / raw)
To: Paul Eggert, 18368-done
Version: 24.5
On 8/30/2014 10:21 PM, Paul Eggert wrote:
> Thanks, I verified that that patch works on AIX.
I've installed the patch in the trunk as bzr revision 117787.
Ken
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-31 2:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-30 22:50 bug#18368: HYBRID_MALLOC broke AIX build Paul Eggert
2014-08-31 1:41 ` Ken Brown
2014-08-31 2:21 ` Paul Eggert
2014-08-31 2:42 ` Ken Brown
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).