Lines 38-43
Link Here
|
38 |
# include <pthread.h> |
38 |
# include <pthread.h> |
39 |
# include <semaphore.h> |
39 |
# include <semaphore.h> |
40 |
#endif |
40 |
#endif |
|
|
41 |
#include <errno.h> |
41 |
|
42 |
|
42 |
#ifdef malloc |
43 |
#ifdef malloc |
43 |
#undef malloc |
44 |
#undef malloc |
Lines 703-708
memalign(size_t alignment, size_t userSi
Link Here
|
703 |
return address; |
704 |
return address; |
704 |
} |
705 |
} |
705 |
|
706 |
|
|
|
707 |
extern C_LINKAGE int |
708 |
posix_memalign(void **memptr, size_t alignment, size_t userSize) |
709 |
{ |
710 |
/* |
711 |
* Per standard, posix_memalign returns EINVAL when alignment |
712 |
* is not a power of two or power of sizeof(void*). efence |
713 |
* doesn't check the value of alignment in memalign, but then |
714 |
* again, memalign was never specified very well, and on some |
715 |
* systems odd alignments could indeed have been allowed. |
716 |
*/ |
717 |
if ((alignment & (alignment - 1)) |
718 |
|| alignment % sizeof (void *)) |
719 |
return EINVAL; |
720 |
|
721 |
void *ptr = memalign (alignment, userSize); |
722 |
if (ptr == NULL) |
723 |
return ENOMEM; |
724 |
*memptr = ptr; |
725 |
return 0; |
726 |
} |
727 |
|
706 |
/* |
728 |
/* |
707 |
* Find the slot structure for a user address. |
729 |
* Find the slot structure for a user address. |
708 |
*/ |
730 |
*/ |