[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS shishi/gl
From: |
shishi-commit |
Subject: |
CVS shishi/gl |
Date: |
Thu, 11 Nov 2004 19:58:36 +0100 |
Update of /home/cvs/shishi/gl
In directory dopio:/tmp/cvs-serv2300/gl
Modified Files:
alloca_.h allocsa.h getdate.y mktime.c
Log Message:
Update.
--- /home/cvs/shishi/gl/alloca_.h 2004/07/02 09:19:39 1.4
+++ /home/cvs/shishi/gl/alloca_.h 2004/11/11 18:58:35 1.5
@@ -39,7 +39,7 @@
#ifdef __GNUC__
# define alloca __builtin_alloca
#elif defined _AIX
-# define alloca __alloca
+# define alloca __alloca
#elif defined _MSC_VER
# include <malloc.h>
# define alloca _alloca
--- /home/cvs/shishi/gl/allocsa.h 2004/11/08 14:50:17 1.2
+++ /home/cvs/shishi/gl/allocsa.h 2004/11/11 18:58:35 1.3
@@ -94,14 +94,14 @@
#ifdef HAVE_LONG_LONG
sa_alignment_longlong = sa_alignof (long long),
#endif
-#ifdef HAVE_LONG_DOUBLE
+#ifdef HAVE_LONG_DOUBLE
sa_alignment_longdouble = sa_alignof (long double),
#endif
sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1)
#ifdef HAVE_LONG_LONG
| (sa_alignment_longlong - 1)
#endif
-#ifdef HAVE_LONG_DOUBLE
+#ifdef HAVE_LONG_DOUBLE
| (sa_alignment_longdouble - 1)
#endif
) + 1,
--- /home/cvs/shishi/gl/getdate.y 2004/11/08 14:50:17 1.7
+++ /home/cvs/shishi/gl/getdate.y 2004/11/11 18:58:35 1.8
@@ -84,6 +84,21 @@
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif
+/* Shift A right by B bits portably, by dividing A by 2**B and
+ truncating towards minus infinity. A and B should be free of side
+ effects, and B should be in the range 0 <= B <= INT_BITS - 2, where
+ INT_BITS is the number of useful bits in an int. GNU code can
+ assume that INT_BITS is at least 32.
+
+ ISO C99 says that A >> B is implementation-defined if A < 0. Some
+ 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) \
+ : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
+
#define EPOCH_YEAR 1970
#define TM_YEAR_BASE 1900
@@ -734,12 +749,12 @@
{
/* Compute intervening leap days correctly even if year is negative.
Take care to avoid int overflow in leap day calculations. */
- int a4 = (a->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (a->tm_year & 3);
- int b4 = (b->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (b->tm_year & 3);
+ int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3);
+ int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3);
int a100 = a4 / 25 - (a4 % 25 < 0);
int b100 = b4 / 25 - (b4 % 25 < 0);
- int a400 = a100 >> 2;
- int b400 = b100 >> 2;
+ int a400 = SHR (a100, 2);
+ int b400 = SHR (b100, 2);
int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
long int ayear = a->tm_year;
long int years = ayear - b->tm_year;
--- /home/cvs/shishi/gl/mktime.c 2004/11/08 14:50:17 1.5
+++ /home/cvs/shishi/gl/mktime.c 2004/11/11 18:58:35 1.6
@@ -45,6 +45,21 @@
# define mktime my_mktime
#endif /* DEBUG */
+/* Shift A right by B bits portably, by dividing A by 2**B and
+ truncating towards minus infinity. A and B should be free of side
+ effects, and B should be in the range 0 <= B <= INT_BITS - 2, where
+ INT_BITS is the number of useful bits in an int. GNU code can
+ assume that INT_BITS is at least 32.
+
+ ISO C99 says that A >> B is implementation-defined if A < 0. Some
+ 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) \
+ : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
+
/* The extra casts work around common compiler bugs. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
@@ -59,14 +74,13 @@
#ifndef TIME_T_MAX
# define TIME_T_MAX TYPE_MAXIMUM (time_t)
#endif
-#define TIME_T_MIDPOINT (((TIME_T_MIN + TIME_T_MAX) >> 1) + 1)
+#define TIME_T_MIDPOINT (SHR (TIME_T_MIN + TIME_T_MAX, 1) + 1)
/* Verify a requirement at compile-time (unlike assert, which is runtime). */
#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
verify (time_t_is_integer, (time_t) 0.5 == 0);
verify (twos_complement_arithmetic, -1 == ~1 + 1);
-verify (right_shift_propagates_sign, -1 >> 1 == -1);
/* The code also assumes that signed integer overflow silently wraps
around, but this assumption can't be stated without causing a
diagnostic on some hosts. */
@@ -132,12 +146,12 @@
/* Compute intervening leap days correctly even if year is negative.
Take care to avoid integer overflow here. */
- int a4 = (year1 >> 2) + (TM_YEAR_BASE >> 2) - ! (year1 & 3);
- int b4 = (year0 >> 2) + (TM_YEAR_BASE >> 2) - ! (year0 & 3);
+ int a4 = SHR (year1, 2) + SHR (TM_YEAR_BASE, 2) - ! (year1 & 3);
+ int b4 = SHR (year0, 2) + SHR (TM_YEAR_BASE, 2) - ! (year0 & 3);
int a100 = a4 / 25 - (a4 % 25 < 0);
int b100 = b4 / 25 - (b4 % 25 < 0);
- int a400 = a100 >> 2;
- int b400 = b100 >> 2;
+ int a400 = SHR (a100, 2);
+ int b400 = SHR (b100, 2);
int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
/* Compute the desired time in time_t precision. Overflow might
@@ -321,14 +335,16 @@
int LOG2_YEARS_PER_BIENNIUM = 1;
int approx_requested_biennia =
- ((year_requested >> LOG2_YEARS_PER_BIENNIUM)
- - ((EPOCH_YEAR - TM_YEAR_BASE) >> LOG2_YEARS_PER_BIENNIUM)
- + (mday >> ALOG2_DAYS_PER_BIENNIUM)
- + (hour >> ALOG2_HOURS_PER_BIENNIUM)
- + (min >> ALOG2_MINUTES_PER_BIENNIUM)
- + (LEAP_SECONDS_POSSIBLE ? 0 : sec >> ALOG2_SECONDS_PER_BIENNIUM));
+ (SHR (year_requested, LOG2_YEARS_PER_BIENNIUM)
+ - SHR (EPOCH_YEAR - TM_YEAR_BASE, LOG2_YEARS_PER_BIENNIUM)
+ + SHR (mday, ALOG2_DAYS_PER_BIENNIUM)
+ + SHR (hour, ALOG2_HOURS_PER_BIENNIUM)
+ + SHR (min, ALOG2_MINUTES_PER_BIENNIUM)
+ + (LEAP_SECONDS_POSSIBLE
+ ? 0
+ : SHR (sec, ALOG2_SECONDS_PER_BIENNIUM)));
- int approx_biennia = t0 >> ALOG2_SECONDS_PER_BIENNIUM;
+ int approx_biennia = SHR (t0, ALOG2_SECONDS_PER_BIENNIUM);
int diff = approx_biennia - approx_requested_biennia;
int abs_diff = diff < 0 ? - diff : diff;
@@ -346,7 +362,7 @@
/* Overflow occurred. Try repairing it; this might work if
the time zone offset is enough to undo the overflow. */
time_t repaired_t0 = -1 - t0;
- approx_biennia = repaired_t0 >> ALOG2_SECONDS_PER_BIENNIUM;
+ approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM);
diff = approx_biennia - approx_requested_biennia;
abs_diff = diff < 0 ? - diff : diff;
if (overflow_threshold < abs_diff)
- CVS shishi/gl, shishi-commit, 2004/11/08
- CVS shishi/gl, shishi-commit, 2004/11/09
- CVS shishi/gl, shishi-commit, 2004/11/10
- CVS shishi/gl,
shishi-commit <=
- CVS shishi/gl, shishi-commit, 2004/11/11
- CVS shishi/gl, shishi-commit, 2004/11/11
- CVS shishi/gl, shishi-commit, 2004/11/11
- CVS shishi/gl, shishi-commit, 2004/11/11
- CVS shishi/gl, shishi-commit, 2004/11/12
- CVS shishi/gl, shishi-commit, 2004/11/19
- CVS shishi/gl, shishi-commit, 2004/11/19
- CVS shishi/gl, shishi-commit, 2004/11/21
- CVS shishi/gl, shishi-commit, 2004/11/28