mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-06 18:22:25 +02:00
commit bash-20161028 snapshot
This commit is contained in:
@@ -100,6 +100,12 @@
|
||||
# include "watch.h"
|
||||
#endif
|
||||
|
||||
#ifdef powerof2
|
||||
# undef powerof2
|
||||
#endif
|
||||
/* Could also use (((x) & -(x)) == (x)) */
|
||||
#define powerof2(x) ((((x) - 1) & (x)) == 0)
|
||||
|
||||
/* System-specific omissions. */
|
||||
#ifdef HPUX
|
||||
# define NO_VALLOC
|
||||
@@ -1125,6 +1131,28 @@ internal_memalign (alignment, size, file, line, flags)
|
||||
return aligned;
|
||||
}
|
||||
|
||||
int
|
||||
posix_memalign (memptr, alignment, size)
|
||||
void **memptr;
|
||||
size_t alignment, size;
|
||||
{
|
||||
void *mem;
|
||||
|
||||
/* Perform posix-mandated error checking here */
|
||||
if ((alignment % sizeof (void *) != 0) || alignment == 0)
|
||||
return EINVAL;
|
||||
else if (powerof2 (alignment) == 0)
|
||||
return EINVAL;
|
||||
|
||||
mem = internal_memalign (alignment, size, (char *)0, 0, 0);
|
||||
if (mem != 0)
|
||||
{
|
||||
*memptr = mem;
|
||||
return 0;
|
||||
}
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
#if !defined (NO_VALLOC)
|
||||
/* This runs into trouble with getpagesize on HPUX, and Multimax machines.
|
||||
Patching out seems cleaner than the ugly fix needed. */
|
||||
|
||||
Reference in New Issue
Block a user