VirtualBox

Changeset 22403 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
Aug 24, 2009 7:12:48 AM (15 years ago)
Author:
vboxsync
Message:

NAT: (de-)register counter macrodifinitions was introduced.

Location:
trunk/src/VBox/Devices/Network/slirp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/counters.h

    r22402 r22403  
    2424 */
    2525
    26 #if !defined(PROFILE_COUNTER) && !defined(DRV_PROFILE_COUNTER)
    27 # error (DRV_)PROFILE_COUNTER is not defied
     26/*
     27 * COUNTERS_INIT is used before using counters.h to declare helping macro
     28 * definitions for (de-)registering counters
     29 */
     30#ifndef COUNTERS_H
     31# define COUNTERS_H
     32# if defined(VBOX_WITH_STATISTICS)
     33#  define REGISTER_COUNTER(name, type, units, dsc)                  \
     34    do {                                                            \
     35        PDMDrvHlpSTAMRegisterF(pDrvIns,                             \
     36                               &pData->Stat ## name,                \
     37                               type,                                \
     38                               STAMVISIBILITY_ALWAYS,               \
     39                               units,                               \
     40                               dsc,                                 \
     41                               "/Drivers/NAT%u/" #name,             \
     42                               pDrvIns->iInstance);                 \
     43    } while (0)
     44#  define DEREGISTER_COUNTER(name) PDMDrvHlpSTAMDeregister(pDrvIns, &pData->Stat ## name)
     45# else
     46#  define REGISTER_COUNTER(name, type, units, dsc) do {} while (0)
     47#  define DEREGISTER_COUNTER(name) do {} while (0)
     48# endif
    2849#endif
    29 #if !defined(COUNTING_COUNTER) && !defined(DRV_COUNTING_COUNTER)
    30 # error (DRV_)COUNTING_COUNTER is not defined
    31 #endif
     50
     51#ifndef COUNTERS_INIT
     52# if !defined(PROFILE_COUNTER) && !defined(DRV_PROFILE_COUNTER)
     53#  error (DRV_)PROFILE_COUNTER is not defied
     54# endif
     55# if !defined(COUNTING_COUNTER) && !defined(DRV_COUNTING_COUNTER)
     56#  error (DRV_)COUNTING_COUNTER is not defined
     57# endif
    3258
    3359/*
    3460 * DRV_ prefixed are counters used in DrvNAT the rest are used in Slirp
    3561 */
    36 #ifdef DRV_PROFILE_COUNTER
    37 # define PROFILE_COUNTER(name, dsc) do {} while (0)
    38 #endif
    39 #ifdef DRV_COUNTING_COUNTER
    40 # define COUNTING_COUNTER(name, dsc) do {} while (0)
    41 #endif
     62# ifdef DRV_PROFILE_COUNTER
     63#  define PROFILE_COUNTER(name, dsc) do {} while (0)
     64# endif
     65# ifdef DRV_COUNTING_COUNTER
     66#  define COUNTING_COUNTER(name, dsc) do {} while (0)
     67# endif
    4268
    43 #ifdef PROFILE_COUNTER
    44 # define DRV_PROFILE_COUNTER(name, dsc) do {} while (0)
    45 #endif
    46 #ifdef COUNTING_COUNTER
    47 # define DRV_COUNTING_COUNTER(name, dsc) do {} while (0)
    48 #endif
     69# ifdef PROFILE_COUNTER
     70#  define DRV_PROFILE_COUNTER(name, dsc) do {} while (0)
     71# endif
     72# ifdef COUNTING_COUNTER
     73#  define DRV_COUNTING_COUNTER(name, dsc) do {} while (0)
     74# endif
    4975
    5076PROFILE_COUNTER(Fill, "Profiling slirp fills");
     
    99125PROFILE_COUNTER(ALIAS_output, "ALIAS::output");
    100126
    101 #undef DRV_COUNTING_COUNTER
    102 #undef DRV_PROFILE_COUNTER
     127# undef DRV_COUNTING_COUNTER
     128# undef DRV_PROFILE_COUNTER
    103129
    104 #undef COUNTING_COUNTER
    105 #undef PROFILE_COUNTER
     130# undef COUNTING_COUNTER
     131# undef PROFILE_COUNTER
     132#endif /*!COUNTERS_INIT*/
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r22315 r22403  
    1616#endif
    1717#include <alias.h>
     18#define COUNTERS_INIT
     19#include "counters.h"
    1820
    1921#if !defined(RT_OS_WINDOWS)
     
    566568{
    567569#ifdef VBOX_WITH_STATISTICS
    568 # define COUNTER(name, type, units, dsc)                            \
    569     do {                                                            \
    570         PDMDrvHlpSTAMRegisterF(pDrvIns,                             \
    571                                &pData->Stat ## name,                \
    572                                type,                                \
    573                                STAMVISIBILITY_ALWAYS,               \
    574                                units,                               \
    575                                dsc,                                 \
    576                                "/Drivers/NAT%u/" #name,             \
    577                                pDrvIns->iInstance);                 \
    578     } while (0)
    579 
    580 # define PROFILE_COUNTER(name, dsc)     COUNTER(name, STAMTYPE_PROFILE, STAMUNIT_TICKS_PER_CALL, dsc)
    581 # define COUNTING_COUNTER(name, dsc)    COUNTER(name, STAMTYPE_COUNTER, STAMUNIT_COUNT,          dsc)
     570# define PROFILE_COUNTER(name, dsc)     REGISTER_COUNTER(name, STAMTYPE_PROFILE, STAMUNIT_TICKS_PER_CALL, dsc)
     571# define COUNTING_COUNTER(name, dsc)    REGISTER_COUNTER(name, STAMTYPE_COUNTER, STAMUNIT_COUNT,          dsc)
    582572
    583573# include "counters.h"
     
    598588{
    599589#ifdef VBOX_WITH_STATISTICS
    600 # define PROFILE_COUNTER(name, dsc)     PDMDrvHlpSTAMDeregister(pDrvIns, &pData->Stat ## name)
    601 # define COUNTING_COUNTER(name, dsc)    PDMDrvHlpSTAMDeregister(pDrvIns, &pData->Stat ## name)
     590# define PROFILE_COUNTER(name, dsc)     DEREGISTER_COUNTER(name)
     591# define COUNTING_COUNTER(name, dsc)    DEREGISTER_COUNTER(name)
    602592
    603593# include "counters.h"
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette