- COVERAGE_DEFINE__(COUNTER); \
- extern struct coverage_counter *counter_ptr_##COUNTER; \
- struct coverage_counter *counter_ptr_##COUNTER \
- __attribute__((section("coverage"))) = &counter_##COUNTER
-#else
-#define COVERAGE_DEFINE(MODULE) \
- extern struct coverage_counter counter_##MODULE
-#endif
+ DEFINE_STATIC_PER_THREAD_DATA(unsigned int, \
+ counter_##COUNTER, 0); \
+ static unsigned int COUNTER##_count(void) \
+ { \
+ unsigned int *countp = counter_##COUNTER##_get(); \
+ unsigned int count = *countp; \
+ *countp = 0; \
+ return count; \
+ } \
+ static inline void COUNTER##_add(unsigned int n) \
+ { \
+ *counter_##COUNTER##_get() += n; \
+ } \
+ extern struct coverage_counter counter_##COUNTER; \
+ struct coverage_counter counter_##COUNTER \
+ = { #COUNTER, COUNTER##_count, 0, 0, {0}, {0} }; \
+ OVS_CONSTRUCTOR(COUNTER##_init) { \
+ coverage_counter_register(&counter_##COUNTER); \
+ }