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 7e1ea27d37..7cea1510d6 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 3f6ec5a8d6..09c3b1d124 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 59fd90251e..f2e18d24e4 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 29700c84f4..0128f6323c 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 a91ffa49b5..ce3be371cc 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 631fcf3e1d..983ef66b80 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