1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* time.c (search_time_t): support non 32bit time_t environments.

* win32/Makefile.sub (config.h): VC++8 have ``long long'' type.

* win32/Makefile.sub (config.h): VC++8's time_t is 64bit value.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2006-02-14 02:48:08 +00:00
parent 3d0c93a907
commit 93ff2adbed
3 changed files with 28 additions and 12 deletions

View file

@ -1,3 +1,11 @@
Tue Feb 14 11:42:38 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* time.c (search_time_t): support non 32bit time_t environments.
* win32/Makefile.sub (config.h): VC++8 have ``long long'' type.
* win32/Makefile.sub (config.h): VC++8's time_t is 64bit value.
Mon Feb 13 18:01:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org> Mon Feb 13 18:01:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (copy_node_scope): remove duplicated semicolons at end. * eval.c (copy_node_scope): remove duplicated semicolons at end.

24
time.c
View file

@ -459,6 +459,16 @@ tmcmp(struct tm *a, struct tm *b)
return 0; return 0;
} }
#if SIZEOF_TIME_T == SIZEOF_LONG
typedef unsigned long unsigned_time_t;
#elif SIZEOF_TIME_T == SIZEOF_INT
typedef unsigned int unsigned_time_t;
#elif SIZEOF_TIME_T == SIZEOF_LONG_LONG
typedef unsigned LONG_LONG unsigned_time_t;
#else
# error cannot find integer type which size is same as time_t.
#endif
static time_t static time_t
search_time_t(struct tm *tptr, int utc_p) search_time_t(struct tm *tptr, int utc_p)
{ {
@ -470,12 +480,12 @@ search_time_t(struct tm *tptr, int utc_p)
find_dst = 0 < tptr->tm_isdst; find_dst = 0 < tptr->tm_isdst;
#ifdef NEGATIVE_TIME_T #ifdef NEGATIVE_TIME_T
guess_lo = 1L << (8 * sizeof(time_t) - 1); guess_lo = (time_t)~((unsigned_time_t)~(time_t)0 >> 1);
#else #else
guess_lo = 0; guess_lo = 0;
#endif #endif
guess_hi = ((time_t)-1) < ((time_t)0) ? guess_hi = ((time_t)-1) < ((time_t)0) ?
(1UL << (8 * sizeof(time_t) - 1)) - 1 : (time_t)((unsigned_time_t)~(time_t)0 >> 1) :
~(time_t)0; ~(time_t)0;
guess = timegm_noleapsecond(tptr); guess = timegm_noleapsecond(tptr);
@ -1201,16 +1211,6 @@ time_to_s(VALUE time)
return rb_str_new(buf, len); return rb_str_new(buf, len);
} }
#if SIZEOF_TIME_T == SIZEOF_LONG
typedef unsigned long unsigned_time_t;
#elif SIZEOF_TIME_T == SIZEOF_INT
typedef unsigned int unsigned_time_t;
#elif SIZEOF_TIME_T == SIZEOF_LONG_LONG
typedef unsigned LONG_LONG unsigned_time_t;
#else
# error cannot find integer type which size is same as time_t.
#endif
static VALUE static VALUE
time_add(struct time_object *tobj, VALUE offset, int sign) time_add(struct time_object *tobj, VALUE offset, int sign)
{ {

View file

@ -225,13 +225,21 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub
#define SIZEOF_INT 4 #define SIZEOF_INT 4
#define SIZEOF_SHORT 2 #define SIZEOF_SHORT 2
#define SIZEOF_LONG 4 #define SIZEOF_LONG 4
!if $(MSC_VER) >= 1400
#define SIZEOF_LONG_LONG 8
!else
#define SIZEOF_LONG_LONG 0 #define SIZEOF_LONG_LONG 0
!endif
#define SIZEOF___INT64 8 #define SIZEOF___INT64 8
#define SIZEOF_OFF_T 4 #define SIZEOF_OFF_T 4
#define SIZEOF_VOIDP 4 #define SIZEOF_VOIDP 4
#define SIZEOF_FLOAT 4 #define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8 #define SIZEOF_DOUBLE 8
!if $(MSC_VER) >= 1400
#define SIZEOF_TIME_T 8
!else
#define SIZEOF_TIME_T 4 #define SIZEOF_TIME_T 4
!endif
#define HAVE_PROTOTYPES 1 #define HAVE_PROTOTYPES 1
#define TOKEN_PASTE(x,y) x##y #define TOKEN_PASTE(x,y) x##y
#define HAVE_STDARG_PROTOTYPES 1 #define HAVE_STDARG_PROTOTYPES 1