Browse Source

moving funcs around the corner

tth 1 year ago
parent
commit
dac48f95b8
5 changed files with 87 additions and 49 deletions
  1. 12
    0
      BUILD.txt
  2. 16
    5
      core/Makefile
  3. 59
    0
      core/utils.c
  4. 0
    0
      core/utils.h
  5. 0
    44
      funcs.c

+ 12
- 0
BUILD.txt View File

@@ -0,0 +1,12 @@
1
+		+--------------------------------+
2
+		| how to build the dd2-monitor ? |
3
+		+--------------------------------+
4
+
5
+First step, build some parts of the core library :
6
+
7
+	$ cd core
8
+	$ make t
9
+	$ ./t -v
10
+
11
+
12
+

+ 16
- 5
core/Makefile View File

@@ -1,19 +1,30 @@
1 1
 #
2
+#		dd2 monitoring
2 3
 #
4
+#	buil the core functions, use with care
3 5
 #
4 6
 
5
-OBJS = lut1024f.o parseconf.o
6 7
 
7
-lut1024f.o:	lut1024f.c lut1024.h
8
-	gcc -Wall -c $<
8
+COPT = -Wall -fpic -g -DDEBUG_LEVEL=0
9
+OBJS = lut1024f.o parseconf.o utils.o
10
+DEPS = Makefile
11
+
12
+# ---------------------------------------------------
9 13
 
14
+libdd2m-core.a:		${OBJS}
10 15
 
11
-parseconf.o:	parseconf.c config.h
16
+lut1024f.o:	lut1024f.c lut1024.h ${DEPS}
12 17
 	gcc -Wall -c $<
13 18
 
19
+parseconf.o:	parseconf.c config.h  ${DEPS}
20
+	gcc -Wall -c $<
21
+
22
+utils.o:	utils.c utils.h  ${DEPS}
23
+	gcc -Wall -c $<
14 24
 
25
+# ---------------------------------------------------
15 26
 
16
-t:	t.c ${OBJS}  lut1024.h config.h
27
+t:	t.c ${OBJS}  lut1024.h config.h utils.h ${DEPS}
17 28
 	gcc -Wall $< ${OBJS} -o $@
18 29
 
19 30
 foo.lut1024f:	mklut.pl Makefile

+ 59
- 0
core/utils.c View File

@@ -0,0 +1,59 @@
1
+/*
2
+ *	core/utils.c
3
+ */
4
+
5
+#include  <stdio.h>
6
+#include <unistd.h>
7
+#include  <stdlib.h>
8
+#include  <string.h>
9
+#include  <time.h>
10
+#include  <sys/time.h>
11
+
12
+extern int verbosity;
13
+
14
+/* --------------------------------------------------------------- */
15
+int seed_my_rand(int foo)
16
+{
17
+long	v1, v2;
18
+
19
+v1 = getpid();		v2 = time(NULL);
20
+
21
+return v1 ^ v2;
22
+}
23
+/* --------------------------------------------------------------- */
24
+
25
+int random1000(int type)
26
+{
27
+int         value;
28
+
29
+#if DEBUG_LEVEL > 1
30
+fprintf(stderr, ">>> %s(%d)\n", __func__, type);
31
+#endif
32
+
33
+switch (type) {
34
+	case 0:
35
+		value = rand() % 1000;
36
+		break;
37
+	case 1:
38
+		value = (rand()%1000 + rand()%1000) / 2;
39
+		break;
40
+	default:
41
+		value = -1;
42
+		break;
43
+	}
44
+
45
+return value;
46
+}
47
+/* --------------------------------------------------------------- */
48
+double dtime(void)
49
+{
50
+struct timeval tv;
51
+int         foo;
52
+
53
+foo = gettimeofday(&tv, NULL);
54
+if (foo) fprintf(stderr, "got %d in %s\n", foo, __func__);
55
+
56
+return (double)tv.tv_sec + (double)tv.tv_usec / 1e6;
57
+}
58
+
59
+/* --------------------------------------------------------------- */

+ 0
- 0
core/utils.h View File


+ 0
- 44
funcs.c View File

@@ -13,50 +13,6 @@
13 13
 
14 14
 extern int verbosity;
15 15
 
16
-/* --------------------------------------------------------------- */
17
-int seed_my_rand(int foo)
18
-{
19
-long	v1, v2;
20
-
21
-v1 = getpid();		v2 = time(NULL);
22
-
23
-return v1 ^ v2;
24
-}
25
-/* --------------------------------------------------------------- */
26
-
27
-int random1000(int type)
28
-{
29
-int         value;
30
-if (verbosity)
31
-    fprintf(stderr, ">>> %s(%d)\n", __func__, type);
32
-
33
-switch (type) {
34
-	case 0:
35
-		value = rand() % 1000;
36
-		break;
37
-	case 1:
38
-		value = (rand()%1000 + rand()%1000) / 2;
39
-		break;
40
-	default:
41
-		value = -1;
42
-		break;
43
-	}
44
-
45
-return value;
46
-}
47
-
48
-/* --------------------------------------------------------------- */
49
-
50
-double dtime(void)
51
-{
52
-struct timeval tv;
53
-int         foo;
54
-
55
-foo = gettimeofday(&tv, NULL);
56
-if (foo) fprintf(stderr, "got %d in %s\n", foo, __func__);
57
-
58
-return (double)tv.tv_sec + (double)tv.tv_usec / 1e6;
59
-}
60 16
 
61 17
 /* --------------------------------------------------------------- */
62 18
 

Loading…
Cancel
Save