diff --git a/configure.ac b/configure.ac index 4f4bfcc1..0dea296c 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/klib/drand48.c b/src/klib/drand48.c index ab9230e3..2f4335bd 100644 --- a/src/klib/drand48.c +++ b/src/klib/drand48.c @@ -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 +#endif + +#ifndef HAVE_DRAND48 #include #include "drand48.h" @@ -67,4 +71,6 @@ double erand48(unsigned short xseed[3]) double drand48(void) { return erand48(_rand48_seed); -} \ No newline at end of file +} + +#endif // HAVE_DRAND48 diff --git a/src/klib/drand48.h b/src/klib/drand48.h index d8fd0f7d..56b55d3c 100644 --- a/src/klib/drand48.h +++ b/src/klib/drand48.h @@ -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 +#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 \ No newline at end of file diff --git a/src/strndup.c b/src/strndup.c index 61f605b6..6d1a9300 100644 --- a/src/strndup.c +++ b/src/strndup.c @@ -1,4 +1,7 @@ +#ifdef HAVE_CONFIG_H #include +#endif + #ifndef HAVE_STRNDUP #include diff --git a/src/strndup.h b/src/strndup.h index 69dea1a7..7cd3bffb 100644 --- a/src/strndup.h +++ b/src/strndup.h @@ -1,7 +1,9 @@ #ifndef STRNDUP_H #define STRNDUP_H +#ifdef HAVE_CONFIG_H #include +#endif #ifndef HAVE_STRNDUP diff --git a/windows/configure.ac b/windows/configure.ac index b41080f6..0a964cf5 100644 --- a/windows/configure.ac +++ b/windows/configure.ac @@ -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