Merge pull request #279 from openvenues/drand48_fix

fix Mac build/standardize conditional compilation of strndup and drand48 for Windows
This commit is contained in:
Al Barrentine
2017-11-29 13:04:24 -05:00
committed by GitHub
6 changed files with 24 additions and 7 deletions

View File

@@ -48,7 +48,7 @@ AC_TYPE_UINT8_T
AC_CHECK_TYPES([ptrdiff_t])
# Checks for library functions.
AC_CHECK_FUNCS([malloc realloc getcwd gettimeofday memmove memset regcomp setlocale sqrt strdup strndup])
AC_CHECK_FUNCS([malloc realloc drand48 getcwd gettimeofday memmove memset regcomp setlocale sqrt strdup strndup])
AC_CONFIG_FILES([Makefile
libpostal.pc

View File

@@ -12,7 +12,11 @@
* to anyone/anything when using this software.
*/
//I've rearranged the source into a header-only implementation for drand48() -Benjamin Kusin
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef HAVE_DRAND48
#include <math.h>
#include "drand48.h"
@@ -67,4 +71,6 @@ double erand48(unsigned short xseed[3])
double drand48(void)
{
return erand48(_rand48_seed);
}
}
#endif // HAVE_DRAND48

View File

@@ -12,11 +12,15 @@
* to anyone/anything when using this software.
*/
//I've rearranged the source into a header-only implementation for drand48() -Benjamin Kusin
#ifndef _DRAND48_H
#define _DRAND48_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef HAVE_DRAND48
#define RAND48_SEED_0 (0x330e)
#define RAND48_SEED_1 (0xabcd)
#define RAND48_SEED_2 (0x1234)
@@ -37,5 +41,7 @@ double erand48(unsigned short xseed[3]);
double drand48(void);
#endif // HAVE_DRAND48
#endif // _DRAND48_H
#endif // _DRAND48_H

View File

@@ -1,4 +1,7 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef HAVE_STRNDUP
#include <stdlib.h>

View File

@@ -1,7 +1,9 @@
#ifndef STRNDUP_H
#define STRNDUP_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef HAVE_STRNDUP

View File

@@ -48,7 +48,7 @@ AC_TYPE_UINT8_T
AC_CHECK_TYPES([ptrdiff_t])
# Checks for library functions.
AC_CHECK_FUNCS([malloc realloc getcwd gettimeofday memmove memset regcomp setlocale sqrt strdup strndup])
AC_CHECK_FUNCS([malloc realloc drand48 getcwd gettimeofday memmove memset regcomp setlocale sqrt strdup strndup])
AC_CONFIG_FILES([Makefile
libpostal.pc