"""
# Module LinuxKernelPerfAPI

This module is an autogenerated set of constants and enums defined
mostly by C preprocessor macros in the Linux kernel header files.

These definitions are kernel version and architecture dependent.

Autogeneration from Linux 4.4.49 header files took place on Apr 23 2017 at 15:33:40.
"""
module LinuxKernelPerfAPI

const LINUX_VERSION_CODE = 263217
const LINUX_KERNEL_VERSION = v"4.4.49"

# syscall ids
const __NR_perf_event_open = 298
const __NR_getcpu = 309
const __NR_getpid = 39
const __NR_gettid = 186

@enum( perf_type_id::UInt32
     , PERF_TYPE_HARDWARE = 0
     , PERF_TYPE_SOFTWARE = 1
     , PERF_TYPE_TRACEPOINT = 2
     , PERF_TYPE_HW_CACHE = 3
     , PERF_TYPE_RAW = 4
     , PERF_TYPE_BREAKPOINT = 5
     , PERF_TYPE_MAX = 6
     )

@enum( perf_hw_id::UInt32
     , PERF_COUNT_HW_CPU_CYCLES = 0
     , PERF_COUNT_HW_INSTRUCTIONS = 1
     , PERF_COUNT_HW_CACHE_REFERENCES = 2
     , PERF_COUNT_HW_CACHE_MISSES = 3
     , PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 4
     , PERF_COUNT_HW_BRANCH_MISSES = 5
     , PERF_COUNT_HW_BUS_CYCLES = 6
     , PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 7
     , PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 8
     , PERF_COUNT_HW_REF_CPU_CYCLES = 9
     , PERF_COUNT_HW_MAX = 10
     )

@enum( perf_hw_cache_id::UInt32
     , PERF_COUNT_HW_CACHE_L1D = 0
     , PERF_COUNT_HW_CACHE_L1I = 1
     , PERF_COUNT_HW_CACHE_LL = 2
     , PERF_COUNT_HW_CACHE_DTLB = 3
     , PERF_COUNT_HW_CACHE_ITLB = 4
     , PERF_COUNT_HW_CACHE_BPU = 5
     , PERF_COUNT_HW_CACHE_NODE = 6
     , PERF_COUNT_HW_CACHE_MAX = 7
     )

@enum( perf_hw_cache_op_id::UInt32
     , PERF_COUNT_HW_CACHE_OP_READ = 0
     , PERF_COUNT_HW_CACHE_OP_WRITE = 1
     , PERF_COUNT_HW_CACHE_OP_PREFETCH = 2
     , PERF_COUNT_HW_CACHE_OP_MAX = 3
     )

@enum( perf_hw_cache_op_result_id::UInt32
     , PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0
     , PERF_COUNT_HW_CACHE_RESULT_MISS = 1
     , PERF_COUNT_HW_CACHE_RESULT_MAX = 2
     )

@enum( perf_sw_ids::UInt32
     , PERF_COUNT_SW_CPU_CLOCK = 0
     , PERF_COUNT_SW_TASK_CLOCK = 1
     , PERF_COUNT_SW_PAGE_FAULTS = 2
     , PERF_COUNT_SW_CONTEXT_SWITCHES = 3
     , PERF_COUNT_SW_CPU_MIGRATIONS = 4
     , PERF_COUNT_SW_PAGE_FAULTS_MIN = 5
     , PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6
     , PERF_COUNT_SW_ALIGNMENT_FAULTS = 7
     , PERF_COUNT_SW_EMULATION_FAULTS = 8
     , PERF_COUNT_SW_DUMMY = 9
     , PERF_COUNT_SW_BPF_OUTPUT = 10
     , PERF_COUNT_SW_MAX = 11
     )

@enum( perf_event_sample_format::UInt32
     , PERF_SAMPLE_IP = 1
     , PERF_SAMPLE_TID = 2
     , PERF_SAMPLE_TIME = 4
     , PERF_SAMPLE_ADDR = 8
     , PERF_SAMPLE_READ = 16
     , PERF_SAMPLE_CALLCHAIN = 32
     , PERF_SAMPLE_ID = 64
     , PERF_SAMPLE_CPU = 128
     , PERF_SAMPLE_PERIOD = 256
     , PERF_SAMPLE_STREAM_ID = 512
     , PERF_SAMPLE_RAW = 1024
     , PERF_SAMPLE_BRANCH_STACK = 2048
     , PERF_SAMPLE_REGS_USER = 4096
     , PERF_SAMPLE_STACK_USER = 8192
     , PERF_SAMPLE_WEIGHT = 16384
     , PERF_SAMPLE_DATA_SRC = 32768
     , PERF_SAMPLE_IDENTIFIER = 65536
     , PERF_SAMPLE_TRANSACTION = 131072
     , PERF_SAMPLE_REGS_INTR = 262144
     , PERF_SAMPLE_MAX = 524288
     )

