1 //===- FuzzerBuiltins.h - Internal header for builtins ----------*- C++ -* ===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 // Wrapper functions and marcos around builtin functions.
10 //===----------------------------------------------------------------------===//
11 
12 #ifndef LLVM_FUZZER_BUILTINS_H
13 #define LLVM_FUZZER_BUILTINS_H
14 
15 #include "FuzzerDefs.h"
16 
17 #if !LIBFUZZER_MSVC
18 #include <cstdint>
19 
20 #define GET_CALLER_PC() __builtin_return_address(0)
21 
22 namespace fuzzer {
23 
Bswap(uint8_t x)24 inline uint8_t  Bswap(uint8_t x)  { return x; }
Bswap(uint16_t x)25 inline uint16_t Bswap(uint16_t x) { return __builtin_bswap16(x); }
Bswap(uint32_t x)26 inline uint32_t Bswap(uint32_t x) { return __builtin_bswap32(x); }
Bswap(uint64_t x)27 inline uint64_t Bswap(uint64_t x) { return __builtin_bswap64(x); }
28 
Clzll(unsigned long long X)29 inline uint32_t Clzll(unsigned long long X) { return __builtin_clzll(X); }
Clz(unsigned long long X)30 inline uint32_t Clz(unsigned long long X) { return __builtin_clz(X); }
Popcountll(unsigned long long X)31 inline int Popcountll(unsigned long long X) { return __builtin_popcountll(X); }
32 
33 }  // namespace fuzzer
34 
35 #endif  // !LIBFUZZER_MSVC
36 #endif  // LLVM_FUZZER_BUILTINS_H
37