1 /* Copyright (c) 2013, 2021, Oracle and/or its affiliates. 2 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License, version 2.0, 5 as published by the Free Software Foundation. 6 7 This program is also distributed with certain software (including 8 but not limited to OpenSSL) that is licensed under separate terms, 9 as designated in a particular file or component or in included license 10 documentation. The authors of MySQL hereby grant you an additional 11 permission to link the program and your derivative works with the 12 separately licensed software that they have included with MySQL. 13 14 Without limiting anything contained in the foregoing, this file, 15 which is part of C Driver for MySQL (Connector/C), is also subject to the 16 Universal FOSS Exception, version 1.0, a copy of which can be found at 17 http://oss.oracle.com/licenses/universal-foss-exception. 18 19 This program is distributed in the hope that it will be useful, 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 GNU General Public License, version 2.0, for more details. 23 24 You should have received a copy of the GNU General Public License 25 along with this program; if not, write to the Free Software Foundation, 26 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 27 28 #ifndef MYSQL_PSI_MEMORY_H 29 #define MYSQL_PSI_MEMORY_H 30 31 #include "psi_base.h" 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /** 38 @file mysql/psi/psi_memory.h 39 Performance schema instrumentation interface. 40 41 @defgroup Instrumentation_interface Instrumentation Interface 42 @ingroup Performance_schema 43 @{ 44 */ 45 46 #ifdef HAVE_PSI_INTERFACE 47 #ifndef DISABLE_ALL_PSI 48 #ifndef DISABLE_PSI_MEMORY 49 #define HAVE_PSI_MEMORY_INTERFACE 50 #endif /* DISABLE_PSI_MEMORY */ 51 #endif /* DISABLE_ALL_PSI */ 52 #endif /* HAVE_PSI_INTERFACE */ 53 54 struct PSI_thread; 55 56 /** 57 Instrumented memory key. 58 To instrument memory, a memory key must be obtained using @c register_memory. 59 Using a zero key always disable the instrumentation. 60 */ 61 typedef unsigned int PSI_memory_key; 62 63 #ifdef HAVE_PSI_1 64 65 /** 66 @defgroup Group_PSI_v1 Application Binary Interface, version 1 67 @ingroup Instrumentation_interface 68 @{ 69 */ 70 71 /** 72 Memory instrument information. 73 @since PSI_VERSION_1 74 This structure is used to register instrumented memory. 75 */ 76 struct PSI_memory_info_v1 77 { 78 /** Pointer to the key assigned to the registered memory. */ 79 PSI_memory_key *m_key; 80 /** The name of the memory instrument to register. */ 81 const char *m_name; 82 /** 83 The flags of the socket instrument to register. 84 @sa PSI_FLAG_GLOBAL 85 */ 86 int m_flags; 87 }; 88 typedef struct PSI_memory_info_v1 PSI_memory_info_v1; 89 90 /** 91 Memory registration API. 92 @param category a category name (typically a plugin name) 93 @param info an array of memory info to register 94 @param count the size of the info array 95 */ 96 typedef void (*register_memory_v1_t) 97 (const char *category, struct PSI_memory_info_v1 *info, int count); 98 99 /** 100 Instrument memory allocation. 101 @param key the memory instrument key 102 @param size the size of memory allocated 103 @param[out] owner the memory owner 104 @return the effective memory instrument key 105 */ 106 typedef PSI_memory_key (*memory_alloc_v1_t) 107 (PSI_memory_key key, size_t size, struct PSI_thread ** owner); 108 109 /** 110 Instrument memory re allocation. 111 @param key the memory instrument key 112 @param old_size the size of memory previously allocated 113 @param new_size the size of memory re allocated 114 @param[in, out] owner the memory owner 115 @return the effective memory instrument key 116 */ 117 typedef PSI_memory_key (*memory_realloc_v1_t) 118 (PSI_memory_key key, size_t old_size, size_t new_size, struct PSI_thread ** owner); 119 120 /** 121 Instrument memory claim. 122 @param key the memory instrument key 123 @param size the size of memory allocated 124 @param[in, out] owner the memory owner 125 @return the effective memory instrument key 126 */ 127 typedef PSI_memory_key (*memory_claim_v1_t) 128 (PSI_memory_key key, size_t size, struct PSI_thread ** owner); 129 130 /** 131 Instrument memory free. 132 @param key the memory instrument key 133 @param size the size of memory allocated 134 @param owner the memory owner 135 */ 136 typedef void (*memory_free_v1_t) 137 (PSI_memory_key key, size_t size, struct PSI_thread * owner); 138 139 /** @} (end of group Group_PSI_v1) */ 140 141 #endif /* HAVE_PSI_1 */ 142 143 #ifdef HAVE_PSI_2 144 struct PSI_memory_info_v2 145 { 146 int placeholder; 147 }; 148 149 #endif /* HAVE_PSI_2 */ 150 151 #ifdef USE_PSI_1 152 typedef struct PSI_memory_info_v1 PSI_memory_info; 153 #endif 154 155 #ifdef USE_PSI_2 156 typedef struct PSI_memory_info_v2 PSI_memory_info; 157 #endif 158 159 /** @} (end of group Instrumentation_interface) */ 160 161 #ifdef __cplusplus 162 } 163 #endif 164 165 166 #endif /* MYSQL_PSI_MEMORY_H */ 167 168