chromium/third_party/breakpad/breakpad/src/common/linux/ucontext_constants.h

// Copyright 2012 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// This header can be included either from a C, C++ or Assembly file.
// Its purpose is to contain constants that must match the offsets of
// various fields in ucontext_t.
//
// They should match the definitions from signal.h.
//
// Used by src/common/linux/breakpad_getcontext.S
// Tested by src/common/linux/breakpad_getcontext_unittest.cc
//
// This header should not be used by anything else.

#ifndef GOOGLEBREAKPAD_COMMON_LINUX_UCONTEXT_CONSTANTS_H
#define GOOGLEBREAKPAD_COMMON_LINUX_UCONTEXT_CONSTANTS_H

#if defined(__arm__)

#define MCONTEXT_GREGS_OFFSET
#define UCONTEXT_SIGMASK_OFFSET

#elif defined(__aarch64__)

#define UCONTEXT_SIGMASK_OFFSET

#define MCONTEXT_GREGS_OFFSET
#define MCONTEXT_SP_OFFSET
#define MCONTEXT_PC_OFFSET
#define MCONTEXT_PSTATE_OFFSET
#define MCONTEXT_EXTENSION_OFFSET

#define FPSIMD_MAGIC

#define FPSIMD_CONTEXT_MAGIC_OFFSET
#define FPSIMD_CONTEXT_SIZE_OFFSET
#define FPSIMD_CONTEXT_FPSR_OFFSET
#define FPSIMD_CONTEXT_FPCR_OFFSET
#define FPSIMD_CONTEXT_VREGS_OFFSET
#define FPSIMD_CONTEXT_SIZE

#define REGISTER_SIZE
#define SIMD_REGISTER_SIZE

#elif defined(__i386__)

#define MCONTEXT_GREGS_OFFSET
#define MCONTEXT_GS_OFFSET
#define MCONTEXT_FS_OFFSET
#define MCONTEXT_ES_OFFSET
#define MCONTEXT_DS_OFFSET
#define MCONTEXT_EDI_OFFSET
#define MCONTEXT_ESI_OFFSET
#define MCONTEXT_EBP_OFFSET
#define MCONTEXT_ESP_OFFSET
#define MCONTEXT_EBX_OFFSET
#define MCONTEXT_EDX_OFFSET
#define MCONTEXT_ECX_OFFSET
#define MCONTEXT_EAX_OFFSET
#define MCONTEXT_TRAPNO_OFFSET
#define MCONTEXT_ERR_OFFSET
#define MCONTEXT_EIP_OFFSET
#define MCONTEXT_CS_OFFSET
#define MCONTEXT_EFL_OFFSET
#define MCONTEXT_UESP_OFFSET
#define MCONTEXT_SS_OFFSET

#define UCONTEXT_SIGMASK_OFFSET

#define UCONTEXT_FPREGS_OFFSET
#if defined(__BIONIC__)
#define UCONTEXT_FPREGS_MEM_OFFSET
#else
#define UCONTEXT_FPREGS_MEM_OFFSET
#endif

#elif defined(__mips__)

#if _MIPS_SIM == _ABIO32
#define MCONTEXT_PC_OFFSET
#define MCONTEXT_GREGS_OFFSET
#define MCONTEXT_FPREGS_OFFSET
#define MCONTEXT_FPC_CSR
#define UCONTEXT_SIGMASK_OFFSET
#else
#define MCONTEXT_GREGS_OFFSET
#define MCONTEXT_FPREGS_OFFSET
#define MCONTEXT_PC_OFFSET
#define MCONTEXT_FPC_CSR
#define UCONTEXT_SIGMASK_OFFSET
#endif

#elif defined(__x86_64__)

#define MCONTEXT_GREGS_OFFSET
#define UCONTEXT_SIGMASK_OFFSET

#define MCONTEXT_GREGS_R8
#define MCONTEXT_GREGS_R9
#define MCONTEXT_GREGS_R10
#define MCONTEXT_GREGS_R11
#define MCONTEXT_GREGS_R12
#define MCONTEXT_GREGS_R13
#define MCONTEXT_GREGS_R14
#define MCONTEXT_GREGS_R15
#define MCONTEXT_GREGS_RDI
#define MCONTEXT_GREGS_RSI
#define MCONTEXT_GREGS_RBP
#define MCONTEXT_GREGS_RBX
#define MCONTEXT_GREGS_RDX
#define MCONTEXT_GREGS_RAX
#define MCONTEXT_GREGS_RCX
#define MCONTEXT_GREGS_RSP
#define MCONTEXT_GREGS_RIP
#define MCONTEXT_FPREGS_PTR
#if defined(__BIONIC__)
#define MCONTEXT_FPREGS_MEM
#else
#define MCONTEXT_FPREGS_MEM
#endif
#define FPREGS_OFFSET_MXCSR

