2021-12-09 08:49:32 +00:00
|
|
|
/* Restartable Sequences internal API. Linux implementation.
|
2023-01-06 21:08:04 +00:00
|
|
|
Copyright (C) 2021-2023 Free Software Foundation, Inc.
|
2021-12-09 08:49:32 +00:00
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#ifndef RSEQ_INTERNAL_H
|
|
|
|
#define RSEQ_INTERNAL_H
|
|
|
|
|
|
|
|
#include <sysdep.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <kernel-features.h>
|
2021-12-09 08:49:32 +00:00
|
|
|
#include <stdbool.h>
|
2021-12-09 08:49:32 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/rseq.h>
|
|
|
|
|
|
|
|
#ifdef RSEQ_SIG
|
2021-12-09 08:49:32 +00:00
|
|
|
static inline bool
|
2021-12-09 08:49:32 +00:00
|
|
|
rseq_register_current_thread (struct pthread *self, bool do_rseq)
|
2021-12-09 08:49:32 +00:00
|
|
|
{
|
2021-12-09 08:49:32 +00:00
|
|
|
if (do_rseq)
|
|
|
|
{
|
|
|
|
int ret = INTERNAL_SYSCALL_CALL (rseq, &self->rseq_area,
|
|
|
|
sizeof (self->rseq_area),
|
|
|
|
0, RSEQ_SIG);
|
|
|
|
if (!INTERNAL_SYSCALL_ERROR_P (ret))
|
2021-12-09 08:49:32 +00:00
|
|
|
return true;
|
2021-12-09 08:49:32 +00:00
|
|
|
}
|
|
|
|
THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED);
|
2021-12-09 08:49:32 +00:00
|
|
|
return false;
|
2021-12-09 08:49:32 +00:00
|
|
|
}
|
|
|
|
#else /* RSEQ_SIG */
|
2021-12-09 08:49:32 +00:00
|
|
|
static inline bool
|
2021-12-09 08:49:32 +00:00
|
|
|
rseq_register_current_thread (struct pthread *self, bool do_rseq)
|
2021-12-09 08:49:32 +00:00
|
|
|
{
|
|
|
|
THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED);
|
2021-12-09 08:49:32 +00:00
|
|
|
return false;
|
2021-12-09 08:49:32 +00:00
|
|
|
}
|
|
|
|
#endif /* RSEQ_SIG */
|
|
|
|
|
|
|
|
#endif /* rseq-internal.h */
|