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 230b57cec5SDimitry Andric inline uint8_t Bswap(uint8_t x) { return x; } 240b57cec5SDimitry Andric inline uint16_t Bswap(uint16_t x) { return __builtin_bswap16(x); } 250b57cec5SDimitry Andric inline uint32_t Bswap(uint32_t x) { return __builtin_bswap32(x); } 260b57cec5SDimitry Andric inline uint64_t Bswap(uint64_t x) { return __builtin_bswap64(x); } 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric inline uint32_t Clzll(unsigned long long X) { return __builtin_clzll(X); } 290b57cec5SDimitry Andric inline uint32_t Clz(unsigned long long X) { return __builtin_clz(X); } 300b57cec5SDimitry Andric inline int Popcountll(unsigned long long X) { return __builtin_popcountll(X); } 310b57cec5SDimitry Andric 320b57cec5SDimitry Andric } // namespace fuzzer 330b57cec5SDimitry Andric 340b57cec5SDimitry Andric #endif // !LIBFUZZER_MSVC 350b57cec5SDimitry Andric #endif // LLVM_FUZZER_BUILTINS_H 36