commit bash-20161028 snapshot

This commit is contained in:
Chet Ramey
2016-11-03 17:28:23 -04:00
parent 628bb7b79b
commit 553a7d66e4
30 changed files with 1077 additions and 74 deletions
+28
View File
@@ -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. */