]> git.sesse.net Git - vlc/commitdiff
Emulate C99's lldiv() if necessary
authorEric Petit <titer@videolan.org>
Wed, 8 Mar 2006 23:32:08 +0000 (23:32 +0000)
committerEric Petit <titer@videolan.org>
Wed, 8 Mar 2006 23:32:08 +0000 (23:32 +0000)
configure.ac
include/vlc_common.h
src/extras/libc.c

index d3de5a66b42d1b3e3d3036ed2491d382b5dce096..7ff88e059279f3566e9c7f0ba988a418c702c802 100644 (file)
@@ -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)])
index 60204149f9ef06ad807cd363fc975ecfe397538d..381bd24d458482cbe396520c1723e5fb8d37a5c0 100644 (file)
@@ -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
index d358bfd1bf873a4428b2349d7180618cfbaaa419..2b2982dcc9d8adace8a6601016028468b36584b2 100644 (file)
@@ -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 '\'