1 /* IFUNC resolver function for CPU specific functions.
3 Copyright (C) 2012-2014 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
21 #include <dl-procinfo.h>
23 #define STFLE_BITS_Z10 34 /* General instructions extension */
24 #define STFLE_BITS_Z196 45 /* Distinct operands, pop ... */
28 #define IFUNC_RESOLVE(FUNC) \
29 asm (".globl " #FUNC "\n\t" \
30 ".type " #FUNC ",@gnu_indirect_function\n\t" \
31 ".set " #FUNC ",resolve_" #FUNC "\n\t" \
32 ".globl __GI_" #FUNC "\n\t" \
33 ".set __GI_" #FUNC "," #FUNC "\n"); \
35 /* Make the declarations of the optimized functions hidden in order
36 to prevent GOT slots being generated for them. */ \
37 extern void *FUNC##_z196 attribute_hidden; \
38 extern void *FUNC##_z10 attribute_hidden; \
39 extern void *FUNC##_z900 attribute_hidden; \
41 void *resolve_##FUNC (unsigned long int dl_hwcap) \
43 if (dl_hwcap & HWCAP_S390_STFLE) \
45 /* We want just 1 double word to be returned. */ \
46 register unsigned long reg0 asm("0") = 0; \
47 unsigned long stfle_bits; \
49 asm volatile(".machine push" "\n\t" \
50 ".machine \"z9-109\"" "\n\t" \
53 : "=QS" (stfle_bits), "+d" (reg0) \
56 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0) \
57 return &FUNC##_z196; \
58 else if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z10))) != 0) \
61 return &FUNC##_z900; \
64 return &FUNC##_z900; \
69 asm(".weak bcmp ; bcmp = memcmp");
71 /* In the static lib memcpy is needed before the reloc is resolved. */