metzman | 4013297 | 2019-01-09 21:46:09 +0000 | [diff] [blame^] | 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 | |
| 24 | inline uint8_t Bswap(uint8_t x) { return x; } |
| 25 | inline uint16_t Bswap(uint16_t x) { return __builtin_bswap16(x); } |
| 26 | inline uint32_t Bswap(uint32_t x) { return __builtin_bswap32(x); } |
| 27 | inline uint64_t Bswap(uint64_t x) { return __builtin_bswap64(x); } |
| 28 | |
| 29 | inline uint32_t Clzll(unsigned long long X) { return __builtin_clzll(X); } |
| 30 | inline uint32_t Clz(unsigned long long X) { return __builtin_clz(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 |