diff options
author | Michael Elkins <me@sigpipe.org> | 2010-08-06 17:08:34 -0700 |
---|---|---|
committer | Michael Elkins <me@sigpipe.org> | 2010-08-06 17:08:34 -0700 |
commit | 5171db160f8f638655053863053b357efa612445 (patch) | |
tree | f84154f0e96570cf20bc649643a1e1c5b8b830d4 | |
parent | 0d60d3f1633d2f1af82dd966dc7736fee2c0e107 (diff) |
detect availablity of 'long long'
cast time_t to 'long long' prior to bitshifting since it can be a float value according to POSIX.1-2008
closes #3439
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | init.c | 5 | ||||
-rw-r--r-- | protos.h | 9 |
3 files changed, 14 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 88383b3e..5a8c7f0e 100644 --- a/configure.ac +++ b/configure.ac @@ -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) @@ -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); } @@ -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 |