diff --git a/configure.ac b/configure.ac
index 9930ed3..84f4909 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,6 +56,9 @@ AM_CFLAGS="${AM_CFLAGS} ${MEM_OPT_FLAGS}"
AM_CFLAGS="${AM_CFLAGS} ${CFLAGS}"
AC_SUBST(AM_CFLAGS)
+AM_LDFLAGS=""
+AC_SUBST(AM_LDFLAGS)
+
AC_CONFIG_FILES([Makefile
docs/Makefile
tests/Makefile
diff --git a/include/Makefile.am b/include/Makefile.am
index 491447d..e151b79 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -8,6 +8,7 @@ nobase_include_HEADERS = trbase.h \
tr/print_trace.h \
tr/sized_data.h \
tr/tree_macros.h \
+ tr/math.h \
tr/interface/class.h \
tr/interface/indexable.h \
tr/interface/observer.h \
diff --git a/include/tr/math.h b/include/tr/math.h
new file mode 100644
index 0000000..b1cf73d
--- /dev/null
+++ b/include/tr/math.h
@@ -0,0 +1,59 @@
+/**
+ * \file
+ * Common reusable definitions.
+ *
+ * \todo All public symbols need to be prefixed to make name clashes
+ * more unlikely.
+ *
+ * \author Georg Hopp
+ *
+ * \copyright
+ * Copyright © 2014 Georg Hopp
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef __TR_MATH_H__
+#define __TR_MATH_H__
+
+#include "tr/commons.h"
+
+inline
+long
+TR_euklidGcd(register long val1, register long val2)
+{
+ register long mod;
+
+ if(val2 > val1) SWAP_XOR(val1, val2);
+
+ mod = val1 % val2;
+ while (mod != 0) {
+ val1 = val2;
+ val2 = mod;
+ mod = val1 % val2;
+ }
+
+ return val2;
+}
+
+inline
+long
+TR_lcm(register long val1, register long val2)
+{
+ return val1 * val2 / TR_euklidGcd(val1, val2);
+}
+
+#endif // __TR_MATH_H__
+
+// vim: set ts=4 sw=4:
diff --git a/include/trbase.h b/include/trbase.h
index 72ab59d..0b4f16b 100644
--- a/include/trbase.h
+++ b/include/trbase.h
@@ -8,6 +8,7 @@
#include "tr/timer.h"
#include "tr/print_trace.h"
#include "tr/sized_data.h"
+#include "tr/math.h"
#include "tr/interface.h"
#include "tr/interface/class.h"
#include "tr/interface/subject.h"
diff --git a/src/Makefile.am b/src/Makefile.am
index 46d46f5..5ff661c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,8 @@
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = subdir-objects
-AM_CFLAGS += -I../include/
+AM_CFLAGS += -I../include/ -std=c99 -DREENTRANT -lpthread
+AM_LDFLAGS += -lpthread
TR_CLASS = memory.c \
interface.c \
@@ -12,6 +13,7 @@ TR_CLASS = memory.c \
print_trace.c \
stderr.c \
syslog.c \
+ math.c \
sized_data.c \
sized_data_set_data.c \
i_class.c \
@@ -24,6 +26,6 @@ TR_CLASS = memory.c \
lib_LTLIBRARIES = libtrbase.la
libtrbase_la_SOURCES = $(TR_CLASS)
-libtrbase_la_CFLAGS = $(AM_CFLAGS) -lpthread
-libtrbase_la_LIBADD =
+libtrbase_la_CFLAGS = $(AM_CFLAGS)
+libtrbase_la_LIBADD = $(AM_LDFLAGS)
libtrbase_la_LDFLAGS = -version-info 1:0:1
diff --git a/src/math.c b/src/math.c
new file mode 100644
index 0000000..58841ae
--- /dev/null
+++ b/src/math.c
@@ -0,0 +1,30 @@
+/**
+ * \file
+ * Common reusable definitions.
+ *
+ * \todo All public symbols need to be prefixed to make name clashes
+ * more unlikely.
+ *
+ * \author Georg Hopp
+ *
+ * \copyright
+ * Copyright © 2014 Georg Hopp
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "tr/math.h"
+
+extern inline long TR_euklidGcd(register long, register long);
+extern inline long TR_lcm(register long, register long);
diff --git a/src/timer_get.c b/src/timer_get.c
index 986ecb4..ffa6748 100644
--- a/src/timer_get.c
+++ b/src/timer_get.c
@@ -20,6 +20,8 @@
* along with this program. If not, see .
*/
+#define _POSIX_C_SOURCE 199309L
+
#include
#include
diff --git a/src/timer_set.c b/src/timer_set.c
index 2bd3e25..cc14997 100644
--- a/src/timer_set.c
+++ b/src/timer_set.c
@@ -20,6 +20,8 @@
* along with this program. If not, see .
*/
+#define _POSIX_C_SOURCE 199309L
+
#include
#include "trbase.h"