summaryrefslogtreecommitdiff
path: root/libs/pbd/pbd/timersub.h
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-07-11 14:30:38 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-07-11 14:30:38 -0400
commit2218a70d376586633451134cb790b5c8d794e431 (patch)
treec848398fa0ccbc13644b4202717f92a9696054b3 /libs/pbd/pbd/timersub.h
parentb6afce39a40f5a6f06de665c242d96934b7e3f8e (diff)
Add timersub macro for platforms where it isn't defined
Diffstat (limited to 'libs/pbd/pbd/timersub.h')
-rw-r--r--libs/pbd/pbd/timersub.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/libs/pbd/pbd/timersub.h b/libs/pbd/pbd/timersub.h
new file mode 100644
index 0000000000..6cb152414c
--- /dev/null
+++ b/libs/pbd/pbd/timersub.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991-1994,1996-2003,2005,2006,2009
+ Free Software Foundation, Inc.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/time.h>
+
+#ifndef timersub
+# define timersub(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
+ if ((result)->tv_usec < 0) { \
+ --(result)->tv_sec; \
+ (result)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif
+