Skip to content

Commit

Permalink
build: use ac_create_stdint_h.m4 and check for memalign.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Hergert authored and chergert committed Oct 18, 2013
1 parent 88d1bc6 commit 505d133
Show file tree
Hide file tree
Showing 4 changed files with 526 additions and 172 deletions.
14 changes: 14 additions & 0 deletions bson/bson-memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*/


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdlib.h>
#include <string.h>

Expand Down Expand Up @@ -53,10 +57,20 @@ bson_memalign0 (size_t alignment,
{
void *mem;

#if HAVE_POSIX_MEMALIGN
if (0 != posix_memalign(&mem, alignment, size)) {
perror("posix_memalign() failure:");
abort();
}
#elif HAVE_MEMALIGN
mem = memalign(alignment, size);
if (!mem) {
perror("memalign() failure:");
abort();
}
#else
mem = bson_malloc(size);
#endif

memset(mem, 0, size);

Expand Down
4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ AC_SUBST(BSON_LT_LDFLAGS)
dnl **************************************************************************
dnl Check for Required Headers
dnl **************************************************************************
AC_NEED_STDINT_H([bson/bson-stdint.h])
AC_CREATE_STDINT_H([bson/bson-stdint.h])


dnl **************************************************************************
Expand Down Expand Up @@ -161,6 +161,8 @@ AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=],
[CLOCK_LIB=])])
AC_SUBST([CLOCK_LIB])

AC_CHECK_FUNCS(posix_memalign memalign)


dnl **************************************************************************
dnl Check if pthread_mutex synchronisation needed
Expand Down
Loading

0 comments on commit 505d133

Please sign in to comment.