MySQL 8.4.2
Source Code Documentation
pfs_global.h File Reference

Miscellaneous global dependencies (declarations). More...

#include "my_config.h"
#include <atomic>
#include <stddef.h>
#include <sys/socket.h>
#include <sys/types.h>
#include "my_compiler.h"
#include "my_inttypes.h"
#include "sql/thr_malloc.h"
#include <mysql/components/services/mysql_server_telemetry_traces_service.h>

Go to the source code of this file.

Classes

struct  PFS_cacheline_atomic_uint32
 An atomic uint32 variable, guaranteed to be alone in a CPU cache line. More...
 
struct  PFS_cacheline_atomic_uint64
 An atomic uint64 variable, guaranteed to be alone in a CPU cache line. More...
 
struct  PFS_cacheline_atomic_size_t
 An atomic size_t variable, guaranteed to be alone in a CPU cache line. More...
 
struct  PFS_cacheline_atomic_ptr< T >
 An atomic<T> variable, guaranteed to be alone in a CPU cache line. More...
 

Macros

#define PFS_ALIGNEMENT   64
 
#define PFS_ALIGNED   alignas(PFS_ALIGNEMENT)
 
#define PFS_CACHE_LINE_SIZE   CPU_LEVEL1_DCACHE_LINESIZE
 
#define PFS_MALLOC_ARRAY(k, n, s, T, f)    reinterpret_cast<T *>(pfs_malloc_array((k), (n), (s), (f)))
 Helper, to allocate an array of structures. More...
 
#define PFS_FREE_ARRAY(k, n, s, p)   pfs_free_array((k), (n), (s), (p))
 Helper, to free an array of structures. More...
 
#define PFS_NEW(CLASS)   (new (*THR_MALLOC) CLASS())
 Helper to allocate an object from mem_root. More...
 
#define SANITIZE_ARRAY_BODY(T, ARRAY, MAX, UNSAFE)
 Given an array defined as T ARRAY[MAX], check that an UNSAFE pointer actually points to an element within the array. More...
 

Functions

void * pfs_malloc (PFS_builtin_memory_class *klass, size_t size, myf flags)
 Memory allocation for the performance schema. More...
 
void * pfs_malloc_array (PFS_builtin_memory_class *klass, size_t n, size_t size, myf flags)
 Allocate an array of structures with overflow check. More...
 
void pfs_free (PFS_builtin_memory_class *klass, size_t size, void *ptr)
 Free memory allocated with. More...
 
void pfs_free_array (PFS_builtin_memory_class *klass, size_t n, size_t size, void *ptr)
 Free memory allocated with. More...
 
bool is_overflow (size_t product, size_t n1, size_t n2)
 Detect multiplication overflow. More...
 
uint pfs_get_socket_address (char *host, uint host_len, uint *port, const struct sockaddr_storage *src_addr, socklen_t src_len)
 Convert raw ip address into readable format. More...
 
void pfs_print_error (const char *format,...)
 

Variables

bool pfs_initialized
 True when the performance schema is initialized. More...
 

Detailed Description

Miscellaneous global dependencies (declarations).

Macro Definition Documentation

◆ PFS_ALIGNED

#define PFS_ALIGNED   alignas(PFS_ALIGNEMENT)

◆ PFS_ALIGNEMENT

#define PFS_ALIGNEMENT   64

◆ PFS_CACHE_LINE_SIZE

#define PFS_CACHE_LINE_SIZE   CPU_LEVEL1_DCACHE_LINESIZE

◆ PFS_FREE_ARRAY

#define PFS_FREE_ARRAY (   k,
  n,
  s,
  p 
)    pfs_free_array((k), (n), (s), (p))

Helper, to free an array of structures.

Parameters
kmemory class
nnumber of elements in the array
ssize of array element
pthe array to free

◆ PFS_MALLOC_ARRAY

#define PFS_MALLOC_ARRAY (   k,
  n,
  s,
  T,
 
)     reinterpret_cast<T *>(pfs_malloc_array((k), (n), (s), (f)))

Helper, to allocate an array of structures.

Parameters
kmemory class
nnumber of elements in the array
ssize of array element
Ttype of an element
fflags to use when allocating memory

◆ PFS_NEW

#define PFS_NEW (   CLASS)    (new (*THR_MALLOC) CLASS())

Helper to allocate an object from mem_root.

Parameters
CLASSClass to instantiate

◆ SANITIZE_ARRAY_BODY

#define SANITIZE_ARRAY_BODY (   T,
  ARRAY,
  MAX,
  UNSAFE 
)
Value:
intptr offset; \
if ((&ARRAY[0] <= UNSAFE) && (UNSAFE < &ARRAY[MAX])) { \
offset = ((intptr)UNSAFE - (intptr)ARRAY) % sizeof(T); \
if (offset == 0) { \
return UNSAFE; \
} \
} \
return NULL
#define MAX(a, b)
Definition: crypt_genhash_impl.cc:86
intptr_t intptr
Definition: my_inttypes.h:70
#define UNSAFE(a, b, c)
Definition: sql_lex.cc:5045
#define NULL
Definition: types.h:55

Given an array defined as T ARRAY[MAX], check that an UNSAFE pointer actually points to an element within the array.

Function Documentation

◆ is_overflow()

bool is_overflow ( size_t  product,
size_t  n1,
size_t  n2 
)

Detect multiplication overflow.

Parameters
productmultiplication product
n1operand
n2operand
Returns
true if multiplication caused an overflow.

◆ pfs_free()

void pfs_free ( PFS_builtin_memory_class klass,
size_t  size,
void *  ptr 
)

Free memory allocated with.

See also
pfs_malloc.

◆ pfs_free_array()

void pfs_free_array ( PFS_builtin_memory_class klass,
size_t  n,
size_t  size,
void *  ptr 
)

Free memory allocated with.

See also
pfs_malloc_array.

Free memory allocated with.

See also
pfs_malloc_array.
Parameters
klassperformance schema memory class
nnumber of array elements
sizeelement size
ptrpointer to memory

◆ pfs_get_socket_address()

uint pfs_get_socket_address ( char *  host,
uint  host_len,
uint *  port,
const struct sockaddr_storage *  src_addr,
socklen_t  src_len 
)

Convert raw ip address into readable format.

Do not do a reverse DNS lookup.

◆ pfs_malloc()

void * pfs_malloc ( PFS_builtin_memory_class klass,
size_t  size,
myf  flags 
)

Memory allocation for the performance schema.

The memory used internally in the performance schema implementation. It is allocated at startup, or during runtime with scalable buffers.

◆ pfs_malloc_array()

void * pfs_malloc_array ( PFS_builtin_memory_class klass,
size_t  n,
size_t  size,
myf  flags 
)

Allocate an array of structures with overflow check.

Allocate an array of structures with overflow check.

Checks for overflow of n * size before allocating.

Parameters
klassperformance schema memory class
nnumber of array elements
sizeelement size
flagsmalloc flags
Returns
pointer to memory on success, else nullptr

◆ pfs_print_error()

void pfs_print_error ( const char *  format,
  ... 
)

Variable Documentation

◆ pfs_initialized

bool pfs_initialized
extern

True when the performance schema is initialized.