Skip to content
Snippets Groups Projects
Commit 2118a3ea authored by Daniel Salzman's avatar Daniel Salzman
Browse files

Replace memalign with posix_memalign

parent 4f32f874
Branches
Tags
No related merge requests found
......@@ -178,7 +178,7 @@ AC_DEFINE([DSFMT_MEXP], [521], [DSFMT parameters.])
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MMAP
AC_CHECK_FUNCS([gethostbyname gettimeofday clock_gettime memalign memmove memset munmap regcomp pselect select socket sqrt strcasecmp strchr strdup strerror strncasecmp strtol strtoul poll epoll_wait kqueue setgroups sendmmsg madvise pthread_setaffinity_np getline fgetln])
AC_CHECK_FUNCS([gethostbyname gettimeofday clock_gettime posix_memalign memmove memset munmap regcomp pselect select socket sqrt strcasecmp strchr strdup strerror strncasecmp strtol strtoul poll epoll_wait kqueue setgroups sendmmsg madvise pthread_setaffinity_np getline fgetln])
# Check for cpu_set_t/cpuset_t compatibility
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[cpu_set_t set; CPU_ZERO(&set);]])],
......
......@@ -21,7 +21,7 @@
#include <time.h>
#include <sys/time.h>
#include <config.h>
#ifdef HAVE_MEMALIGN
#ifdef HAVE_POSIX_MEMALIGN
#include <stdlib.h>
#endif
......@@ -84,18 +84,18 @@ double tls_rand()
/* Initialize PRNG state. */
#ifdef HAVE_MEMALIGN
s = memalign(16, sizeof(dsfmt_t));
if (posix_memalign((void **)&s, 16, sizeof(dsfmt_t)) != 0) {
fprintf(stderr, "error: PRNG: not enough memory\n");
return .0;
}
#else
s = malloc(sizeof(dsfmt_t));
#endif
if (s == NULL) {
if ((s = malloc(sizeof(dsfmt_t))) == NULL) {
fprintf(stderr, "error: PRNG: not enough memory\n");
return .0;
} else {
dsfmt_init_gen_rand(s, seed);
(void)pthread_setspecific(tls_prng_key, s);
}
#endif
dsfmt_init_gen_rand(s, seed);
(void)pthread_setspecific(tls_prng_key, s);
}
return dsfmt_genrand_close_open(s);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment