(root)/
glibc-2.38/
sysdeps/
unix/
sysv/
linux/
rseq-internal.h
       1  /* Restartable Sequences internal API.  Linux implementation.
       2     Copyright (C) 2021-2023 Free Software Foundation, Inc.
       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 RSEQ_INTERNAL_H
      19  #define RSEQ_INTERNAL_H
      20  
      21  #include <sysdep.h>
      22  #include <errno.h>
      23  #include <kernel-features.h>
      24  #include <stdbool.h>
      25  #include <stdio.h>
      26  #include <sys/rseq.h>
      27  
      28  #ifdef RSEQ_SIG
      29  static inline bool
      30  rseq_register_current_thread (struct pthread *self, bool do_rseq)
      31  {
      32    if (do_rseq)
      33      {
      34        int ret = INTERNAL_SYSCALL_CALL (rseq, &self->rseq_area,
      35                                         sizeof (self->rseq_area),
      36                                         0, RSEQ_SIG);
      37        if (!INTERNAL_SYSCALL_ERROR_P (ret))
      38          return true;
      39      }
      40    THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED);
      41    return false;
      42  }
      43  #else /* RSEQ_SIG */
      44  static inline bool
      45  rseq_register_current_thread (struct pthread *self, bool do_rseq)
      46  {
      47    THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED);
      48    return false;
      49  }
      50  #endif /* RSEQ_SIG */
      51  
      52  #endif /* rseq-internal.h */