|
From: Nicholas N. <nj...@ca...> - 2004-07-25 12:01:26
|
Hi,
I've written a regression test that uses posix_memalign(). When I compile
it, I get this warning:
memalign2.c:35: warning: implicit declaration of function `posix_memalign'
But it compiles and runs ok.
Looking in /usr/include/stdlib.h, I see this declaration:
#ifdef __USE_XOPEN2K
/* Allocate memory of SIZE bytes with an alignment of ALIGNMENT. */
extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
__THROW __attribute_malloc__;
#endif
I guess the __USE_XOPEN2K is the problem, whatever that signifies.
I see the same thing on three different machines.
So I'm a bit puzzled. Is posix_memalign() standard? Should I not add a
regression test using it? (It would result in a warning.)
N
|
|
From: Tom H. <th...@cy...> - 2004-07-25 14:33:14
|
In message <Pin...@he...>
Nicholas Nethercote <nj...@ca...> wrote:
> Looking in /usr/include/stdlib.h, I see this declaration:
>
> #ifdef __USE_XOPEN2K
> /* Allocate memory of SIZE bytes with an alignment of ALIGNMENT. */
> extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
> __THROW __attribute_malloc__;
> #endif
>
> I guess the __USE_XOPEN2K is the problem, whatever that signifies.
> I see the same thing on three different machines.
>
> So I'm a bit puzzled. Is posix_memalign() standard? Should I not add a
> regression test using it? (It would result in a warning.)
It appears to be standard, as the linux manual page says:
CONFORMING TO
The function valloc() appeared in 3.0 BSD. It is documented as being
obsolete in BSD 4.3, and as legacy in SUSv2. It no longer occurs in
SUSv3. The function memalign() appears in SunOS 4.1.3 but not in BSD
4.4. The function posix_memalign() comes from POSIX 1003.1d.
The manual page also has this to say about header files:
HEADERS
Everybody agrees that posix_memalign() is declared in <stdlib.h>. In
order to declare it, glibc needs _GNU_SOURCE defined, or _XOPEN_SOURCE
defined to a value not less than 600.
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|