summaryrefslogtreecommitdiff
path: root/storage/perfschema
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-03-29 09:53:15 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2022-03-29 09:53:15 +0300
commit020e7d89ebdcded3355c82cec93e0abef2898258 (patch)
tree4e25a2d8826cbe0ddac7ae564fe1c28b220f9925 /storage/perfschema
parent739002eec90efa73a3b77db1cc46b313e8ac1bfd (diff)
parent303448bc912486f4766129cc407a5077a3ca4359 (diff)
downloadmariadb-git-020e7d89ebdcded3355c82cec93e0abef2898258.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'storage/perfschema')
-rw-r--r--storage/perfschema/unittest/stub_pfs_global.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/storage/perfschema/unittest/stub_pfs_global.h b/storage/perfschema/unittest/stub_pfs_global.h
index 8a1f9216ba2..b7adbe33504 100644
--- a/storage/perfschema/unittest/stub_pfs_global.h
+++ b/storage/perfschema/unittest/stub_pfs_global.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -24,6 +25,9 @@
#include <my_sys.h>
#include <pfs_global.h>
#include <string.h>
+#ifdef HAVE_MEMALIGN
+# include <malloc.h>
+#endif
bool pfs_initialized= false;
@@ -43,7 +47,17 @@ void *pfs_malloc(size_t size, myf)
if (--stub_alloc_fails_after_count <= 0)
return NULL;
+#ifndef PFS_ALIGNEMENT
void *ptr= malloc(size);
+#elif defined HAVE_MEMALIGN
+ void *ptr= memalign(PFS_ALIGNEMENT, size);
+#elif defined HAVE_ALIGNED_MALLOC
+ void *ptr= _aligned_malloc(size, PFS_ALIGNEMENT);
+#else
+ void *ptr;
+ if (posix_memalign(&ptr, PFS_ALIGNEMENT, size))
+ ptr= NULL;
+#endif
if (ptr != NULL)
memset(ptr, 0, size);
return ptr;