Annotation of embedaddon/php/ext/mysqlnd/mysqlnd_statistics.h, revision 1.1

1.1     ! misho       1: /*
        !             2:   +----------------------------------------------------------------------+
        !             3:   | PHP Version 5                                                        |
        !             4:   +----------------------------------------------------------------------+
        !             5:   | Copyright (c) 2006-2012 The PHP Group                                |
        !             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:   +----------------------------------------------------------------------+
        !            15:   | Authors: Georg Richter <georg@mysql.com>                             |
        !            16:   |          Andrey Hristov <andrey@mysql.com>                           |
        !            17:   |          Ulf Wendel <uwendel@mysql.com>                              |
        !            18:   +----------------------------------------------------------------------+
        !            19: */
        !            20: 
        !            21: /* $Id: mysqlnd_statistics.h 321634 2012-01-01 13:15:04Z felipe $ */
        !            22: 
        !            23: #ifndef MYSQLND_STATISTICS_H
        !            24: #define MYSQLND_STATISTICS_H
        !            25: 
        !            26: 
        !            27: PHPAPI extern MYSQLND_STATS * mysqlnd_global_stats;
        !            28: 
        !            29: typedef struct st_mysqlnd_string
        !            30: {
        !            31:        char    *s;
        !            32:        size_t  l;
        !            33: } MYSQLND_STRING;
        !            34: 
        !            35: extern const MYSQLND_STRING mysqlnd_stats_values_names[];
        !            36: 
        !            37: #ifdef ZTS
        !            38: #define MYSQLND_STATS_LOCK(stats) tsrm_mutex_lock((stats)->LOCK_access)
        !            39: #define MYSQLND_STATS_UNLOCK(stats) tsrm_mutex_unlock((stats)->LOCK_access)
        !            40: #else
        !            41: #define MYSQLND_STATS_LOCK(stats)
        !            42: #define MYSQLND_STATS_UNLOCK(stats)
        !            43: #endif
        !            44: 
        !            45: #ifndef MYSQLND_CORE_STATISTICS_TRIGGERS_DISABLED
        !            46: #define MYSQLND_STAT_CALL_TRIGGER(s_array, statistic, val) \
        !            47:                        if ((s_array)->triggers[(statistic)] && (s_array)->in_trigger == FALSE) { \
        !            48:                                (s_array)->in_trigger = TRUE; \
        !            49:                                MYSQLND_STATS_UNLOCK((s_array)); \
        !            50:                                                                                                                                                                                \
        !            51:                                (s_array)->triggers[(statistic)]((s_array), (statistic), (val) TSRMLS_CC); \
        !            52:                                                                                                                                                                                \
        !            53:                                MYSQLND_STATS_LOCK((s_array)); \
        !            54:                                (s_array)->in_trigger = FALSE; \
        !            55:                        } 
        !            56: #else
        !            57: #define MYSQLND_STAT_CALL_TRIGGER(s_array, statistic, val)
        !            58: #endif /* MYSQLND_CORE_STATISTICS_TRIGGERS_DISABLED */
        !            59: 
        !            60: #define MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(stats, statistic, value) \
        !            61:        { \
        !            62:                        MYSQLND_STATS_LOCK(stats); \
        !            63:                        (stats)->values[(statistic)] += (value); \
        !            64:                        MYSQLND_STAT_CALL_TRIGGER((stats), (statistic), (value)); \
        !            65:                        MYSQLND_STATS_UNLOCK(_p_s); \
        !            66:        }
        !            67: 
        !            68: #define MYSQLND_DEC_STATISTIC(enabler, stats, statistic) \
        !            69:  { \
        !            70:        enum_mysqlnd_collected_stats _s = (statistic);\
        !            71:        MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
        !            72:        if ((enabler) && _p_s && _s != _p_s->count) { \
        !            73:                MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s, -1); \
        !            74:        }\
        !            75:  }
        !            76: 
        !            77: #define MYSQLND_INC_STATISTIC(enabler, stats, statistic) \
        !            78:  { \
        !            79:        enum_mysqlnd_collected_stats _s = (statistic);\
        !            80:        MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
        !            81:        if ((enabler) && _p_s && _s != _p_s->count) { \
        !            82:                MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s, 1); \
        !            83:        }\
        !            84:  }
        !            85: 
        !            86: #define MYSQLND_INC_STATISTIC_W_VALUE(enabler, stats, statistic, value) \
        !            87:  { \
        !            88:        enum_mysqlnd_collected_stats _s = (statistic);\
        !            89:        MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
        !            90:        if ((enabler) && _p_s && _s != _p_s->count) { \
        !            91:                uint64_t v = (uint64_t) (value); \
        !            92:                MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s, v); \
        !            93:        }\
        !            94:  }
        !            95: 
        !            96: #define MYSQLND_INC_STATISTIC_W_VALUE2(enabler, stats, statistic1, value1, statistic2, value2) \
        !            97:  { \
        !            98:        MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
        !            99:        if ((enabler) && _p_s) { \
        !           100:                uint64_t v1 = (uint64_t) (value1); \
        !           101:                uint64_t v2 = (uint64_t) (value2); \
        !           102:                enum_mysqlnd_collected_stats _s1 = (statistic1);\
        !           103:                enum_mysqlnd_collected_stats _s2 = (statistic2);\
        !           104:                if (_s1 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s1, v1); \
        !           105:                if (_s2 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s2, v2); \
        !           106:        }\
        !           107:  }
        !           108: 
        !           109: #define MYSQLND_INC_STATISTIC_W_VALUE3(enabler, stats, statistic1, value1, statistic2, value2, statistic3, value3) \
        !           110:  { \
        !           111:        MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
        !           112:        if ((enabler) && _p_s) { \
        !           113:                uint64_t v1 = (uint64_t) (value1); \
        !           114:                uint64_t v2 = (uint64_t) (value2); \
        !           115:                uint64_t v3 = (uint64_t) (value3); \
        !           116:                enum_mysqlnd_collected_stats _s1 = (statistic1);\
        !           117:                enum_mysqlnd_collected_stats _s2 = (statistic2);\
        !           118:                enum_mysqlnd_collected_stats _s3 = (statistic3);\
        !           119:                if (_s1 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s1, v1); \
        !           120:                if (_s2 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s2, v2); \
        !           121:                if (_s3 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s3, v3); \
        !           122:        }\
        !           123:  }
        !           124: 
        !           125: 
        !           126: 
        !           127: #ifndef MYSQLND_CORE_STATISTICS_DISABLED
        !           128: 
        !           129: #define MYSQLND_INC_GLOBAL_STATISTIC(statistic) \
        !           130:        MYSQLND_INC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic))
        !           131: 
        !           132: #define MYSQLND_DEC_CONN_STATISTIC(conn_stats, statistic) \
        !           133:        MYSQLND_DEC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic))
        !           134: 
        !           135: #define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2, value2) \
        !           136:        MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2))
        !           137: 
        !           138: #define MYSQLND_INC_CONN_STATISTIC(conn_stats, statistic) \
        !           139:        MYSQLND_INC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic)); \
        !           140:        MYSQLND_INC_STATISTIC(MYSQLND_G(collect_statistics), (conn_stats), (statistic));
        !           141: 
        !           142: #define MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn_stats, statistic, value) \
        !           143:        MYSQLND_INC_STATISTIC_W_VALUE(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic), (value)); \
        !           144:        MYSQLND_INC_STATISTIC_W_VALUE(MYSQLND_G(collect_statistics), (conn_stats), (statistic), (value));
        !           145: 
        !           146: #define MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats, statistic1, value1, statistic2, value2) \
        !           147:        MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2)); \
        !           148:        MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), (conn_stats), (statistic1), (value1), (statistic2), (value2));
        !           149: 
        !           150: #define MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats, statistic1, value1, statistic2, value2, statistic3, value3) \
        !           151:        MYSQLND_INC_STATISTIC_W_VALUE3(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2), (statistic3), (value3)); \
        !           152:        MYSQLND_INC_STATISTIC_W_VALUE3(MYSQLND_G(collect_statistics), (conn_stats), (statistic1), (value1), (statistic2), (value2), (statistic3), (value3));
        !           153: 
        !           154: #else
        !           155: 
        !           156: #define MYSQLND_INC_GLOBAL_STATISTIC(statistic) 
        !           157: #define MYSQLND_DEC_CONN_STATISTIC(conn_stats, statistic)
        !           158: #define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2, value2)
        !           159: #define MYSQLND_INC_CONN_STATISTIC(conn_stats, statistic)
        !           160: #define MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn_stats, statistic, value)
        !           161: #define MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats, statistic1, value1, statistic2, value2)
        !           162: #define MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats, statistic1, value1, statistic2, value2, statistic3, value3)
        !           163: 
        !           164: #endif /* MYSQLND_CORE_STATISTICS_DISABLED */
        !           165: 
        !           166: PHPAPI void mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, const MYSQLND_STRING * names, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC);
        !           167: 
        !           168: PHPAPI void mysqlnd_stats_init(MYSQLND_STATS ** stats, size_t statistic_count);
        !           169: PHPAPI void mysqlnd_stats_end(MYSQLND_STATS * stats);
        !           170: 
        !           171: PHPAPI mysqlnd_stat_trigger mysqlnd_stats_set_trigger(MYSQLND_STATS * const stats, enum_mysqlnd_collected_stats stat, mysqlnd_stat_trigger trigger TSRMLS_DC);
        !           172: PHPAPI mysqlnd_stat_trigger mysqlnd_stats_reset_triggers(MYSQLND_STATS * const stats TSRMLS_DC);
        !           173: 
        !           174: #endif /* MYSQLND_STATISTICS_H */
        !           175: 
        !           176: /*
        !           177:  * Local variables:
        !           178:  * tab-width: 4
        !           179:  * c-basic-offset: 4
        !           180:  * End:
        !           181:  * vim600: noet sw=4 ts=4 fdm=marker
        !           182:  * vim<600: noet sw=4 ts=4
        !           183:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>