Browse Source

moving funcs around the corner

master
tth 3 years 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 @@
+--------------------------------+
| how to build the dd2-monitor ? |
+--------------------------------+
First step, build some parts of the core library :
$ cd core
$ make t
$ ./t -v

+ 16
- 5
core/Makefile 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
gcc -Wall -c $<
COPT = -Wall -fpic -g -DDEBUG_LEVEL=0
OBJS = lut1024f.o parseconf.o utils.o
DEPS = Makefile
# ---------------------------------------------------
libdd2m-core.a: ${OBJS}
parseconf.o: parseconf.c config.h
lut1024f.o: lut1024f.c lut1024.h ${DEPS}
gcc -Wall -c $<
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
- 0
core/utils.c 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
- 0
core/utils.h View File


+ 0
- 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;
}
/* --------------------------------------------------------------- */


Loading…
Cancel
Save