Index: trunk/src/VBox/Devices/Network/slirp/misc.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/misc.c	(revision 88758)
+++ trunk/src/VBox/Devices/Network/slirp/misc.c	(revision 88759)
@@ -84,4 +84,5 @@
 
 #ifndef VBOX_NAT_TST_QUEUE
+
 /*
  * Set fd blocking and non-blocking
@@ -106,20 +107,15 @@
 }
 
-# if !defined(VBOX_NAT_MEM_DEBUG)
-#  if defined (LOG_ENABLED)
-#   undef LogFlowFunc
-#   define LogFlowFunc(x)
-
-#   undef LogFlowFuncEnter
-#   define LogFlowFuncEnter()
-
-#   undef LogFlowFuncLeave
-#   define LogFlowFuncLeave()
-
-#   undef Log2
-#   define Log2(x)
-#  endif /* !LOG_ENABLED */
-# else /* VBOX_NAT_MEM_DEBUG */
-# define NAT_MEM_LOG_ENABLED
+
+# if defined(VBOX_NAT_MEM_DEBUG)
+#  define NATMEM_LOG_FLOW_FUNC(a)        LogFlowFunc(a)
+#  define NATMEM_LOG_FLOW_FUNC_ENTER()   LogFlowFuncEnter()
+#  define NATMEM_LOG_FLOW_FUNC_LEAVE()   LogFlowFuncLeave()
+#  define NATMEM_LOG_2(a)                Log2(a)
+# else
+#  define NATMEM_LOG_FLOW_FUNC(a)        do { } while (0)
+#  define NATMEM_LOG_FLOW_FUNC_ENTER()   do { } while (0)
+#  define NATMEM_LOG_FLOW_FUNC_LEAVE()   do { } while (0)
+#  define NATMEM_LOG_2(a)                do { } while (0)
 # endif
 
@@ -136,5 +132,5 @@
 DECLINLINE(void) slirp_zone_check_and_send_pending(uma_zone_t zone)
 {
-    LogFlowFunc(("ENTER: zone:%R[mzone]\n", zone));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: zone:%R[mzone]\n", zone));
     if (   zone->fDoXmitPending
         && zone->master_zone == NULL)
@@ -148,5 +144,5 @@
         rc2 = RTCritSectEnter(&zone->csZone); AssertRC(rc2);
     }
-    LogFlowFuncLeave();
+    NATMEM_LOG_FLOW_FUNC_LEAVE();
 }
 
@@ -159,10 +155,5 @@
     int rc;
 
-    LogFlowFunc(("ENTER: %R[mzone], size:%d, pflags:%p, %RTbool\n", zone, size, pflags, fWait));
-# ifndef NAT_MEM_LOG_ENABLED
-    NOREF(size);
-    NOREF(pflags);
-    NOREF(fWait);
-# endif
+    NATMEM_LOG_FLOW_FUNC(("ENTER: %R[mzone], size:%d, pflags:%p, %RTbool\n", zone, size, pflags, fWait)); RT_NOREF(size, pflags, fWait);
     RTCritSectEnter(&zone->csZone);
     for (;;)
@@ -194,5 +185,5 @@
         {
             /* We're on the master zone and we can't allocate more. */
-            Log2(("NAT: no room on %s zone\n", zone->name));
+            NATMEM_LOG_2(("NAT: no room on %s zone\n", zone->name));
             /* AssertMsgFailed(("NAT: OOM!")); */
             zone->fDoXmitPending = true;
@@ -207,5 +198,5 @@
         {
             /* No room on master */
-            Log2(("NAT: no room on %s zone for %s zone\n", zone->master_zone->name, zone->name));
+            NATMEM_LOG_2(("NAT: no room on %s zone for %s zone\n", zone->master_zone->name, zone->name));
             break;
         }
@@ -230,5 +221,5 @@
     }
     RTCritSectLeave(&zone->csZone);
-    LogFlowFunc(("LEAVE: %p\n", ret));
+    NATMEM_LOG_FLOW_FUNC(("LEAVE: %p\n", ret));
     return ret;
 }
@@ -238,12 +229,8 @@
     struct item *it;
     uma_zone_t zone;
-# ifndef NAT_MEM_LOG_ENABLED
-    NOREF(size);
-    NOREF(flags);
-# endif
 
     Assert(item);
     it = &((struct item *)item)[-1];
