This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Wierd problems with posix_memalign...
- From: Kimmo Fredriksson <kfredrik at cs dot joensuu dot fi>
- To: Mihnea Balta <dark_lkml at mymail dot ro>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 14 Aug 2003 14:10:35 +0000 (UTC)
- Subject: Re: Wierd problems with posix_memalign...
- Replyto: Kimmo Fredriksson <kfredrik@cs.joensuu.fi>
On Thu, 14 Aug 2003, Mihnea Balta wrote:
> From the man page:
>
> ERRORS
> EINVAL The alignment parameter was not a power of two, or was not a
> multiple of sizeof(void *).
In both example cases, the alignement was 16, which is power of two, and a
multiple of sizeof( void* ), and the first case succeeded, while the
second did not. So, this cannot be the cause of the failure.
>
> ENOMEM There was insufficient memory to fulfill the allocation request.
>
The first example allocated 65536 bytes succesfully, and the second could
not allocate 65 bytes, and this 65 bytes was the first and only allocation
request the program made. Cannot be the problem.
> NOTES
> posix_memalign() verifies that alignment matches the requirements
> detailed above. memalign() may not check that the boundary parameter is
> correct.
>
>
> On Thursday 14 August 2003 16:42, Kimmo Fredriksson wrote:
> > Hi,
> >
> > I'm having troubles with posix_memalign. The following works OK:
> >
> >
> > int r;
> > void *p;
> >
> > r = posix_memalign( &p, 16, 65536 );
> > if( r ) fprintf( stderr, "%s\n", strerror( r ));
> >
> > But e.g. this fails:
> >
> > r = posix_memalign( &p, 16, 65 );
> > if( r ) fprintf( stderr, "%s\n", strerror( r ));
> >
> > i.e. it outputs: Invalid argument
> >
> > Why? It seems that the number of bytes (the last parameter) is "invalid".
> > This happens with at least gcc 2.96 and gcc 3.3.1.
> >
> > My system is Linux 2.4.18 / RH8.0.
> >
> > kf
> >
> >
> > ---------------------------------------------------------------
> > Acasa.ro vine cu albumele, tu vino doar cu pozele ;)
> > http://poze.acasa.ro/
>
>