Browse Source

Semi-Merge commit 'd2abaa8' into cg_merges_20130524b

Conflicts:
	miner.c
Luke Dashjr 12 years ago
parent
commit
9610c8579c
2 changed files with 30 additions and 0 deletions
  1. 25 0
      util.c
  2. 5 0
      util.h

+ 25 - 0
util.c

@@ -1075,6 +1075,31 @@ void cgtime(struct timeval *tv)
 #endif
 }
 
+void subtime(struct timeval *a, struct timeval *b)
+{
+	timersub(a, b, b);
+}
+
+void addtime(struct timeval *a, struct timeval *b)
+{
+	timeradd(a, b, b);
+}
+
+bool time_more(struct timeval *a, struct timeval *b)
+{
+	return timercmp(a, b, >);
+}
+
+bool time_less(struct timeval *a, struct timeval *b)
+{
+	return timercmp(a, b, <);
+}
+
+void copy_time(struct timeval *dest, const struct timeval *src)
+{
+	memcpy(dest, src, sizeof(struct timeval));
+}
+
 /* Returns the microseconds difference between end and start times as a double */
 double us_tdiff(struct timeval *end, struct timeval *start)
 {

+ 5 - 0
util.h

@@ -77,6 +77,11 @@ void thr_info_freeze(struct thr_info *thr);
 void thr_info_cancel(struct thr_info *thr);
 void nmsleep(unsigned int msecs);
 void cgtime(struct timeval *tv);
+void subtime(struct timeval *a, struct timeval *b);
+void addtime(struct timeval *a, struct timeval *b);
+bool time_more(struct timeval *a, struct timeval *b);
+bool time_less(struct timeval *a, struct timeval *b);
+void copy_time(struct timeval *dest, const struct timeval *src);
 double us_tdiff(struct timeval *end, struct timeval *start);
 double tdiff(struct timeval *end, struct timeval *start);
 bool stratum_send(struct pool *pool, char *s, ssize_t len);