|
Packit Service |
82fcde |
/* IFUNC generic definitions.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
|
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 |
/* These macros are used to implement ifunc selection in C. To implement
|
|
Packit Service |
82fcde |
an ifunc function, foo, which returns the address of __foo_impl1 or
|
|
Packit Service |
82fcde |
__foo_impl2:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define foo __redirect_foo
|
|
Packit Service |
82fcde |
#include <foo.h>
|
|
Packit Service |
82fcde |
#undef foo
|
|
Packit Service |
82fcde |
#define SYMBOL_NAME foo
|
|
Packit Service |
82fcde |
#include <ifunc-init.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
extern __typeof (REDIRECT_NAME) OPTIMIZE (impl1) attribute_hidden;
|
|
Packit Service |
82fcde |
extern __typeof (REDIRECT_NAME) OPTIMIZE (impl2) attribute_hidden;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static inline void *
|
|
Packit Service |
82fcde |
foo_selector (void)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
if (condition)
|
|
Packit Service |
82fcde |
return OPTIMIZE (impl2);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return OPTIMIZE (impl1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
libc_ifunc_redirected (__redirect_foo, foo, IFUNC_SELECTOR ());
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define PASTER1(x,y) x##_##y
|
|
Packit Service |
82fcde |
#define EVALUATOR1(x,y) PASTER1 (x,y)
|
|
Packit Service |
82fcde |
#define PASTER2(x,y) __##x##_##y
|
|
Packit Service |
82fcde |
#define EVALUATOR2(x,y) PASTER2 (x,y)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Basically set '__redirect_<symbol>' to use as type definition,
|
|
Packit Service |
82fcde |
'__<symbol>_<variant>' as the optimized implementation and
|
|
Packit Service |
82fcde |
'<symbol>_ifunc_selector' as the IFUNC selector. */
|
|
Packit Service |
82fcde |
#define REDIRECT_NAME EVALUATOR1 (__redirect, SYMBOL_NAME)
|
|
Packit Service |
82fcde |
#define OPTIMIZE(name) EVALUATOR2 (SYMBOL_NAME, name)
|
|
Packit Service |
82fcde |
#define IFUNC_SELECTOR EVALUATOR1 (SYMBOL_NAME, ifunc_selector)
|