Revision e64fc7e5

View differences:

Makefile
7 7
CPPFLAGS = -I$(GRAPES)/include
8 8
CPPFLAGS += -I$(GRAPES)/som
9 9

  
10
ifdef DEBUG
11
CPPFLAGS += -DDEBUG
12
endif
13

  
10 14
LDFLAGS = -L$(GRAPES)/som/TopologyManager -L$(GRAPES)/som/ChunkTrading -L$(GRAPES)/som/ChunkBuffer
11 15
LDLIBS = -ltrading -lcb -ltopman
12 16

  
dbg.h
1
#ifndef DBG_H
2
#define DBG_H
3

  
4
#ifdef DEBUG
5
#define dprintf(...) fprintf(stderr, __VA_ARGS__)
6
#else
7
#define dprintf(...)
8
#endif
9

  
10
#endif	/* DBG_H */
input.c
5 5
#include <chunk.h>
6 6

  
7 7
#include "input.h"
8
#include "dbg.h"
8 9

  
9 10
void input_get(struct chunk *c)
10 11
{
......
19 20
  c->attributes_size = 0;
20 21
  c->attributes = NULL;
21 22

  
22
  fprintf(stderr, "Generate Chunk[%d] (TS: %llu): %s\n", c->id, c->timestamp, c->data);
23
  dprintf("Generate Chunk[%d] (TS: %llu): %s\n", c->id, c->timestamp, c->data);
23 24
}
streaming.c
11 11
#include "streaming.h"
12 12
#include "output.h"
13 13
#include "input.h"
14
#include "dbg.h"
14 15

  
15 16
static struct chunk_buffer *cb;
16 17

  
......
58 59
  struct chunk *buff;
59 60
  int target, c, size;
60 61

  
61
  fprintf(stderr, "Send Chunk: %d neighbours\n", n);
62
  dprintf("Send Chunk: %d neighbours\n", n);
62 63
  if (n == 0) return;
63 64
  buff = cb_get_chunks(cb, &size);
64
  fprintf(stderr, "\t %d chunks in buffer...\n", size);
65
  dprintf("\t %d chunks in buffer...\n", size);
65 66
  if (size == 0) return;
66 67

  
67 68
  /************ STUPID DUMB SCHEDULING ****************/
68 69
  target = n * (rand() / (RAND_MAX + 1.0)); /*0..n-1*/
69 70
  c = size * (rand() / (RAND_MAX + 1.0)); /*0..size-1*/
70 71
  /************ /STUPID DUMB SCHEDULING ****************/
71
  fprintf(stderr, "\t sending chunk[%d]\n", buff[c].id);
72
  dprintf("\t sending chunk[%d]\n", buff[c].id);
72 73

  
73 74
  sendChunk(neighbours[target], buff + c);
74 75
}

Also available in: Unified diff