Permalink
Browse files

Make our long long constants compatible with old versions of Visual C++

6.0 and 7.0 don't have C99 compatibility.
See https://rt.cpan.org/Ticket/Display.html?id=40600
  • Loading branch information...
1 parent 759f37a commit 6a6651b2cdac1f33b7af9ba4525213dfa18672e0 @schwern schwern committed Feb 17, 2010
Showing with 28 additions and 7 deletions.
  1. +5 −5 bin/check_max.c
  2. +6 −0 perl/Time-y2038/Changes
  3. +2 −1 time64.c
  4. +15 −1 time64.h
View
@@ -1,6 +1,6 @@
/* A little program to test the limits of your system's time functions */
-#include "time64_config.h"
+#include "time64.h"
#include <time.h>
#include <stdio.h>
#include <math.h>
@@ -173,13 +173,13 @@ void guess_time_limits_from_types(void) {
below. Don't worry, these won't get run in that case */
if( sizeof(Test_TM.tm_year) == 4 ) {
/* y2**31-1 bug */
- Time_Max = 67768036160140799LL;
- Time_Min = -67768036191676800LL;
+ Time_Max = __LL(67768036160140799);
+ Time_Min = __LL(-67768036191676800);
}
else {
/* All the way out to 2**63-1 */
- Time_Max = 9223372036854775807LL;
- Time_Min = -9223372036854775807LL;
+ Time_Max = __LL(9223372036854775807);
+ Time_Min = __LL(-9223372036854775807);
}
}
else {
View
@@ -1,3 +1,9 @@
+Next
+ Build
+ * Make our long long constants compatible with old versions of
+ Visual C++ that don't have C99 compatibility.
+
+
20100216.1421_04 Tue Feb 16 14:22:08 PST 2010
Build
* Switch dependency on JSON::XS to just JSON to eliminate
View
@@ -168,7 +168,8 @@ static const int length_of_year[2] = { 365, 366 };
/* Some numbers relating to the gregorian cycle */
static const Year years_in_gregorian_cycle = 400;
#define days_in_gregorian_cycle ((365 * 400) + 100 - 4 + 1)
-static const Time64_T seconds_in_gregorian_cycle = days_in_gregorian_cycle * 60LL * 60LL * 24LL;
+static const Time64_T seconds_in_gregorian_cycle = days_in_gregorian_cycle * \
+ __LL(60) * __LL(60) * __LL(24);
/* Year range we can trust the time funcitons with */
#define MAX_SAFE_YEAR 2037
View
@@ -39,6 +39,21 @@ struct TM64 {
#define TM tm
#endif
+/* Figure out how the C preprocessor concatenates */
+#if 42 == 1
+#define __CAT2(a,b) a/**/b
+#endif
+#if 42 == 42
+#define __CATIFY(a, b) a ## b
+#define __CAT2(a,b) __CATIFY(a,b)
+#endif
+
+/* 1234LL is a C99 thing. Some compilers don't like it. */
+#if defined( _MSC_VER ) && ( _MSC_VER <= 1300 )
+#define __LL(c) __CAT2(c,I64)
+#else
+#define __LL(c) __CAT2(c,LL)
+#endif
/* Declare public functions */
struct TM *gmtime64_r (const Time64_T *, struct TM *);
@@ -77,5 +92,4 @@ Time64_T timelocal64 (const struct TM *);
#define TM64_ASCTIME_FORMAT "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n"
#endif
-
#endif

0 comments on commit 6a6651b

Please sign in to comment.