Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/p/posix_memalign.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/p/posix_memalign.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/p/posix_memalign.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/p/posix_memalign.html on line 8

posix_memalign()

Allocate aligned memory

Synopsis:

#include <stdlib.h>

int posix_memalign( void ** memptr,
                    size_t alignment,
                    size_t size );

Arguments:

memptr
A pointer to a location where posix_memalign() can store a pointer the memory.
alignment
The alignment to use for the memory. This must be a multiple of size( void * ).
size
The size, in bytes, of the block to allocate.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The posix_memalign() function allocates size bytes aligned on a boundary specified by alignment. It returns a pointer to the allocated memory in memptr.

The buffer allocated by posix_memalign() is contiguous in virtual address space, but not physical memory. Since some platforms don't allocate memory in 4 KB page sizes, you shouldn't assume that the memory allocated will be physically contiguous if you specify a size of 4 KB or less.

You can obtain the physical address of the start of the buffer using mem_offset() with fd=NOFD.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EINVAL
The value of alignment isn't a multiple of size( void * ).
ENOMEM
There's insufficient memory available with the requested alignment.

Classification:

POSIX 1003.1 ADV

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

errno, free(), malloc(), memalign()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/p/posix_memalign.html on line 165

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/p/posix_memalign.html on line 165