From 1b73c740f371a37298ed85a5348a6ab2590ca869 Mon Sep 17 00:00:00 2001 From: Eric Petit Date: Wed, 8 Mar 2006 23:32:08 +0000 Subject: [PATCH] Emulate C99's lldiv() if necessary --- configure.ac | 2 +- include/vlc_common.h | 11 +++++++++++ src/extras/libc.c | 13 +++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d3de5a66b4..7ff88e0592 100644 --- a/configure.ac +++ b/configure.ac @@ -404,7 +404,7 @@ need_libc=false AC_CHECK_FUNCS(gettimeofday select strerror strtod strtol strtof strtoll strtoull strsep isatty vasprintf asprintf swab sigrelse getpwuid memalign posix_memalign if_nametoindex atoll getenv putenv setenv gmtime_r ctime_r localtime_r lrintf daemon scandir fork bsearch lstat) dnl Check for usual libc functions -AC_CHECK_FUNCS(strdup strndup atof) +AC_CHECK_FUNCS(strdup strndup atof lldiv) AC_CHECK_FUNCS(strcasecmp,,[AC_CHECK_FUNCS(stricmp)]) AC_CHECK_FUNCS(strncasecmp,,[AC_CHECK_FUNCS(strnicmp)]) AC_CHECK_FUNCS(strcasestr,,[AC_CHECK_FUNCS(stristr)]) diff --git a/include/vlc_common.h b/include/vlc_common.h index 60204149f9..381bd24d45 100644 --- a/include/vlc_common.h +++ b/include/vlc_common.h @@ -873,6 +873,17 @@ static inline void _SetQWBE( uint8_t *p, uint64_t i_qw ) # define vlc_strtoll NULL #endif +#ifndef HAVE_LLDIV + typedef struct { + long long quot; /* Quotient. */ + long long rem; /* Remainder. */ + } lldiv_t; +# define lldiv vlc_lldiv + VLC_EXPORT( lldiv_t, vlc_lldiv, ( long long numer, long long denom ) ); +#elif !defined(__PLUGIN__) +# define vlc_lldiv NULL +#endif + #ifndef HAVE_SCANDIR # define scandir vlc_scandir # define alphasort vlc_alphasort diff --git a/src/extras/libc.c b/src/extras/libc.c index d358bfd1bf..2b2982dcc9 100644 --- a/src/extras/libc.c +++ b/src/extras/libc.c @@ -343,6 +343,19 @@ int64_t vlc_atoll( const char *nptr ) } #endif +/***************************************************************************** + * lldiv: returns quotient and remainder + *****************************************************************************/ +#if !defined( HAVE_LLDIV ) +lldiv_t vlc_lldiv( long long numer, long long denom ) +{ + lldiv_t d; + d.quot = numer / denom; + d.rem = numer % denom; + return d; +} +#endif + /***************************************************************************** * vlc_*dir_wrapper: wrapper under Windows to return the list of drive letters * when called with an empty argument or just '\'