blob: a80938d9a54d730320febee4cb895c9aca26f5fd [file] [log] [blame]
metzman40132972019-01-09 21:46:09 +00001//===- 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
22namespace fuzzer {
23
24inline uint8_t Bswap(uint8_t x) { return x; }
25inline uint16_t Bswap(uint16_t x) { return __builtin_bswap16(x); }
26inline uint32_t Bswap(uint32_t x) { return __builtin_bswap32(x); }
27inline uint64_t Bswap(uint64_t x) { return __builtin_bswap64(x); }
28
29inline uint32_t Clzll(unsigned long long X) { return __builtin_clzll(X); }
30inline uint32_t Clz(unsigned long long X) { return __builtin_clz(X); }
31inline 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