brintos

brintos / linux-shallow public Read only

0
0
Text · 687 B · d313358 Raw
41 lines · c
1/* SPDX-License-Identifier: LGPL-2.1-only OR MIT */2/*3 * rseq-x86-thread-pointer.h4 *5 * (C) Copyright 2021 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>6 */7 8#ifndef _RSEQ_X86_THREAD_POINTER9#define _RSEQ_X86_THREAD_POINTER10 11#include <features.h>12 13#ifdef __cplusplus14extern "C" {15#endif16 17#if __GNUC_PREREQ (11, 1)18static inline void *rseq_thread_pointer(void)19{20	return __builtin_thread_pointer();21}22#else23static inline void *rseq_thread_pointer(void)24{25	void *__result;26 27# ifdef __x86_64__28	__asm__ ("mov %%fs:0, %0" : "=r" (__result));29# else30	__asm__ ("mov %%gs:0, %0" : "=r" (__result));31# endif32	return __result;33}34#endif /* !GCC 11 */35 36#ifdef __cplusplus37}38#endif39 40#endif41