Provide fallback implementation of lrand48_r

darcs-hash:20060615105315-ac50b-155e1836d0bdc8f398776a816898718066adcdce.gz
This commit is contained in:
axel 2006-06-15 20:53:15 +10:00
parent 4e38d3bc8c
commit d677b468db
3 changed files with 39 additions and 1 deletions

View file

@ -276,7 +276,7 @@ AC_CHECK_HEADER([regex.h],
# Check for presense of various functions # Check for presense of various functions
AC_CHECK_FUNCS( wcsdup wcsndup wcslen wcscasecmp wcsncasecmp gettext fwprintf ) AC_CHECK_FUNCS( wcsdup wcsndup wcslen wcscasecmp wcsncasecmp gettext fwprintf )
AC_CHECK_FUNCS( futimes wcwidth wcswidth getopt_long wcstok fputwc fgetwc ) 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 # Here follows a list of small programs used to test for various
# features that Autoconf doesn't tell us about # features that Autoconf doesn't tell us about

View file

@ -1005,3 +1005,18 @@ int del_curterm(TERMINAL *oterm)
#endif #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

View file

@ -292,4 +292,27 @@ size_t wcslcpy( wchar_t *dst, const wchar_t *src, size_t siz );
int del_curterm(TERMINAL *oterm); int del_curterm(TERMINAL *oterm);
#endif #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
#endif