added fuctions for triggering math ops in a timer
authortridge <>
Mon, 28 Nov 2005 15:22:36 +0000 (15:22 +0000)
committertridge <>
Mon, 28 Nov 2005 15:22:36 +0000 (15:22 +0000)
load_math/Makefile [new file with mode: 0644]
load_math/load_math.c [new file with mode: 0644]

diff --git a/load_math/Makefile b/load_math/Makefile
new file mode 100644 (file)
index 0000000..0d9c78c
--- /dev/null
@@ -0,0 +1,11 @@
+CFLAGS=-Wall -fPIC -O2
+LIBS=-lm
+
+all: load_math.so 
+
+load_math.so: load_math.o
+       ld -shared -o $@ $^ $(LIBS)
+
+clean:
+       /bin/rm -f *.o *.so *~
+
diff --git a/load_math/load_math.c b/load_math/load_math.c
new file mode 100644 (file)
index 0000000..bb01484
--- /dev/null
@@ -0,0 +1,32 @@
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/time.h>
+#include <time.h>
+#include <math.h>
+
+double global_v;
+
+static void alarm_handler(int sig)
+{
+       struct timeval tv;
+       gettimeofday(&tv,NULL);
+       double v = tan(sin(cos(tv.tv_sec)));
+       v *= 1.3;
+       global_v = v;
+}
+
+void _init(void)
+{
+       struct timeval tv;
+       struct itimerval val;
+       tv.tv_sec = 0;
+       tv.tv_usec = 1;
+       val.it_interval = tv;
+       val.it_value = tv;
+
+       setitimer(ITIMER_REAL, &val, NULL);
+       signal(SIGALRM, alarm_handler);
+}