2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_SHM_COUNTER_H_
18 #define incl_HPHP_SHM_COUNTER_H_
22 // #define ENABLE_SHM_COUNTER
24 #define SHM_COUNTER_KEY 768
26 #define SHM_COUNTER_DEF(n) ShmCounter n;
27 #define SHM_COUNTER_INI(n) n(#n),
30 ///////////////////////////////////////////////////////////////////////////////
34 explicit ShmCounter(const char *n
) : count(0) {
35 size_t size
= sizeof(name
);
36 strncpy(name
, n
, size
);
37 name
[size
- 1] = '\0';
44 SHM_COUNTER_DEF(dummy_def1
)
45 SHM_COUNTER_DEF(dummy_def2
)
46 // Add your real counter definition here
49 SHM_COUNTER_DEF(dummy_defmax
)
52 SHM_COUNTER_INI(dummy_def1
)
53 SHM_COUNTER_INI(dummy_def2
)
54 // Add your real counter initialization here
56 dummy_defmax("dummy_defmax")
61 typedef void (*logError_t
)(const char *fmt
, ...);
62 static bool initialize(bool create
, logError_t logError
= nullptr);
67 static logError_t logError
;
68 static ShmCounters
*s_shmCounters
;
71 ///////////////////////////////////////////////////////////////////////////////
74 #endif // incl_HPHP_SHM_COUNTER_H_