-    LogFlowFunc(("ENTER: item:%p(%R[mzoneitem]), size:%d, flags:%RX8\n", item, it, size, flags));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: item:%p(%R[mzoneitem]), size:%d, flags:%RX8\n", item, it, size, flags)); RT_NOREF(size, flags);
     Assert(it->magic == ITEM_MAGIC);
     zone = it->zone;
@@ -266,5 +253,5 @@
     slirp_zone_check_and_send_pending(zone); /* may exit+enter the cs! */
     RTCritSectLeave(&zone->csZone);
-    LogFlowFuncLeave();
+    NATMEM_LOG_FLOW_FUNC_LEAVE();
 }
 
@@ -273,10 +260,6 @@
 {
     uma_zone_t zone = NULL;
-# ifndef NAT_MEM_LOG_ENABLED
-    NOREF(flags1);
-    NOREF(flags2);
-# endif
-    LogFlowFunc(("ENTER: name:%s size:%d, ctor:%p, dtor:%p, init:%p, fini:%p, flags1:%RX32, flags2:%RX32\n",
-                name, ctor, dtor, init, fini, flags1, flags2));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: name:%s size:%d, ctor:%p, dtor:%p, init:%p, fini:%p, flags1:%RX32, flags2:%RX32\n",
+                name, ctor, dtor, init, fini, flags1, flags2));  RT_NOREF(flags1, flags2);
     zone = RTMemAllocZ(sizeof(struct uma_zone));
     Assert((pData));
@@ -292,5 +275,5 @@
     zone->pfFree = slirp_uma_free;
     RTCritSectInit(&zone->csZone);
-    LogFlowFunc(("LEAVE: %R[mzone]\n", zone));
+    NATMEM_LOG_FLOW_FUNC(("LEAVE: %R[mzone]\n", zone));
     return zone;
 
@@ -301,10 +284,10 @@
     uma_zone_t zone;
     Assert(master);
-    LogFlowFunc(("ENTER: name:%s ctor:%p, dtor:%p, init:%p, fini:%p, master:%R[mzone]\n",
+    NATMEM_LOG_FLOW_FUNC(("ENTER: name:%s ctor:%p, dtor:%p, init:%p, fini:%p, master:%R[mzone]\n",
                 name, ctor, dtor, init, fini, master));
     zone = RTMemAllocZ(sizeof(struct uma_zone));
     if (zone == NULL)
     {
-        LogFlowFunc(("LEAVE: %R[mzone]\n", NULL));
+        NATMEM_LOG_FLOW_FUNC(("LEAVE: %R[mzone]\n", NULL));
         return NULL;
     }
@@ -323,5 +306,5 @@
     zone->master_zone = master;
     RTCritSectInit(&zone->csZone);
-    LogFlowFunc(("LEAVE: %R[mzone]\n", zone));
+    NATMEM_LOG_FLOW_FUNC(("LEAVE: %R[mzone]\n", zone));
     return zone;
 }
@@ -331,5 +314,5 @@
     int i = 0;
     struct item *it;
-    LogFlowFunc(("ENTER: zone:%R[mzone], max:%d\n", zone, max));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: zone:%R[mzone], max:%d\n", zone, max));
     zone->max_items = max;
     zone->area = RTMemAllocZ(max * (sizeof(struct item) + zone->size + sizeof(uint32_t)));
@@ -342,19 +325,19 @@
         LIST_INSERT_HEAD(&zone->free_items, it, list);
     }
-    LogFlowFuncLeave();
+    NATMEM_LOG_FLOW_FUNC_LEAVE();
 }
 
 void uma_zone_set_allocf(uma_zone_t zone, uma_alloc_t pfAlloc)
 {
-    LogFlowFunc(("ENTER: zone:%R[mzone], pfAlloc:%Rfn\n", zone, pfAlloc));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: zone:%R[mzone], pfAlloc:%Rfn\n", zone, pfAlloc));
     zone->pfAlloc = pfAlloc;
-    LogFlowFuncLeave();
+    NATMEM_LOG_FLOW_FUNC_LEAVE();
 }
 
 void uma_zone_set_freef(uma_zone_t zone, uma_free_t pfFree)
 {
-    LogFlowFunc(("ENTER: zone:%R[mzone], pfAlloc:%Rfn\n", zone, pfFree));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: zone:%R[mzone], pfAlloc:%Rfn\n", zone, pfFree));
     zone->pfFree = pfFree;
-    LogFlowFuncLeave();
+    NATMEM_LOG_FLOW_FUNC_LEAVE();
 }
 
