diff --git a/configure.ac b/configure.ac index d09cca000..bb0bd95dc 100644 --- a/configure.ac +++ b/configure.ac @@ -276,7 +276,7 @@ AC_CHECK_HEADER([regex.h], # Check for presense of various functions AC_CHECK_FUNCS( wcsdup wcsndup wcslen wcscasecmp wcsncasecmp gettext fwprintf ) AC_CHECK_FUNCS( futimes wcwidth wcswidth getopt_long wcstok fputwc fgetwc ) -AC_CHECK_FUNCS( wcstol dcgettext wcslcat wcslcpy ) +AC_CHECK_FUNCS( wcstol dcgettext wcslcat wcslcpy lrand48_r) # Here follows a list of small programs used to test for various # features that Autoconf doesn't tell us about diff --git a/fallback.c b/fallback.c index 3024ae2c6..1ed4a477b 100644 --- a/fallback.c +++ b/fallback.c @@ -1005,3 +1005,18 @@ int del_curterm(TERMINAL *oterm) #endif +#ifndef HAVE_LRAND48_R + +int lrand48_r(struct drand48_data *buffer, long int *result) +{ + *result = rand_r( &buffer->seed ); + return 0; +} + +int srand48_r(long int seedval, struct drand48_data *buffer) +{ + buffer->seed = (int)seedval; + return 0; +} + +#endif diff --git a/fallback.h b/fallback.h index d54477e58..7a245f47a 100644 --- a/fallback.h +++ b/fallback.h @@ -292,4 +292,27 @@ size_t wcslcpy( wchar_t *dst, const wchar_t *src, size_t siz ); int del_curterm(TERMINAL *oterm); #endif +#ifndef HAVE_LRAND48_R + +/** + Datastructure for the lrand48_r fallback implementation. +*/ +struct drand48_data +{ + unsigned int seed; +} + ; + +/** + Fallback implementation of lrand48_r. Internally uses rand_r, so it is pretty weak. +*/ +int lrand48_r(struct drand48_data *buffer, long int *result); +/** + Fallback implementation of srand48_r +*/ +int srand48_r(long int seedval, struct drand48_data *buffer); + #endif + +#endif +