~vcs-imports/eglibc/trunk

« back to all changes in this revision

Viewing changes to libc/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c

  • Committer: joseph
  • Date: 2014-01-03 17:51:28 UTC
  • Revision ID: svn-v4:7b3dc134-2b1b-0410-93df-9e9f96275f8d:trunk:24942
Merge changes between r24468 and r24941 from /fsf/trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Enumerate available IFUNC implementations of a function.  PowerPC64 version.
 
2
   Copyright (C) 2013-2014 Free Software Foundation, Inc.
 
3
   This file is part of the GNU C Library.
 
4
 
 
5
   The GNU C Library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Lesser General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2.1 of the License, or (at your option) any later version.
 
9
 
 
10
   The GNU C Library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Lesser General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Lesser General Public
 
16
   License along with the GNU C Library; if not, see
 
17
   <http://www.gnu.org/licenses/>.  */
 
18
 
 
19
#include <assert.h>
 
20
#include <string.h>
 
21
#include <wchar.h>
 
22
#include <ldsodefs.h>
 
23
#include <ifunc-impl-list.h>
 
24
 
 
25
/* Maximum number of IFUNC implementations.  */
 
26
#define MAX_IFUNC       6
 
27
 
 
28
size_t
 
29
__libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 
30
                        size_t max)
 
31
{
 
32
  assert (max >= MAX_IFUNC);
 
33
 
 
34
  size_t i = 0;
 
35
 
 
36
  unsigned long int hwcap = GLRO(dl_hwcap);
 
37
  /* hwcap contains only the latest supported ISA, the code checks which is
 
38
     and fills the previous supported ones.  */
 
39
  if (hwcap & PPC_FEATURE_ARCH_2_06)
 
40
    hwcap |= PPC_FEATURE_ARCH_2_05 | PPC_FEATURE_POWER5_PLUS |
 
41
             PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
 
42
  else if (hwcap & PPC_FEATURE_ARCH_2_05)
 
43
    hwcap |= PPC_FEATURE_POWER5_PLUS | PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
 
44
  else if (hwcap & PPC_FEATURE_POWER5_PLUS)
 
45
    hwcap |= PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
 
46
  else if (hwcap & PPC_FEATURE_POWER5)
 
47
    hwcap |= PPC_FEATURE_POWER4;
 
48
 
 
49
#ifdef SHARED
 
50
  /* Support sysdeps/powerpc/powerpc64/multiarch/memcpy.c.  */
 
51
  IFUNC_IMPL (i, name, memcpy,
 
52
              IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_HAS_VSX,
 
53
                              __memcpy_power7)
 
54
              IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_06,
 
55
                              __memcpy_a2)
 
56
              IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_05,
 
57
                              __memcpy_power6)
 
58
              IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_CELL_BE,
 
59
                              __memcpy_cell)
 
60
              IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_POWER4,
 
61
                              __memcpy_power4)
 
62
              IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_ppc))
 
63
 
 
64
  /* Support sysdeps/powerpc/powerpc64/multiarch/memset.c.  */
 
65
  IFUNC_IMPL (i, name, memset,
 
66
              IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_HAS_VSX,
 
67
                              __memset_power7)
 
68
              IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_ARCH_2_05,
 
69
                              __memset_power6)
 
70
              IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_POWER4,
 
71
                              __memset_power4)
 
72
              IFUNC_IMPL_ADD (array, i, memset, 1, __memset_ppc))
 
73
 
 
74
  /* Support sysdeps/powerpc/powerpc64/multiarch/strcpy.c.  */
 
75
  IFUNC_IMPL (i, name, strcpy,
 
76
              IFUNC_IMPL_ADD (array, i, strcpy, hwcap & PPC_FEATURE_HAS_VSX,
 
77
                              __strcpy_power7)
 
78
              IFUNC_IMPL_ADD (array, i, strcpy, 1,
 
79
                              __strcpy_ppc))
 
80
 
 
81
  /* Support sysdeps/powerpc/powerpc64/multiarch/stpcpy.c.  */
 
82
  IFUNC_IMPL (i, name, stpcpy,
 
83
              IFUNC_IMPL_ADD (array, i, stpcpy, hwcap & PPC_FEATURE_HAS_VSX,
 
84
                              __stpcpy_power7)
 
85
              IFUNC_IMPL_ADD (array, i, stpcpy, 1,
 
86
                              __stpcpy_ppc))
 
87
 
 
88
  /* Support sysdeps/powerpc/powerpc64/multiarch/strlen.c.  */
 
89
  IFUNC_IMPL (i, name, strlen,
 
90
              IFUNC_IMPL_ADD (array, i, strlen, hwcap & PPC_FEATURE_HAS_VSX,
 
91
                              __strlen_power7)
 
92
              IFUNC_IMPL_ADD (array, i, strlen, 1,
 
93
                              __strlen_ppc))
 
