summary refs log tree commit diff
path: root/time/mktime.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-03-16 02:57:35 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-05-23 14:36:24 -0700
commit03cf7fe31be5964707a54ed82969b9c181f8dd99 (patch)
tree0bc872aba029ef45e274a05a4e6e6c6ef2367007 /time/mktime.c
parentf04dfbc244efb683e395d40c08c86fb93e679167 (diff)
downloadglibc-03cf7fe31be5964707a54ed82969b9c181f8dd99.tar.gz
glibc-03cf7fe31be5964707a54ed82969b9c181f8dd99.tar.xz
glibc-03cf7fe31be5964707a54ed82969b9c181f8dd99.zip
mktime: check signed shifts on long_int and time_t, too
* time/mktime.c (SHR): Check that shifts work as desired
on the types long_int and time_t too, as SHR is used on
such types.
Diffstat (limited to 'time/mktime.c')
-rw-r--r--time/mktime.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/time/mktime.c b/time/mktime.c
index 6d4db69da2..5144987708 100644
--- a/time/mktime.c
+++ b/time/mktime.c
@@ -89,9 +89,11 @@ verify (long_int_is_wide_enough, INT_MAX == INT_MAX * (long_int) 2 / 2);
    implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift
    right in the usual way when A < 0, so SHR falls back on division if
    ordinary A >> B doesn't seem to be the usual signed shift.  */
-#define SHR(a, b)	\
-  (-1 >> 1 == -1	\
-   ? (a) >> (b)		\
+#define SHR(a, b)                                               \
+  ((-1 >> 1 == -1                                               \
+    && (long_int) -1 >> 1 == -1                                 \
+    && ((time_t) -1 >> 1 == -1 || ! TYPE_SIGNED (time_t)))      \
+   ? (a) >> (b)                                                 \
    : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
 
 /* The extra casts in the following macros work around compiler bugs,