xref: /freebsd/contrib/llvm-project/compiler-rt/lib/stats/stats.h (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric //===-- stats.h -------------------------------------------------*- 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 //
9*0b57cec5SDimitry Andric // Data definitions for sanitizer statistics gathering.
10*0b57cec5SDimitry Andric //
11*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
12*0b57cec5SDimitry Andric 
13*0b57cec5SDimitry Andric #ifndef SANITIZER_STATS_STATS_H
14*0b57cec5SDimitry Andric #define SANITIZER_STATS_STATS_H
15*0b57cec5SDimitry Andric 
16*0b57cec5SDimitry Andric #include "sanitizer_common/sanitizer_internal_defs.h"
17*0b57cec5SDimitry Andric 
18*0b57cec5SDimitry Andric namespace __sanitizer {
19*0b57cec5SDimitry Andric 
20*0b57cec5SDimitry Andric // Number of bits in data that are used for the sanitizer kind. Needs to match
21*0b57cec5SDimitry Andric // llvm::kSanitizerStatKindBits in
22*0b57cec5SDimitry Andric // llvm/include/llvm/Transforms/Utils/SanitizerStats.h
23*0b57cec5SDimitry Andric enum { kKindBits = 3 };
24*0b57cec5SDimitry Andric 
25*0b57cec5SDimitry Andric struct StatInfo {
26*0b57cec5SDimitry Andric   uptr addr;
27*0b57cec5SDimitry Andric   uptr data;
28*0b57cec5SDimitry Andric };
29*0b57cec5SDimitry Andric 
30*0b57cec5SDimitry Andric struct StatModule {
31*0b57cec5SDimitry Andric   StatModule *next;
32*0b57cec5SDimitry Andric   u32 size;
33*0b57cec5SDimitry Andric   StatInfo infos[1];
34*0b57cec5SDimitry Andric };
35*0b57cec5SDimitry Andric 
CountFromData(uptr data)36*0b57cec5SDimitry Andric inline uptr CountFromData(uptr data) {
37*0b57cec5SDimitry Andric   return data & ((1ull << (sizeof(uptr) * 8 - kKindBits)) - 1);
38*0b57cec5SDimitry Andric }
39*0b57cec5SDimitry Andric 
40*0b57cec5SDimitry Andric }
41*0b57cec5SDimitry Andric 
42*0b57cec5SDimitry Andric #endif
43