94
 
 
95
  /* Support sysdeps/powerpc/powerpc64/multiarch/strncmp.c.  */
 
96
  IFUNC_IMPL (i, name, strncmp,
 
97
              IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_HAS_VSX,
 
98
                              __strncmp_power7)
 
99
              IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_POWER4,
 
100
                              __strncmp_power4)
 
101
              IFUNC_IMPL_ADD (array, i, strncmp, 1,
 
102
                              __strncmp_ppc))
 
103
 
 
104
  /* Support sysdeps/powerpc/powerpc64/multiarch/strchr.c.  */
 
105
  IFUNC_IMPL (i, name, strchr,
 
106
              IFUNC_IMPL_ADD (array, i, strchr,
 
107
                              hwcap & PPC_FEATURE_HAS_VSX,
 
108
                              __strchr_power7)
 
109
              IFUNC_IMPL_ADD (array, i, strchr, 1,
 
110
                              __strchr_ppc))
 
111
 
 
112
  /* Support sysdeps/powerpc/powerpc64/multiarch/strchrnul.c.  */
 
113
  IFUNC_IMPL (i, name, strchrnul,
 
114
              IFUNC_IMPL_ADD (array, i, strchrnul,
 
115
                              hwcap & PPC_FEATURE_HAS_VSX,
 
116
                              __strchrnul_power7)
 
117
              IFUNC_IMPL_ADD (array, i, strchrnul, 1,
 
118
                              __strchrnul_ppc))
 
119
#endif
 
120
 
 
121
  /* Support sysdeps/powerpc/powerpc64/multiarch/memcmp.c.  */
 
122
  IFUNC_IMPL (i, name, memcmp,
 
123
              IFUNC_IMPL_ADD (array, i, memcmp, hwcap & PPC_FEATURE_HAS_VSX,
 
124
                              __memcmp_power7)
 
125
              IFUNC_IMPL_ADD (array, i, memcmp, hwcap & PPC_FEATURE_POWER4,
 
126
                              __memcmp_power4)
 
127
              IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_ppc))
 
128
 
 
129
  /* Support sysdeps/powerpc/powerpc64/multiarch/bzero.c.  */
 
130
  IFUNC_IMPL (i, name, bzero,
 
131
              IFUNC_IMPL_ADD (array, i, bzero, hwcap & PPC_FEATURE_HAS_VSX,
 
132
                              __bzero_power7)
 
133
              IFUNC_IMPL_ADD (array, i, bzero, hwcap & PPC_FEATURE_ARCH_2_05,
 
134
                              __bzero_power6)
 
135
              IFUNC_IMPL_ADD (array, i, bzero, hwcap & PPC_FEATURE_POWER4,
 
136
                              __bzero_power4)
 
137
              IFUNC_IMPL_ADD (array, i, bzero, 1, __bzero_ppc))
 
138
 
 
139
  /* Support sysdeps/powerpc/powerpc64/multiarch/mempcpy.c.  */
 
140
  IFUNC_IMPL (i, name, mempcpy,
 
141
              IFUNC_IMPL_ADD (array, i, mempcpy,
 
142
                              hwcap & PPC_FEATURE_HAS_VSX,
 
143
                              __mempcpy_power7)
 
144
              IFUNC_IMPL_ADD (array, i, mempcpy, 1,
 
145
                              __mempcpy_ppc))
 
146
 
 
147
  /* Support sysdeps/powerpc/powerpc64/multiarch/memchr.c.  */
 
148
  IFUNC_IMPL (i, name, memchr,
 
149
              IFUNC_IMPL_ADD (array, i, memchr,
 
150
                              hwcap & PPC_FEATURE_HAS_VSX,
 
151
                              __memchr_power7)
 
152
              IFUNC_IMPL_ADD (array, i, memchr, 1,
 
153
                              __memchr_ppc))
 
154
 
 
155
  /* Support sysdeps/powerpc/powerpc64/multiarch/memrchr.c.  */
 
156
  IFUNC_IMPL (i, name, memrchr,
 
157
              IFUNC_IMPL_ADD (array, i, memrchr,
 
158
                              hwcap & PPC_FEATURE_HAS_VSX,
 
159
                              __memrchr_power7)
 
160
              IFUNC_IMPL_ADD (array, i, memrchr, 1,
 
161
                              __memrchr_ppc))
 
162
 
 
163
  /* Support sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c.  */
 
164
  IFUNC_IMPL (i, name, rawmemchr,
 
165
              IFUNC_IMPL_ADD (array, i, rawmemchr,
 
166
                              hwcap & PPC_FEATURE_HAS_VSX,
 
167
                              __rawmemchr_power7)
 
168
              IFUNC_IMPL_ADD (array, i, rawmemchr, 1,
 
169
                              __rawmemchr_ppc))
 