#elif defined(__riscv)

#if __riscv_xlen == 32
#define UCONTEXT_SIGMASK_OFFSET
#define MCONTEXT_GREGS_OFFSET
#define MCONTEXT_GREGS_SIZE
#define REG_S
#elif __riscv_xlen == 64
#define UCONTEXT_SIGMASK_OFFSET
#define MCONTEXT_GREGS_OFFSET
#define MCONTEXT_GREGS_SIZE
#define REG_S
#else
#error "Unexpected __riscv_xlen"
#endif

#define MCONTEXT_GREGS_PC
#define MCONTEXT_GREGS_RA
#define MCONTEXT_GREGS_SP
#define MCONTEXT_GREGS_GP
#define MCONTEXT_GREGS_TP
#define MCONTEXT_GREGS_T0
#define MCONTEXT_GREGS_T1
#define MCONTEXT_GREGS_T2
#define MCONTEXT_GREGS_S0
#define MCONTEXT_GREGS_S1
#define MCONTEXT_GREGS_A0
#define MCONTEXT_GREGS_A1
#define MCONTEXT_GREGS_A2
#define MCONTEXT_GREGS_A3
#define MCONTEXT_GREGS_A4
#define MCONTEXT_GREGS_A5
#define MCONTEXT_GREGS_A6
#define MCONTEXT_GREGS_A7
#define MCONTEXT_GREGS_S2
#define MCONTEXT_GREGS_S3
#define MCONTEXT_GREGS_S4
#define MCONTEXT_GREGS_S5
#define MCONTEXT_GREGS_S6
#define MCONTEXT_GREGS_S7
#define MCONTEXT_GREGS_S8
#define MCONTEXT_GREGS_S9
#define MCONTEXT_GREGS_S10
#define MCONTEXT_GREGS_S11
#define MCONTEXT_GREGS_T3
#define MCONTEXT_GREGS_T4
#define MCONTEXT_GREGS_T5
#define MCONTEXT_GREGS_T6

#define MCONTEXT_FPREGS_OFFSET

#if __riscv_flen == 32
#define MCONTEXT_FPREGS_SIZE
#define FREG_S
#elif __riscv_flen == 64
#define MCONTEXT_FPREGS_SIZE
#define FREG_S
#elif __riscv_flen == 128
#define MCONTEXT_FPREGS_SIZE
#define FREG_S
#else
#error "Unexpected __riscv_flen"
#endif

#define MCONTEXT_FPREGS_FT0
#define MCONTEXT_FPREGS_FT1
#define MCONTEXT_FPREGS_FT2
#define MCONTEXT_FPREGS_FT3
#define MCONTEXT_FPREGS_FT4
#define MCONTEXT_FPREGS_FT5
#define MCONTEXT_FPREGS_FT6
#define MCONTEXT_FPREGS_FT7
#define MCONTEXT_FPREGS_FS0
#define MCONTEXT_FPREGS_FS1
#define MCONTEXT_FPREGS_FA0
#define MCONTEXT_FPREGS_FA1
#define MCONTEXT_FPREGS_FA2
#define MCONTEXT_FPREGS_FA3
#define MCONTEXT_FPREGS_FA4
#define MCONTEXT_FPREGS_FA5
#define MCONTEXT_FPREGS_FA6
#define MCONTEXT_FPREGS_FA7
#define MCONTEXT_FPREGS_FS2
#define MCONTEXT_FPREGS_FS3
#define MCONTEXT_FPREGS_FS4
#define MCONTEXT_FPREGS_FS5
#define MCONTEXT_FPREGS_FS6
#define MCONTEXT_FPREGS_FS7
#define MCONTEXT_FPREGS_FS8
#define MCONTEXT_FPREGS_FS9
#define MCONTEXT_FPREGS_FS10
#define MCONTEXT_FPREGS_FS11
#define MCONTEXT_FPREGS_FT8
#define MCONTEXT_FPREGS_FT9
#define MCONTEXT_FPREGS_FT10
#define MCONTEXT_FPREGS_FT11

#define MCONTEXT_FPC_CSR

#else
# error "This header has not been ported for your CPU"
#endif

#endif  // GOOGLEBREAKPAD_COMMON_ANDROID_UCONTEXT_CONSTANTS_H