summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.mk2
-rw-r--r--thread.c1
-rw-r--r--thread_pthread.c10
-rw-r--r--thread_win32.c10
-rw-r--r--time.c21
-rw-r--r--timev.h21
6 files changed, 23 insertions, 42 deletions
diff --git a/common.mk b/common.mk
index 7e1ea27..7cea151 100644
--- a/common.mk
+++ b/common.mk
@@ -745,7 +745,7 @@ struct.$(OBJEXT): {$(VPATH)}struct.c $(RUBY_H_INCLUDES) {$(VPATH)}internal.h
thread.$(OBJEXT): {$(VPATH)}thread.c {$(VPATH)}eval_intern.h \
$(RUBY_H_INCLUDES) {$(VPATH)}gc.h $(VM_CORE_H_INCLUDES) \
{$(VPATH)}thread_$(THREAD_MODEL).c $(ENCODING_H_INCLUDES) \
- {$(VPATH)}internal.h {$(VPATH)}io.h {$(VPATH)}thread.h
+ {$(VPATH)}internal.h {$(VPATH)}io.h {$(VPATH)}thread.h {$(VPATH)}timev.h
transcode.$(OBJEXT): {$(VPATH)}transcode.c $(RUBY_H_INCLUDES) \
$(ENCODING_H_INCLUDES) {$(VPATH)}transcode_data.h {$(VPATH)}internal.h
cont.$(OBJEXT): {$(VPATH)}cont.c $(RUBY_H_INCLUDES) \
diff --git a/thread.c b/thread.c
index 3f6ec5a..09c3b1d 100644
--- a/thread.c
+++ b/thread.c
@@ -60,6 +60,7 @@
#include "eval_intern.h"
#include "gc.h"
#include "internal.h"
+#include "timev.h"
#include "ruby/io.h"
#include "ruby/thread.h"
diff --git a/thread_pthread.c b/thread_pthread.c
index 59fd902..f2e18d2 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -363,16 +363,6 @@ native_cond_timedwait(rb_thread_cond_t *cond, pthread_mutex_t *mutex, struct tim
return r;
}
-#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 struct timespec
native_cond_timeout(rb_thread_cond_t *cond, struct timespec timeout_rel)
{
diff --git a/thread_win32.c b/thread_win32.c
index 29700c8..0128f63 100644
--- a/thread_win32.c
+++ b/thread_win32.c
@@ -506,16 +506,6 @@ native_cond_timedwait(rb_thread_cond_t *cond, rb_thread_lock_t *mutex, struct ti
return native_cond_timedwait_ms(cond, mutex, timeout_ms);
}
-#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 struct timespec
native_cond_timeout(rb_thread_cond_t *cond, struct timespec timeout_rel)
{
diff --git a/time.c b/time.c
index a91ffa4..ce3be37 100644
--- a/time.c
+++ b/time.c
@@ -717,27 +717,6 @@ num_exact(VALUE v)
/* time_t */
-#ifndef TYPEOF_TIMEVAL_TV_SEC
-# define TYPEOF_TIMEVAL_TV_SEC time_t
-#endif
-#ifndef TYPEOF_TIMEVAL_TV_USEC
-# if INT_MAX >= 1000000
-# define TYPEOF_TIMEVAL_TV_USEC int
-# else
-# define TYPEOF_TIMEVAL_TV_USEC long
-# endif
-#endif
-
-#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 wideval_t
rb_time_magnify(wideval_t w)
{
diff --git a/timev.h b/timev.h
index 631fcf3..983ef66 100644
--- a/timev.h
+++ b/timev.h
@@ -18,4 +18,25 @@ struct vtm {
#define TIME_SCALE 1000000000
+#ifndef TYPEOF_TIMEVAL_TV_SEC
+# define TYPEOF_TIMEVAL_TV_SEC time_t
+#endif
+#ifndef TYPEOF_TIMEVAL_TV_USEC
+# if INT_MAX >= 1000000
+# define TYPEOF_TIMEVAL_TV_USEC int
+# else
+# define TYPEOF_TIMEVAL_TV_USEC long
+# endif
+#endif
+
+#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
+
#endif