@@ -364,8 +347,5 @@
     reference counters */
     struct item *it = NULL;
-# ifndef NAT_MEM_LOG_ENABLED
-    NOREF(zone);
-# endif
-    LogFlowFunc(("ENTER: zone:%R[mzone], mem:%p\n", zone, mem));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: zone:%R[mzone], mem:%p\n", zone, mem)); RT_NOREF(zone);
     it = (struct item *)mem; /* 1st element */
     Assert(mem != NULL);
@@ -373,5 +353,5 @@
     /* for returning pointer to counter we need get 0 elemnt */
     Assert(it[-1].magic == ITEM_MAGIC);
-    LogFlowFunc(("LEAVE: %p\n", &it[-1].ref_count));
+    NATMEM_LOG_FLOW_FUNC(("LEAVE: %p\n", &it[-1].ref_count));
     return &it[-1].ref_count;
 }
@@ -380,12 +360,9 @@
 {
     void *mem;
-# ifndef NAT_MEM_LOG_ENABLED
-    NOREF(how);
-# endif
     Assert(zone->magic == ZONE_MAGIC);
-    LogFlowFunc(("ENTER: zone:%R[mzone], args:%p, how:%RX32\n", zone, args, how));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: zone:%R[mzone], args:%p, how:%RX32\n", zone, args, how)); RT_NOREF(how);
     if (zone->pfAlloc == NULL)
     {
-        LogFlowFunc(("LEAVE: NULL\n"));
+        NATMEM_LOG_FLOW_FUNC(("LEAVE: NULL\n"));
         return NULL;
     }
@@ -398,5 +375,5 @@
     }
     RTCritSectLeave(&zone->csZone);
-    LogFlowFunc(("LEAVE: %p\n", mem));
+    NATMEM_LOG_FLOW_FUNC(("LEAVE: %p\n", mem));
     return mem;
 }
@@ -404,7 +381,7 @@
 void uma_zfree(uma_zone_t zone, void *item)
 {
-    LogFlowFunc(("ENTER: zone:%R[mzone], item:%p\n", zone, item));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: zone:%R[mzone], item:%p\n", zone, item));
     uma_zfree_arg(zone, item, NULL);
-    LogFlowFuncLeave();
+    NATMEM_LOG_FLOW_FUNC_LEAVE();
 }
 
@@ -415,8 +392,5 @@
     Assert((zone->pfFree));
     Assert((mem));
-    LogFlowFunc(("ENTER: zone:%R[mzone], mem:%p, flags:%p\n", zone, mem, flags));
-# ifndef NAT_MEM_LOG_ENABLED
-    NOREF(flags);
-# endif
+    NATMEM_LOG_FLOW_FUNC(("ENTER: zone:%R[mzone], mem:%p, flags:%p\n", zone, mem, flags)); RT_NOREF(flags);
 
     RTCritSectEnter(&zone->csZone);
@@ -425,7 +399,8 @@
     Assert((zone->magic == ZONE_MAGIC && zone == it->zone));
 
-    zone->pfFree(mem,  0, 0);
+    zone->pfFree(mem, 0, 0);
     RTCritSectLeave(&zone->csZone);
-    LogFlowFuncLeave();
+
+    NATMEM_LOG_FLOW_FUNC_LEAVE();
 }
 
@@ -433,9 +408,9 @@
 {
     int fExhausted;
-    LogFlowFunc(("ENTER: zone:%R[mzone]\n", zone));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: zone:%R[mzone]\n", zone));
     RTCritSectEnter(&zone->csZone);
     fExhausted = (zone->cur_items == zone->max_items);
     RTCritSectLeave(&zone->csZone);
-    LogFlowFunc(("LEAVE: %RTbool\n", fExhausted));
+    NATMEM_LOG_FLOW_FUNC(("LEAVE: %RTbool\n", fExhausted));
     return fExhausted;
 }
@@ -448,5 +423,5 @@
     /* vvl: Huh? What to do with zone which hasn't got backstore ? */
     Assert((zone->master_zone));
-    LogFlowFunc(("ENTER: zone:%R[mzone]\n", zone));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: zone:%R[mzone]\n", zone));
     master_zone = zone->master_zone;
     while (!LIST_EMPTY(&zone->free_items))
@@ -468,5 +443,5 @@
         RTCritSectLeave(&master_zone->csZone);
     }
-    LogFlowFuncLeave();
+    NATMEM_LOG_FLOW_FUNC_LEAVE();
 }
 
