|
Packit Service |
82fcde |
/* Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifndef _SYS_UCONTEXT_H
|
|
Packit Service |
82fcde |
#define _SYS_UCONTEXT_H 1
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <features.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <bits/types/sigset_t.h>
|
|
Packit Service |
82fcde |
#include <bits/types/stack_t.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifdef __USE_MISC
|
|
Packit Service |
82fcde |
# define __ctx(fld) fld
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
# define __ctx(fld) __ ## fld
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
struct __ctx(pt_regs);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#if __WORDSIZE == 32
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Number of general registers. */
|
|
Packit Service |
82fcde |
# define __NGREG 48
|
|
Packit Service |
82fcde |
# ifdef __USE_MISC
|
|
Packit Service |
82fcde |
# define NGREG __NGREG
|
|
Packit Service |
82fcde |
# endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Container for all general registers. */
|
|
Packit Service |
82fcde |
typedef unsigned long gregset_t[__NGREG];
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Container for floating-point registers and status */
|
|
Packit Service |
82fcde |
typedef struct _libc_fpstate
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
double __ctx(fpregs)[32];
|
|
Packit Service |
82fcde |
double __ctx(fpscr);
|
|
Packit Service |
82fcde |
unsigned int _pad[2];
|
|
Packit Service |
82fcde |
} fpregset_t;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Container for Altivec/VMX registers and status.
|
|
Packit Service |
82fcde |
Needs to be aligned on a 16-byte boundary. */
|
|
Packit Service |
82fcde |
typedef struct _libc_vrstate
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
unsigned int __ctx(vrregs)[32][4];
|
|
Packit Service |
82fcde |
unsigned int __ctx(vrsave);
|
|
Packit Service |
82fcde |
unsigned int _pad[2];
|
|
Packit Service |
82fcde |
unsigned int __ctx(vscr);
|
|
Packit Service |
82fcde |
} vrregset_t;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Context to describe whole processor state. */
|
|
Packit Service |
82fcde |
typedef struct
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
gregset_t __ctx(gregs);
|
|
Packit Service |
82fcde |
fpregset_t __ctx(fpregs);
|
|
Packit Service |
82fcde |
vrregset_t __ctx(vrregs) __attribute__((__aligned__(16)));
|
|
Packit Service |
82fcde |
} mcontext_t;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* For 64-bit kernels with Altivec support, a machine context is exactly
|
|
Packit Service |
82fcde |
* a sigcontext. For older kernel (without Altivec) the sigcontext matches
|
|
Packit Service |
82fcde |
* the mcontext upto but not including the v_regs field. For kernels that
|
|
Packit Service |
82fcde |
* don't set AT_HWCAP or return AT_HWCAP without PPC_FEATURE_HAS_ALTIVEC the
|
|
Packit Service |
82fcde |
* v_regs field may not exist and should not be referenced. The v_regd field
|
|
Packit Service |
82fcde |
* can be refernced safely only after verifying that PPC_FEATURE_HAS_ALTIVEC
|
|
Packit Service |
82fcde |
* is set in AT_HWCAP. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Number of general registers. */
|
|
Packit Service |
82fcde |
# define __NGREG 48 /* includes r0-r31, nip, msr, lr, etc. */
|
|
Packit Service |
82fcde |
# define __NFPREG 33 /* includes fp0-fp31 &fpscr. */
|
|
Packit Service |
82fcde |
# define __NVRREG 34 /* includes v0-v31, vscr, & vrsave in
|
|
Packit Service |
82fcde |
split vectors */
|
|
Packit Service |
82fcde |
# ifdef __USE_MISC
|
|
Packit Service |
82fcde |
# define NGREG __NGREG
|
|
Packit Service |
82fcde |
# define NFPREG __NFPREG
|
|
Packit Service |
82fcde |
# define NVRREG __NVRREG
|
|
Packit Service |
82fcde |
# endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
typedef unsigned long gregset_t[__NGREG];
|
|
Packit Service |
82fcde |
typedef double fpregset_t[__NFPREG];
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Container for Altivec/VMX Vector Status and Control Register. Only 32-bits
|
|
Packit Service |
82fcde |
but can only be copied to/from a 128-bit vector register. So we allocated
|
|
Packit Service |
82fcde |
a whole quadword speedup save/restore. */
|
|
Packit Service |
82fcde |
typedef struct _libc_vscr
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
unsigned int __pad[3];
|
|
Packit Service |
82fcde |
unsigned int __ctx(vscr_word);
|
|
Packit Service |
82fcde |
} vscr_t;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Container for Altivec/VMX registers and status.
|
|
Packit Service |
82fcde |
Must to be aligned on a 16-byte boundary. */
|
|
Packit Service |
82fcde |
typedef struct _libc_vrstate
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
unsigned int __ctx(vrregs)[32][4];
|
|
Packit Service |
82fcde |
vscr_t __ctx(vscr);
|
|
Packit Service |
82fcde |
unsigned int __ctx(vrsave);
|
|
Packit Service |
82fcde |
unsigned int __pad[3];
|
|
Packit Service |
82fcde |
} vrregset_t __attribute__((__aligned__(16)));
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
typedef struct {
|
|
Packit Service |
82fcde |
unsigned long __glibc_reserved[4];
|
|
Packit Service |
82fcde |
int __ctx(signal);
|
|
Packit Service |
82fcde |
int __pad0;
|
|
Packit Service |
82fcde |
unsigned long __ctx(handler);
|
|
Packit Service |
82fcde |
unsigned long __ctx(oldmask);
|
|
Packit Service |
82fcde |
struct __ctx(pt_regs) *__ctx(regs);
|
|
Packit Service |
82fcde |
gregset_t __ctx(gp_regs);
|
|
Packit Service |
82fcde |
fpregset_t __ctx(fp_regs);
|
|
Packit Service |
82fcde |
/*
|
|
Packit Service |
82fcde |
* To maintain compatibility with current implementations the sigcontext is
|
|
Packit Service |
82fcde |
* extended by appending a pointer (v_regs) to a quadword type (elf_vrreg_t)
|
|
Packit Service |
82fcde |
* followed by an unstructured (vmx_reserve) field of 69 doublewords. This
|
|
Packit Service |
82fcde |
* allows the array of vector registers to be quadword aligned independent of
|
|
Packit Service |
82fcde |
* the alignment of the containing sigcontext or ucontext. It is the
|
|
Packit Service |
82fcde |
* responsibility of the code setting the sigcontext to set this pointer to
|
|
Packit Service |
82fcde |
* either NULL (if this processor does not support the VMX feature) or the
|
|
Packit Service |
82fcde |
* address of the first quadword within the allocated (vmx_reserve) area.
|
|
Packit Service |
82fcde |
*
|
|
Packit Service |
82fcde |
* The pointer (v_regs) of vector type (elf_vrreg_t) is essentually
|
|
Packit Service |
82fcde |
* an array of 34 quadword entries. The entries with
|
|
Packit Service |
82fcde |
* indexes 0-31 contain the corresponding vector registers. The entry with
|
|
Packit Service |
82fcde |
* index 32 contains the vscr as the last word (offset 12) within the
|
|
Packit Service |
82fcde |
* quadword. This allows the vscr to be stored as either a quadword (since
|
|
Packit Service |
82fcde |
* it must be copied via a vector register to/from storage) or as a word.
|
|
Packit Service |
82fcde |
* The entry with index 33 contains the vrsave as the first word (offset 0)
|
|
Packit Service |
82fcde |
* within the quadword.
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
vrregset_t *__ctx(v_regs);
|
|
Packit Service |
82fcde |
long __ctx(vmx_reserve)[__NVRREG+__NVRREG+1];
|
|
Packit Service |
82fcde |
} mcontext_t;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Userlevel context. */
|
|
Packit Service |
82fcde |
typedef struct ucontext_t
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
unsigned long int __ctx(uc_flags);
|
|
Packit Service |
82fcde |
struct ucontext_t *uc_link;
|
|
Packit Service |
82fcde |
stack_t uc_stack;
|
|
Packit Service |
82fcde |
#if __WORDSIZE == 32
|
|
Packit Service |
82fcde |
/*
|
|
Packit Service |
82fcde |
* These fields are set up this way to maximize source and
|
|
Packit Service |
82fcde |
* binary compatibility with code written for the old
|
|
Packit Service |
82fcde |
* ucontext_t definition, which didn't include space for the
|
|
Packit Service |
82fcde |
* registers.
|
|
Packit Service |
82fcde |
*
|
|
Packit Service |
82fcde |
* Different versions of the kernel have stored the registers on
|
|
Packit Service |
82fcde |
* signal delivery at different offsets from the ucontext struct.
|
|
Packit Service |
82fcde |
* Programs should thus use the uc_mcontext.uc_regs pointer to
|
|
Packit Service |
82fcde |
* find where the registers are actually stored. The registers
|
|
Packit Service |
82fcde |
* will be stored within the ucontext_t struct but not necessarily
|
|
Packit Service |
82fcde |
* at a fixed address. As a side-effect, this lets us achieve
|
|
Packit Service |
82fcde |
* 16-byte alignment for the register storage space if the
|
|
Packit Service |
82fcde |
* Altivec registers are to be saved, without requiring 16-byte
|
|
Packit Service |
82fcde |
* alignment on the whole ucontext_t.
|
|
Packit Service |
82fcde |
*
|
|
Packit Service |
82fcde |
* The uc_mcontext.regs field is included for source compatibility
|
|
Packit Service |
82fcde |
* with programs written against the older ucontext_t definition,
|
|
Packit Service |
82fcde |
* and its name should therefore not change. The uc_pad field
|
|
Packit Service |
82fcde |
* is for binary compatibility with programs compiled against the
|
|
Packit Service |
82fcde |
* old ucontext_t; it ensures that uc_mcontext.regs and uc_sigmask
|
|
Packit Service |
82fcde |
* are at the same offset as previously.
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
int __glibc_reserved1[7];
|
|
Packit Service |
82fcde |
union __ctx(uc_regs_ptr) {
|
|
Packit Service |
82fcde |
struct __ctx(pt_regs) *__ctx(regs);
|
|
Packit Service |
82fcde |
mcontext_t *__ctx(uc_regs);
|
|
Packit Service |
82fcde |
} uc_mcontext;
|
|
Packit Service |
82fcde |
sigset_t uc_sigmask;
|
|
Packit Service |
82fcde |
/* last for extensibility */
|
|
Packit Service |
82fcde |
char __ctx(uc_reg_space)[sizeof(mcontext_t) + 12];
|
|
Packit Service |
82fcde |
#else /* 64-bit */
|
|
Packit Service |
82fcde |
sigset_t uc_sigmask;
|
|
Packit Service |
82fcde |
mcontext_t uc_mcontext; /* last for extensibility */
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
} ucontext_t;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#undef __ctx
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#endif /* sys/ucontext.h */
|