@enum( perf_branch_sample_type_shift::UInt32
     , PERF_SAMPLE_BRANCH_USER_SHIFT = 0
     , PERF_SAMPLE_BRANCH_KERNEL_SHIFT = 1
     , PERF_SAMPLE_BRANCH_HV_SHIFT = 2
     , PERF_SAMPLE_BRANCH_ANY_SHIFT = 3
     , PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT = 4
     , PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT = 5
     , PERF_SAMPLE_BRANCH_IND_CALL_SHIFT = 6
     , PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT = 7
     , PERF_SAMPLE_BRANCH_IN_TX_SHIFT = 8
     , PERF_SAMPLE_BRANCH_NO_TX_SHIFT = 9
     , PERF_SAMPLE_BRANCH_COND_SHIFT = 10
     , PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT = 11
     , PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT = 12
     , PERF_SAMPLE_BRANCH_CALL_SHIFT = 13
     , PERF_SAMPLE_BRANCH_MAX_SHIFT = 14
     )

@enum( perf_branch_sample_type::UInt32
     , PERF_SAMPLE_BRANCH_USER = 1
     , PERF_SAMPLE_BRANCH_KERNEL = 2
     , PERF_SAMPLE_BRANCH_HV = 4
     , PERF_SAMPLE_BRANCH_ANY = 8
     , PERF_SAMPLE_BRANCH_ANY_CALL = 16
     , PERF_SAMPLE_BRANCH_ANY_RETURN = 32
     , PERF_SAMPLE_BRANCH_IND_CALL = 64
     , PERF_SAMPLE_BRANCH_ABORT_TX = 128
     , PERF_SAMPLE_BRANCH_IN_TX = 256
     , PERF_SAMPLE_BRANCH_NO_TX = 512
     , PERF_SAMPLE_BRANCH_COND = 1024
     , PERF_SAMPLE_BRANCH_CALL_STACK = 2048
     , PERF_SAMPLE_BRANCH_IND_JUMP = 4096
     , PERF_SAMPLE_BRANCH_CALL = 8192
     , PERF_SAMPLE_BRANCH_MAX = 16384
     )

@enum( perf_sample_regs_abi::UInt32
     , PERF_SAMPLE_REGS_ABI_NONE = 0
     , PERF_SAMPLE_REGS_ABI_32 = 1
     , PERF_SAMPLE_REGS_ABI_64 = 2
     )


# this is in the original header files _not_ an enum !
const PERF_TXN_ABORT_MASK_size = 8
@enum( perf_txn::UInt64
     , PERF_TXN_ELISION = 1
     , PERF_TXN_TRANSACTION = 2
     , PERF_TXN_SYNC = 4
     , PERF_TXN_ASYNC = 8
     , PERF_TXN_RETRY = 16
     , PERF_TXN_CONFLICT = 32
     , PERF_TXN_CAPACITY_WRITE = 64
     , PERF_TXN_CAPACITY_READ = 128
     , PERF_TXN_MAX = 256
     , PERF_TXN_ABORT_MASK = 18446744069414584320
     , PERF_TXN_ABORT_SHIFT = 32
     )

@enum( perf_event_read_format::UInt32
     , PERF_FORMAT_TOTAL_TIME_ENABLED = 1
     , PERF_FORMAT_TOTAL_TIME_RUNNING = 2
     , PERF_FORMAT_ID = 4
     , PERF_FORMAT_GROUP = 8
     , PERF_FORMAT_MAX = 16
     )


# sizes of `perf_event_attr` for various kernel API versions
const PERF_ATTR_SIZE_VER0 = 64
const PERF_ATTR_SIZE_VER1 = 72
const PERF_ATTR_SIZE_VER2 = 80
const PERF_ATTR_SIZE_VER3 = 96
const PERF_ATTR_SIZE_VER4 = 104
const PERF_ATTR_SIZE_VER5 = 112

# size of current implementation of `perf_event_attr`
const perf_event_attr_size = 112

# `ioctl` ids applicable to perf event file descriptors
const PERF_EVENT_IOC_ENABLE = 9216
const PERF_EVENT_IOC_DISABLE = 9217
const PERF_EVENT_IOC_REFRESH = 9218
const PERF_EVENT_IOC_RESET = 9219
const PERF_EVENT_IOC_PERIOD = 1074275332
const PERF_EVENT_IOC_SET_OUTPUT = 9221
const PERF_EVENT_IOC_SET_FILTER = 1074275334
const PERF_EVENT_IOC_ID = 2148017159
const PERF_EVENT_IOC_SET_BPF = 1074013192

@enum( perf_event_ioc_flags::UInt32
     , PERF_IOC_FLAG_GROUP = 1
     )

