moving funcs around the corner

This commit is contained in:
Tonton Th 2019-01-17 11:51:07 +01:00
parent 63d71d99a7
commit dac48f95b8
5 changed files with 87 additions and 49 deletions

12
BUILD.txt Normal file
View File

@ -0,0 +1,12 @@
+--------------------------------+
| how to build the dd2-monitor ? |
+--------------------------------+
First step, build some parts of the core library :
$ cd core
$ make t
$ ./t -v

View File

@ -1,19 +1,30 @@
#
# dd2 monitoring
#
# buil the core functions, use with care
#
OBJS = lut1024f.o parseconf.o
lut1024f.o: lut1024f.c lut1024.h
COPT = -Wall -fpic -g -DDEBUG_LEVEL=0
OBJS = lut1024f.o parseconf.o utils.o
DEPS = Makefile
# ---------------------------------------------------
libdd2m-core.a: ${OBJS}
lut1024f.o: lut1024f.c lut1024.h ${DEPS}
gcc -Wall -c $<
parseconf.o: parseconf.c config.h
parseconf.o: parseconf.c config.h ${DEPS}
gcc -Wall -c $<
utils.o: utils.c utils.h ${DEPS}
gcc -Wall -c $<
# ---------------------------------------------------
t: t.c ${OBJS} lut1024.h config.h
t: t.c ${OBJS} lut1024.h config.h utils.h ${DEPS}
gcc -Wall $< ${OBJS} -o $@
foo.lut1024f: mklut.pl Makefile

59
core/utils.c Normal file
View File

@ -0,0 +1,59 @@
/*
* core/utils.c
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
extern int verbosity;
/* --------------------------------------------------------------- */
int seed_my_rand(int foo)
{
long v1, v2;
v1 = getpid(); v2 = time(NULL);
return v1 ^ v2;
}
/* --------------------------------------------------------------- */
int random1000(int type)
{
int value;
#if DEBUG_LEVEL > 1
fprintf(stderr, ">>> %s(%d)\n", __func__, type);
#endif
switch (type) {
case 0:
value = rand() % 1000;
break;
case 1:
value = (rand()%1000 + rand()%1000) / 2;
break;
default:
value = -1;
break;
}
return value;
}
/* --------------------------------------------------------------- */
double dtime(void)
{
struct timeval tv;
int foo;
foo = gettimeofday(&tv, NULL);
if (foo) fprintf(stderr, "got %d in %s\n", foo, __func__);
return (double)tv.tv_sec + (double)tv.tv_usec / 1e6;
}
/* --------------------------------------------------------------- */

0
core/utils.h Normal file
View File

44
funcs.c
View File

@ -13,50 +13,6 @@
extern int verbosity;
/* --------------------------------------------------------------- */
int seed_my_rand(int foo)
{
long v1, v2;
v1 = getpid(); v2 = time(NULL);
return v1 ^ v2;
}
/* --------------------------------------------------------------- */
int random1000(int type)
{
int value;
if (verbosity)
fprintf(stderr, ">>> %s(%d)\n", __func__, type);
switch (type) {
case 0:
value = rand() % 1000;
break;
case 1:
value = (rand()%1000 + rand()%1000) / 2;
break;
default:
value = -1;
break;
}
return value;
}
/* --------------------------------------------------------------- */
double dtime(void)
{
struct timeval tv;
int foo;
foo = gettimeofday(&tv, NULL);
if (foo) fprintf(stderr, "got %d in %s\n", foo, __func__);
return (double)tv.tv_sec + (double)tv.tv_usec / 1e6;
}
/* --------------------------------------------------------------- */