10b57cec5SDimitry Andric //===- FuzzerBuiltins.h - Internal header for builtins ----------*- C++ -* ===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // Wrapper functions and marcos around builtin functions. 90b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 100b57cec5SDimitry Andric 110b57cec5SDimitry Andric #ifndef LLVM_FUZZER_BUILTINS_H 120b57cec5SDimitry Andric #define LLVM_FUZZER_BUILTINS_H 130b57cec5SDimitry Andric 14*5ffd83dbSDimitry Andric #include "FuzzerPlatform.h" 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #if !LIBFUZZER_MSVC 170b57cec5SDimitry Andric #include <cstdint> 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric #define GET_CALLER_PC() __builtin_return_address(0) 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric namespace fuzzer { 220b57cec5SDimitry Andric Bswap(uint8_t x)230b57cec5SDimitry Andricinline uint8_t Bswap(uint8_t x) { return x; } Bswap(uint16_t x)240b57cec5SDimitry Andricinline uint16_t Bswap(uint16_t x) { return __builtin_bswap16(x); } Bswap(uint32_t x)250b57cec5SDimitry Andricinline uint32_t Bswap(uint32_t x) { return __builtin_bswap32(x); } Bswap(uint64_t x)260b57cec5SDimitry Andricinline uint64_t Bswap(uint64_t x) { return __builtin_bswap64(x); } 270b57cec5SDimitry Andric Clzll(unsigned long long X)280b57cec5SDimitry Andricinline uint32_t Clzll(unsigned long long X) { return __builtin_clzll(X); } Popcountll(unsigned long long X)290b57cec5SDimitry Andricinline int Popcountll(unsigned long long X) { return __builtin_popcountll(X); } 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric } // namespace fuzzer 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric #endif // !LIBFUZZER_MSVC 340b57cec5SDimitry Andric #endif // LLVM_FUZZER_BUILTINS_H 35