[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [RFC] STATS_INC macro
From: |
Jani Monoses |
Subject: |
[lwip-devel] [RFC] STATS_INC macro |
Date: |
Wed, 22 Oct 2003 13:27:45 +0300 |
Hi all
Does this look a reasonable way to you to replace ifdef LWIP_STATS/
incr counter with macros?
It works with gcc but I am not sure if it works with all
preprocessors...it should though '.' is a regular operator.
As an example slipif.c uses the new macro
thoughts?
Jani
diff -u -r1.7 stats.h
--- src/include/lwip/stats.h 19 Mar 2003 12:37:46 -0000 1.7
+++ src/include/lwip/stats.h 22 Oct 2003 08:32:15 -0000
@@ -101,9 +101,21 @@
void stats_init(void);
+
+#define STATS_INC(x) ++lwip_stats.x
#else
#define stats_init()
+#define STATS_INC(x)
#endif /* LWIP_STATS */
+
+#ifdef TCP_STATS
+#define TCP_STATS_INC(x) STATS_INC(x)
+#endif
+
+#ifdef LINK_STATS
+#define LINK_STATS_INC(x) STATS_INC(x)
+#endif
+
#endif /* __LWIP_STATS_H__ */
cvs server: Diffing src/include/netif
cvs server: Diffing src/netif
Index: src/netif/slipif.c
===================================================================
RCS file: /cvsroot/lwip/lwip/src/netif/slipif.c,v
retrieving revision 1.12.2.1
diff -u -r1.12.2.1 slipif.c
--- src/netif/slipif.c 19 Jun 2003 10:24:32 -0000 1.12.2.1
+++ src/netif/slipif.c 22 Oct 2003 08:32:16 -0000
@@ -115,9 +115,7 @@
/* Received whole packet. */
pbuf_realloc(q, recved);
-#ifdef LINK_STATS
- ++lwip_stats.link.recv;
-#endif /* LINK_STATS */
+ LINK_STATS_INC(link.recv);
LWIP_DEBUGF(SLIP_DEBUG, ("slipif: Got packet\n"));
return q;
@@ -141,12 +139,10 @@
LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: alloc\n"));
p = pbuf_alloc(PBUF_LINK, PBUF_POOL_BUFSIZE, PBUF_POOL);
-#ifdef LINK_STATS
if (p == NULL) {
- ++lwip_stats.link.drop;
+ LINK_STATS_INC(link.drop);
LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: no new pbuf! (DROP)\n"));
}
-#endif /* LINK_STATS */
if (q != NULL) {
pbuf_chain(q, p);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-devel] [RFC] STATS_INC macro,
Jani Monoses <=