nettoyer le brotch
This commit is contained in:
parent
e5cc357130
commit
7c8067fc5a
13
Makefile
13
Makefile
@ -8,13 +8,12 @@ CCOPT = -Wall -g
|
||||
|
||||
all: essai fake-values
|
||||
|
||||
essai: essai.c funcs.o Makefile
|
||||
gcc ${CCOPT} $< funcs.o -o $@
|
||||
# ---------------------------------------------
|
||||
|
||||
essai: essai.c Makefile
|
||||
gcc ${CCOPT} $< core/utils.o -o $@
|
||||
|
||||
funcs.o: funcs.c funcs.h Makefile
|
||||
gcc ${CCOPT} -c $<
|
||||
|
||||
fake-values: fake-values.c funcs.o Makefile
|
||||
gcc ${CCOPT} $< funcs.o -o $@
|
||||
fake-values: fake-values.c Makefile
|
||||
gcc ${CCOPT} $< core/utils.o -o $@
|
||||
|
||||
# ---------------------------------------------
|
||||
|
31
essai.c
31
essai.c
@ -5,24 +5,45 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "funcs.h"
|
||||
#include "core/utils.h"
|
||||
|
||||
int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
int get_loadavg(double *where)
|
||||
{
|
||||
FILE *fp;
|
||||
double loads[3];
|
||||
int foo;
|
||||
|
||||
if ( ! (fp=fopen("/proc/loadavg", "r")) ) {
|
||||
perror("read loadavg");
|
||||
return -1;
|
||||
}
|
||||
|
||||
foo = fscanf(fp, "%lf %lf %lf", loads, loads+1, loads+2);
|
||||
if (3 != foo) fprintf(stderr, "%s : read %d vals\n", __func__, foo);
|
||||
|
||||
memcpy(where, loads, 3 * sizeof(double));
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int opt, foo;
|
||||
int type = 0;
|
||||
double loads[3];
|
||||
|
||||
while ((opt = getopt(argc, argv, "vst:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "v")) != -1) {
|
||||
switch (opt) {
|
||||
case 'v': verbosity++; break;
|
||||
case 's': srand(getpid()); break;
|
||||
case 't': type = atoi(optarg); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "funcs.h"
|
||||
#include "core/utils.h"
|
||||
|
||||
int verbosity;
|
||||
|
||||
|
40
funcs.c
40
funcs.c
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* funcs.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "funcs.h"
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
int get_loadavg(double *where)
|
||||
{
|
||||
FILE *fp;
|
||||
double loads[3];
|
||||
int foo;
|
||||
|
||||
if ( ! (fp=fopen("/proc/loadavg", "r")) ) {
|
||||
perror("read loadavg");
|
||||
return -1;
|
||||
}
|
||||
|
||||
foo = fscanf(fp, "%lf %lf %lf", loads, loads+1, loads+2);
|
||||
if (3 != foo) fprintf(stderr, "%s : read %d vals\n", __func__, foo);
|
||||
|
||||
memcpy(where, loads, 3 * sizeof(double));
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- */
|
Loading…
Reference in New Issue
Block a user