| 1 | /* Copyright (c) 2008, 2023, 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 | This program is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License, version 2.0, for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with this program; if not, write to the Free Software Foundation, |
| 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ |
| 22 | |
| 23 | #include <my_global.h>cxx . . $ `<file>/include/my_global.h`/ |
| 24 | #include <my_sys.h>cxx . . $ `<file>/include/my_sys.h`/ |
| 25 | #include <pfs_global.h>cxx . . $ `<file>/storage/perfschema/pfs_global.h`/ |
| 26 | #include "aligned.h"cxx . . $ `<file>/include/aligned.h`/ |
| 27 | #include "assume_aligned.h"cxx . . $ `<file>/include/assume_aligned.h`/ |
| 28 | |
| 29 | bool pfs_initializedcxx . . $ pfs_initialized.= false; |
| 30 | |
| 31 | void *pfs_malloccxx . . $ pfs_malloc(6aa2a32eaa14783f).(PFS_builtin_memory_classcxx . . $ PFS_builtin_memory_class# *klass, size_t size, myfcxx . . $ myf# flags) |
| 32 | { |
| 33 | size= MY_ALIGNcxx . . $ `include/my_global.h:821:9`!(size, CPU_LEVEL1_DCACHE_LINESIZEcxx . . $ `include/my_global.h:1180:13`!); |
| 34 | void *ptr= aligned_malloccxx . . $ aligned_malloc(63a7bf2941bfcd7a).(size, CPU_LEVEL1_DCACHE_LINESIZEcxx . . $ `include/my_global.h:1180:13`!); |
| 35 | if (ptr && (flags & MY_ZEROFILLcxx . . $ `include/my_sys.h:87:9`!)) |
| 36 | memset_alignedcxx . . $ memset_aligned(d1de1e4fb215f1c6).<CPU_LEVEL1_DCACHE_LINESIZEcxx . . $ `include/my_global.h:1180:13`!>(ptr, 0, size); |
| 37 | return ptr; |
| 38 | } |
| 39 | |
| 40 | void pfs_freecxx . . $ pfs_free(ea99d79324896572).(PFS_builtin_memory_classcxx . . $ PFS_builtin_memory_class# *, size_t, void *ptr) |
| 41 | { |
| 42 | aligned_freecxx . . $ aligned_free(5d22bdacc48458e8).(ptr); |
| 43 | } |
| 44 | |
| 45 | void *pfs_malloc_arraycxx . . $ pfs_malloc_array(d1bbc11c2fb8274).(PFS_builtin_memory_classcxx . . $ PFS_builtin_memory_class# *klass, size_t n, size_t size, myfcxx . . $ myf# flags) |
| 46 | { |
| 47 | size_t array_size= n * size; |
| 48 | /* Check for overflow before allocating. */ |
| 49 | if (is_overflowcxx . . $ is_overflow(bc720f431d9350b0).(array_size, n, size)) |
| 50 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 51 | return pfs_malloccxx . . $ pfs_malloc(6aa2a32eaa14783f).(klass, array_size, flags); |
| 52 | } |
| 53 | |
| 54 | void pfs_free_arraycxx . . $ pfs_free_array(29e45b223abe5221).(PFS_builtin_memory_classcxx . . $ PFS_builtin_memory_class# *klass, size_t n, size_t size, void *ptr) |
| 55 | { |
| 56 | if (ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 57 | return; |
| 58 | size_t array_size= n * size; |
| 59 | return pfs_freecxx . . $ pfs_free(ea99d79324896572).(klass, array_size, ptr); |
| 60 | } |
| 61 | |
| 62 | bool is_overflowcxx . . $ is_overflow(bc720f431d9350b0).(size_t product, size_t n1, size_t n2) |
| 63 | { |
| 64 | if (n1 != 0 && (product / n1 != n2)) |
| 65 | return true; |
| 66 | else |
| 67 | return false; |
| 68 | } |
| 69 | |
| 70 | void pfs_print_errorcxx . . $ pfs_print_error(326aeb464d16410c).(const char *format, ...) |
| 71 | { |
| 72 | /* Do not pollute the unit test output with annoying messages. */ |
| 73 | } |
| 74 |