const PERF_RECORD_MISC_CPUMODE_MASK = 7
const PERF_RECORD_MISC_CPUMODE_UNKNOWN = 0
const PERF_RECORD_MISC_KERNEL = 1
const PERF_RECORD_MISC_USER = 2
const PERF_RECORD_MISC_HYPERVISOR = 3
const PERF_RECORD_MISC_GUEST_KERNEL = 4
const PERF_RECORD_MISC_GUEST_USER = 5
const PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT = 4096
const PERF_RECORD_MISC_MMAP_DATA = 8192
const PERF_RECORD_MISC_COMM_EXEC = 8192
const PERF_RECORD_MISC_SWITCH_OUT = 8192
const PERF_RECORD_MISC_EXACT_IP = 16384
const PERF_RECORD_MISC_EXT_RESERVED = 32768
@enum( perf_event_type::UInt32
     , PERF_RECORD_MMAP = 1
     , PERF_RECORD_LOST = 2
     , PERF_RECORD_COMM = 3
     , PERF_RECORD_EXIT = 4
     , PERF_RECORD_THROTTLE = 5
     , PERF_RECORD_UNTHROTTLE = 6
     , PERF_RECORD_FORK = 7
     , PERF_RECORD_READ = 8
     , PERF_RECORD_SAMPLE = 9
     , PERF_RECORD_MMAP2 = 10
     , PERF_RECORD_AUX = 11
     , PERF_RECORD_ITRACE_START = 12
     , PERF_RECORD_LOST_SAMPLES = 13
     , PERF_RECORD_SWITCH = 14
     , PERF_RECORD_SWITCH_CPU_WIDE = 15
     , PERF_RECORD_MAX = 16
     )


const PERF_MAX_STACK_DEPTH = 127

@enum( perf_callchain_context::UInt64
     , PERF_CONTEXT_HV = 18446744073709551584
     , PERF_CONTEXT_KERNEL = 18446744073709551488
     , PERF_CONTEXT_USER = 18446744073709551104
     , PERF_CONTEXT_GUEST = 18446744073709549568
     , PERF_CONTEXT_GUEST_KERNEL = 18446744073709549440
     , PERF_CONTEXT_GUEST_USER = 18446744073709549056
     , PERF_CONTEXT_MAX = 18446744073709547521
     )

const PERF_AUX_FLAG_TRUNCATED = 1
const PERF_AUX_FLAG_OVERWRITE = 2

const PERF_FLAG_FD_NO_GROUP = 1
const PERF_FLAG_FD_OUTPUT = 2
const PERF_FLAG_PID_CGROUP = 4
const PERF_FLAG_FD_CLOEXEC = 8

const PERF_MEM_OP_NA = 1
const PERF_MEM_OP_LOAD = 2
const PERF_MEM_OP_STORE = 4
const PERF_MEM_OP_PFETCH = 8
const PERF_MEM_OP_EXEC = 16
const PERF_MEM_OP_SHIFT = 0

const PERF_MEM_LVL_NA = 1
const PERF_MEM_LVL_HIT = 2
const PERF_MEM_LVL_MISS = 4
const PERF_MEM_LVL_L1 = 8
const PERF_MEM_LVL_LFB = 16
const PERF_MEM_LVL_L2 = 32
const PERF_MEM_LVL_L3 = 64
const PERF_MEM_LVL_LOC_RAM = 128
const PERF_MEM_LVL_REM_RAM1 = 256
const PERF_MEM_LVL_REM_RAM2 = 512
const PERF_MEM_LVL_REM_CCE1 = 1024
const PERF_MEM_LVL_REM_CCE2 = 2048
const PERF_MEM_LVL_IO = 4096
const PERF_MEM_LVL_UNC = 8192
const PERF_MEM_LVL_SHIFT = 5

const PERF_MEM_SNOOP_NA = 1
const PERF_MEM_SNOOP_NONE = 2
const PERF_MEM_SNOOP_HIT = 4
const PERF_MEM_SNOOP_MISS = 8
const PERF_MEM_SNOOP_HITM = 16
const PERF_MEM_SNOOP_SHIFT = 19

const PERF_MEM_LOCK_NA = 1
const PERF_MEM_LOCK_LOCKED = 2
const PERF_MEM_LOCK_SHIFT = 24

const PERF_MEM_TLB_NA = 1
const PERF_MEM_TLB_HIT = 2
const PERF_MEM_TLB_MISS = 4
const PERF_MEM_TLB_L1 = 8
const PERF_MEM_TLB_L2 = 16
const PERF_MEM_TLB_WK = 32
const PERF_MEM_TLB_OS = 64
const PERF_MEM_TLB_SHIFT = 26

# equivalent type for `pid_t`
const PID_T = Int32

end  # autogenerated module LinuxKernelPerfAPI
