1*0b57cec5SDimitry Andric //===- FuzzerBuiltins.h - Internal header for builtins ----------*- C++ -* ===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric // Wrapper functions and marcos around builtin functions. 9*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 10*0b57cec5SDimitry Andric 11*0b57cec5SDimitry Andric #ifndef LLVM_FUZZER_BUILTINS_H 12*0b57cec5SDimitry Andric #define LLVM_FUZZER_BUILTINS_H 13*0b57cec5SDimitry Andric 14*0b57cec5SDimitry Andric #include "FuzzerDefs.h" 15*0b57cec5SDimitry Andric 16*0b57cec5SDimitry Andric #if !LIBFUZZER_MSVC 17*0b57cec5SDimitry Andric #include <cstdint> 18*0b57cec5SDimitry Andric 19*0b57cec5SDimitry Andric #define GET_CALLER_PC() __builtin_return_address(0) 20*0b57cec5SDimitry Andric 21*0b57cec5SDimitry Andric namespace fuzzer { 22*0b57cec5SDimitry Andric 23*0b57cec5SDimitry Andric inline uint8_t Bswap(uint8_t x) { return x; } 24*0b57cec5SDimitry Andric inline uint16_t Bswap(uint16_t x) { return __builtin_bswap16(x); } 25*0b57cec5SDimitry Andric inline uint32_t Bswap(uint32_t x) { return __builtin_bswap32(x); } 26*0b57cec5SDimitry Andric inline uint64_t Bswap(uint64_t x) { return __builtin_bswap64(x); } 27*0b57cec5SDimitry Andric 28*0b57cec5SDimitry Andric inline uint32_t Clzll(unsigned long long X) { return __builtin_clzll(X); } 29*0b57cec5SDimitry Andric inline uint32_t Clz(unsigned long long X) { return __builtin_clz(X); } 30*0b57cec5SDimitry Andric inline int Popcountll(unsigned long long X) { return __builtin_popcountll(X); } 31*0b57cec5SDimitry Andric 32*0b57cec5SDimitry Andric } // namespace fuzzer 33*0b57cec5SDimitry Andric 34*0b57cec5SDimitry Andric #endif // !LIBFUZZER_MSVC 35*0b57cec5SDimitry Andric #endif // LLVM_FUZZER_BUILTINS_H 36