1*5ffd83dbSDimitry Andric //===-- utilities.h ---------------------------------------------*- C++ -*-===// 2*5ffd83dbSDimitry Andric // 3*5ffd83dbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*5ffd83dbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*5ffd83dbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*5ffd83dbSDimitry Andric // 7*5ffd83dbSDimitry Andric //===----------------------------------------------------------------------===// 8*5ffd83dbSDimitry Andric 9*5ffd83dbSDimitry Andric #include "gwp_asan/definitions.h" 10*5ffd83dbSDimitry Andric 11*5ffd83dbSDimitry Andric #include <stddef.h> 12*5ffd83dbSDimitry Andric #include <stdint.h> 13*5ffd83dbSDimitry Andric 14*5ffd83dbSDimitry Andric namespace gwp_asan { 15*5ffd83dbSDimitry Andric // Checks that `Condition` is true, otherwise fails in a platform-specific way 16*5ffd83dbSDimitry Andric // with `Message`. 17*5ffd83dbSDimitry Andric void Check(bool Condition, const char *Message); 18*5ffd83dbSDimitry Andric 19*5ffd83dbSDimitry Andric enum class AlignmentStrategy { 20*5ffd83dbSDimitry Andric // Default => POWER_OF_TWO on most platforms, BIONIC for Android Bionic. 21*5ffd83dbSDimitry Andric DEFAULT, 22*5ffd83dbSDimitry Andric POWER_OF_TWO, 23*5ffd83dbSDimitry Andric BIONIC, 24*5ffd83dbSDimitry Andric PERFECT, 25*5ffd83dbSDimitry Andric }; 26*5ffd83dbSDimitry Andric 27*5ffd83dbSDimitry Andric // Returns the real size of a right-aligned allocation. 28*5ffd83dbSDimitry Andric size_t rightAlignedAllocationSize( 29*5ffd83dbSDimitry Andric size_t RealAllocationSize, 30*5ffd83dbSDimitry Andric AlignmentStrategy Align = AlignmentStrategy::DEFAULT); 31*5ffd83dbSDimitry Andric } // namespace gwp_asan 32