]> granicus.if.org Git - mutt/commitdiff
detect availablity of 'long long'
authorMichael Elkins <me@sigpipe.org>
Sat, 7 Aug 2010 00:08:34 +0000 (17:08 -0700)
committerMichael Elkins <me@sigpipe.org>
Sat, 7 Aug 2010 00:08:34 +0000 (17:08 -0700)
cast time_t to 'long long' prior to bitshifting since it can be a float value according to POSIX.1-2008

closes #3439

configure.ac
init.c
protos.h

index 88383b3e18713d893c2f91da9b1ff93448f48882..5a8c7f0eccceb4287c7e9a5abee1453e6e267d6c 100644 (file)
@@ -109,6 +109,7 @@ AH_BOTTOM([/* fseeko portability defines */
 #endif
 ])
 MUTT_C99_INTTYPES
+AC_TYPE_LONG_LONG_INT
 
 ac_aux_path_sendmail=/usr/sbin:/usr/lib
 AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, $PATH:$ac_aux_path_sendmail)
diff --git a/init.c b/init.c
index 23512bb0be9bbd03d15159c8806652eb05cf8e11..656fe1456cf16e45b21486145271f17622d8a44b 100644 (file)
--- a/init.c
+++ b/init.c
@@ -2868,8 +2868,11 @@ static void mutt_srandom (void)
   /* POSIX.1-2008 states that seed is 'unsigned' without specifying its width.
    * Use as many of the lower order bits from the current time of day as the seed.
    * If the upper bound is truncated, that is fine.
+   *
+   * tv_sec is integral of type integer or float.  Cast to 'long long' before
+   * bitshift in case it is a float.
    */
-  seed = (tv.tv_sec << 20) | tv.tv_usec;
+  seed = ((LONGLONG) tv.tv_sec << 20) | tv.tv_usec;
   srandom(seed);
 }
 
index fe00ea84d38f8ef866fb12dd44c05653c6fefb1d..140dfc3516eb4b7f03f3dba1e7d344d17916accf 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -410,6 +410,15 @@ void mutt_pattern_free (pattern_t **pat);
  * Prototypes for broken systems
  */
 
+#ifdef HAVE_LONG_LONG_INT
+#ifdef LONGLONG
+#error LONGLONG is already defined
+#endif
+#define LONGLONG long long
+#else
+#define LONGLONG long
+#endif
+
 #ifdef HAVE_SRAND48
 #define LRAND lrand48
 #define SRAND srand48