@@ -474,21 +449,16 @@
 {
     /** @todo (vvl) make it wiser  */
-    LogFlowFunc(("ENTER: mem:%p, arg:%p\n", mem, arg));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: mem:%p, arg:%p\n", mem, arg));
+    RT_NOREF(arg);
     Assert(mem);
-# ifndef NAT_MEM_LOG_ENABLED
-    NOREF(arg);
-# endif
     RTMemFree(mem);
-    LogFlowFuncLeave();
+    NATMEM_LOG_FLOW_FUNC_LEAVE();
 }
 
 void *uma_zalloc(uma_zone_t zone, int len)
 {
-# ifndef NAT_MEM_LOG_ENABLED
-    NOREF(zone);
-    NOREF(len);
-# endif
-    LogFlowFunc(("ENTER: zone:%R[mzone], len:%d\n", zone, len));
-    LogFlowFunc(("LEAVE: NULL"));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: zone:%R[mzone], len:%d\n", zone, len));
+    RT_NOREF(zone, len);
+    NATMEM_LOG_FLOW_FUNC(("LEAVE: NULL"));
     return NULL;
 }
@@ -498,5 +468,5 @@
     struct mbuf *m;
     int size = MCLBYTES;
-    LogFlowFunc(("ENTER: cbMin:%d, ppvBuf:%p, pcbBuf:%p\n", cbMin, ppvBuf, pcbBuf));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: cbMin:%d, ppvBuf:%p, pcbBuf:%p\n", cbMin, ppvBuf, pcbBuf));
 
     *ppvBuf = NULL;
@@ -512,5 +482,5 @@
     {
         AssertMsgFailed(("Unsupported size %zu", cbMin));
-        LogFlowFunc(("LEAVE: NULL (bad size %zu)\n", cbMin));
+        NATMEM_LOG_FLOW_FUNC(("LEAVE: NULL (bad size %zu)\n", cbMin));
         return NULL;
     }
@@ -519,5 +489,5 @@
     if (m == NULL)
     {
-        LogFlowFunc(("LEAVE: NULL\n"));
+        NATMEM_LOG_FLOW_FUNC(("LEAVE: NULL\n"));
         return NULL;
     }
@@ -525,5 +495,5 @@
     *ppvBuf = mtod(m, void *);
     *pcbBuf = size;
-    LogFlowFunc(("LEAVE: %p\n", m));
+    NATMEM_LOG_FLOW_FUNC(("LEAVE: %p\n", m));
     return m;
 }
@@ -532,10 +502,10 @@
 {
 
-    LogFlowFunc(("ENTER: m:%p, pu8Buf:%p\n", m, pu8Buf));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: m:%p, pu8Buf:%p\n", m, pu8Buf));
     if (   !pu8Buf
         && pu8Buf != mtod(m, uint8_t *))
         RTMemFree(pu8Buf); /* This buffer was allocated on heap */
     m_freem(pData, m);
-    LogFlowFuncLeave();
+    NATMEM_LOG_FLOW_FUNC_LEAVE();
 }
 
@@ -543,5 +513,5 @@
 {
     RTCritSectEnter(&zone->csZone);
-    LogFlowFunc(("ENTER: zone:%R[mzone]\n", zone));
+    NATMEM_LOG_FLOW_FUNC(("ENTER: zone:%R[mzone]\n", zone));
     LogRel(("NAT: Zone(nm:%s, used:%d)\n", zone->name, zone->cur_items));
     RTMemFree(zone->area);
@@ -549,10 +519,10 @@
     RTCritSectDelete(&zone->csZone);
     RTMemFree(zone);
-    LogFlowFuncLeave();
+    NATMEM_LOG_FLOW_FUNC_LEAVE();
 }
 
 void m_fini(PNATState pData)
 {
-    LogFlowFuncEnter();
+    NATMEM_LOG_FLOW_FUNC_ENTER();
 # define ZONE_DESTROY(zone) do { zone_destroy((zone)); (zone) = NULL;} while (0)
     ZONE_DESTROY(pData->zone_clust);
@@ -565,5 +535,5 @@
 # undef ZONE_DESTROY
     /** @todo do finalize here.*/
-    LogFlowFuncLeave();
+    NATMEM_LOG_FLOW_FUNC_LEAVE();
 }
 
@@ -577,3 +547,4 @@
     if_mru = 1500;
 }
+
 #endif /* VBOX_NAT_TST_QUEUE */
