develooper Front page | perl.perl6.internals | Postings from September 2005

[perl #37155] compiler warning - missing prototype for posix_memalign()

From:
Joshua Hoblitt
Date:
September 13, 2005 02:58
Subject:
[perl #37155] compiler warning - missing prototype for posix_memalign()
Message ID:
rt-3.0.11-37155-120677.12.7999544526003@perl.org
# New Ticket Created by  Joshua Hoblitt 
# Please include the string:  [perl #37155]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37155 >


Building with revision r9190 I get the following warning.

--
config/gen/platform/generic/memalign.c: In function `Parrot_memalign':
config/gen/platform/generic/memalign.c:12: warning: implicit declaration of function `posix_memalign'
--

Which seemed odd, as I know my platform provides posix_memalign.  cpp
confirms that stdlib.h isn't providing the prototype.

--
$ cpp -DPARROT_HAS_POSIX_MEMALIGN config/gen/platform/generic/memalign.c | grep posix_memalign
    int i = posix_memalign(&p, align, size);
--

Which makes sense, as neither _XOPEN_SOURCE or _GNU_SOURCE is #defined.
So I make the following change:

--
Index: config/gen/platform/generic/memalign.c
===================================================================
--- config/gen/platform/generic/memalign.c      (revision 9190)
+++ config/gen/platform/generic/memalign.c      (working copy)
@@ -3,6 +3,7 @@
  */

 #if defined(PARROT_HAS_POSIX_MEMALIGN)
+#define _XOPEN_SOURCE 600
 #include <stdlib.h>

 void *
--

And now cpp is showing that the proper prototype is being sucked in.

--
$ cpp -DPARROT_HAS_POSIX_MEMALIGN config/gen/platform/generic/memalign.c | grep posix_memalign
extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
    int i = posix_memalign(&p, align, size);
--

So I run `make distclean && perl Configure.pl && make` and the warning
is *still* there (different line number).

--
config/gen/platform/generic/memalign.c: In function `Parrot_memalign':
config/gen/platform/generic/memalign.c:13: warning: implicit declaration of function `posix_memalign'
--

My only guess is that somehow _STDLIB_H is being defined before #include
in memalign.c is processed by cpp.  This has a really bad smell to it.

This is on Linux/AMD64 w/ gcc-3.4.4 & glibc-2.3.5 and multilib header
files.

-J

--



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About