(root)/
glibc-2.38/
sysdeps/
x86_64/
sys/
ucontext.h
       1  /* Copyright (C) 2001-2023 Free Software Foundation, Inc.
       2     This file is part of the GNU C Library.
       3  
       4     The GNU C Library is free software; you can redistribute it and/or
       5     modify it under the terms of the GNU Lesser General Public
       6     License as published by the Free Software Foundation; either
       7     version 2.1 of the License, or (at your option) any later version.
       8  
       9     The GNU C Library is distributed in the hope that it will be useful,
      10     but WITHOUT ANY WARRANTY; without even the implied warranty of
      11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12     Lesser General Public License for more details.
      13  
      14     You should have received a copy of the GNU Lesser General Public
      15     License along with the GNU C Library; if not, see
      16     <https://www.gnu.org/licenses/>.  */
      17  
      18  #ifndef _SYS_UCONTEXT_H
      19  #define _SYS_UCONTEXT_H	1
      20  
      21  #include <features.h>
      22  
      23  #include <bits/types.h>
      24  #include <bits/types/sigset_t.h>
      25  #include <bits/types/stack_t.h>
      26  
      27  
      28  #ifdef __USE_MISC
      29  # define __ctx(fld) fld
      30  #else
      31  # define __ctx(fld) __ ## fld
      32  #endif
      33  
      34  /* Type for general register.  */
      35  __extension__ typedef long long int greg_t;
      36  
      37  /* Number of general registers.  */
      38  #define __NGREG	23
      39  #ifdef __USE_MISC
      40  # define NGREG	__NGREG
      41  #endif
      42  
      43  /* Container for all general registers.  */
      44  typedef greg_t gregset_t[__NGREG];
      45  
      46  #ifdef __USE_GNU
      47  /* Number of each register in the `gregset_t' array.  */
      48  enum
      49  {
      50    REG_GSFS = 0,		/* Actually int gs, fs.  */
      51  # define REG_GSFS	REG_GSFS
      52    REG_ESDS,		/* Actually int es, ds.  */
      53  # define REG_ESDS	REG_ESDS
      54    REG_R8,
      55  # define REG_R8		REG_R8
      56    REG_R9,
      57  # define REG_R9		REG_R9
      58    REG_R10,
      59  # define REG_R10	REG_R10
      60    REG_R11,
      61  # define REG_R11	REG_R11
      62    REG_R12,
      63  # define REG_R12	REG_R12
      64    REG_R13,
      65  # define REG_R13	REG_R13
      66    REG_R14,
      67  # define REG_R14	REG_R14
      68    REG_R15,
      69  # define REG_R15	REG_R15
      70    REG_RDI,
      71  # define REG_RDI	REG_RDI
      72    REG_RSI,
      73  # define REG_RSI	REG_RSI
      74    REG_RBP,
      75  # define REG_RBP	REG_RBP
      76    REG_RSP,
      77  # define REG_RSP	REG_RSP
      78    REG_RBX,
      79  # define REG_RBX	REG_RBX
      80    REG_RDX,
      81  # define REG_RDX	REG_RDX
      82    REG_RCX,
      83  # define REG_RCX	REG_RCX
      84    REG_RAX,
      85  # define REG_RAX	REG_RAX
      86    REG_RIP,
      87  # define REG_RIP	REG_RIP
      88    REG_CS,		/* Actually int cs, pad.  */
      89  # define REG_CS		REG_CS
      90    REG_RFL,
      91  # define REG_RFL	REG_RFL
      92    REG_ERR,
      93  # define REG_ERR	REG_ERR
      94    REG_TRAPNO,
      95  # define REG_TRAPNO	REG_TRAPNO
      96    REG_OLDMASK,
      97  # define REG_OLDMASK	REG_OLDMASK
      98    REG_CR2
      99  # define REG_CR2	REG_CR2
     100  };
     101  #endif
     102  
     103  struct _libc_fpxreg
     104  {
     105    unsigned short int __ctx(significand)[4];
     106    unsigned short int __ctx(exponent);
     107    unsigned short int __glibc_reserved1[3];
     108  };
     109  
     110  struct _libc_xmmreg
     111  {
     112    __uint32_t	__ctx(element)[4];
     113  };
     114  
     115  struct _libc_fpstate
     116  {
     117    /* 64-bit FXSAVE format.  */
     118    __uint16_t		__ctx(cwd);
     119    __uint16_t		__ctx(swd);
     120    __uint16_t		__ctx(ftw);
     121    __uint16_t		__ctx(fop);
     122    __uint64_t		__ctx(rip);
     123    __uint64_t		__ctx(rdp);
     124    __uint32_t		__ctx(mxcsr);
     125    __uint32_t		__ctx(mxcr_mask);
     126    struct _libc_fpxreg	_st[8];
     127    struct _libc_xmmreg	_xmm[16];
     128    __uint32_t		__glibc_reserved1[24];
     129  };
     130  
     131  /* Structure to describe FPU registers.  */
     132  typedef struct _libc_fpstate *fpregset_t;
     133  
     134  /* Context to describe whole processor state.  */
     135  typedef struct
     136    {
     137      gregset_t __ctx(gregs);
     138      /* Note that fpregs is a pointer.  */
     139      fpregset_t __ctx(fpregs);
     140      __extension__ unsigned long long __reserved1 [8];
     141  } mcontext_t;
     142  
     143  /* Userlevel context.  */
     144  typedef struct ucontext_t
     145    {
     146      unsigned long int __ctx(uc_flags);
     147      struct ucontext_t *uc_link;
     148      stack_t uc_stack;
     149      mcontext_t uc_mcontext;
     150      sigset_t uc_sigmask;
     151      struct _libc_fpstate __fpregs_mem;
     152      __extension__ unsigned long long int __ssp[4];
     153    } ucontext_t;
     154  
     155  #undef __ctx
     156  
     157  #endif /* sys/ucontext.h */