170
 
 
171
  /* Support sysdeps/powerpc/powerpc64/multiarch/strnlen.c.  */
 
172
  IFUNC_IMPL (i, name, strnlen,
 
173
              IFUNC_IMPL_ADD (array, i, strnlen, hwcap & PPC_FEATURE_HAS_VSX,
 
174
                              __strnlen_power7)
 
175
              IFUNC_IMPL_ADD (array, i, strnlen, 1,
 
176
                              __strnlen_ppc))
 
177
 
 
178
  /* Support sysdeps/powerpc/powerpc64/multiarch/strcasecmp.c.  */
 
179
  IFUNC_IMPL (i, name, strcasecmp,
 
180
              IFUNC_IMPL_ADD (array, i, strcasecmp,
 
181
                              hwcap & PPC_FEATURE_HAS_VSX,
 
182
                              __strcasecmp_power7)
 
183
              IFUNC_IMPL_ADD (array, i, strcasecmp, 1, __strcasecmp_ppc))
 
184
 
 
185
  /* Support sysdeps/powerpc/powerpc64/multiarch/strcasecmp_l.c.  */
 
186
  IFUNC_IMPL (i, name, strcasecmp_l,
 
187
              IFUNC_IMPL_ADD (array, i, strcasecmp_l,
 
188
                              hwcap & PPC_FEATURE_HAS_VSX,
 
189
                              __strcasecmp_l_power7)
 
190
              IFUNC_IMPL_ADD (array, i, strcasecmp_l, 1,
 
191
                              __strcasecmp_l_ppc))
 
192
 
 
193
  /* Support sysdeps/powerpc/powerpc64/multiarch/strncase.c.  */
 
194
  IFUNC_IMPL (i, name, strncasecmp,
 
195
              IFUNC_IMPL_ADD (array, i, strncasecmp,
 
196
                              hwcap & PPC_FEATURE_HAS_VSX,
 
197
                              __strncasecmp_power7)
 
198
              IFUNC_IMPL_ADD (array, i, strncasecmp, 1, __strncasecmp_ppc))
 
199
 
 
200
  /* Support sysdeps/powerpc/powerpc64/multiarch/strncase_l.c.  */
 
201
  IFUNC_IMPL (i, name, strncasecmp_l,
 
202
              IFUNC_IMPL_ADD (array, i, strncasecmp_l,
 
203
                              hwcap & PPC_FEATURE_HAS_VSX,
 
204
                              __strncasecmp_l_power7)
 
205
              IFUNC_IMPL_ADD (array, i, strncasecmp_l, 1,
 
206
                              __strncasecmp_l_ppc))
 
207
 
 
208
  /* Support sysdeps/powerpc/powerpc64/multiarch/wcschr.c.  */
 
209
  IFUNC_IMPL (i, name, wcschr,
 
210
              IFUNC_IMPL_ADD (array, i, wcschr,
 
211
                              hwcap & PPC_FEATURE_HAS_VSX,
 
212
                              __wcschr_power7)
 
213
              IFUNC_IMPL_ADD (array, i, wcschr,
 
214
                              hwcap & PPC_FEATURE_ARCH_2_05,
 
215
                              __wcschr_power6)
 
216
              IFUNC_IMPL_ADD (array, i, wcschr, 1,
 
217
                              __wcschr_ppc))
 
218
 
 
219
  /* Support sysdeps/powerpc/powerpc64/multiarch/wcschr.c.  */
 
220
  IFUNC_IMPL (i, name, wcsrchr,
 
221
              IFUNC_IMPL_ADD (array, i, wcsrchr,
 
222
                              hwcap & PPC_FEATURE_HAS_VSX,
 
223
                              __wcsrchr_power7)
 
224
              IFUNC_IMPL_ADD (array, i, wcsrchr,
 
225
                              hwcap & PPC_FEATURE_ARCH_2_05,
 
226
                              __wcsrchr_power6)
 
227
              IFUNC_IMPL_ADD (array, i, wcsrchr, 1,
 
228
                              __wcsrchr_ppc))
 
229
 
 
230
  /* Support sysdeps/powerpc/powerpc64/multiarch/wcscpy.c.  */
 
231
  IFUNC_IMPL (i, name, wcscpy,
 
232
              IFUNC_IMPL_ADD (array, i, wcscpy,
 
233
                              hwcap & PPC_FEATURE_HAS_VSX,
 
234
                              __wcscpy_power7)
 
235
              IFUNC_IMPL_ADD (array, i, wcscpy,
 
236
                              hwcap & PPC_FEATURE_ARCH_2_05,
 
237
                              __wcscpy_power6)
 
238
              IFUNC_IMPL_ADD (array, i, wcscpy, 1,
 
239
                              __wcscpy_ppc))
 
240
 
 
241
  return i;
 
242
}