~ubuntu-branches/ubuntu/precise/eglibc/precise-201308281639

« back to all changes in this revision

Viewing changes to sysdeps/i386/i686/multiarch/strcpy.S

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Multiple versions of strcpy
 
2
   Copyright (C) 2011 Free Software Foundation, Inc.
 
3
   Contributed by Intel Corporation.
 
4
   This file is part of the GNU C Library.
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
16
   You should have received a copy of the GNU Lesser General Public
 
17
   License along with the GNU C Library; if not, write to the Free
 
18
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
19
   02111-1307 USA.  */
 
20
 
 
21
#include <sysdep.h>
 
22
#include <init-arch.h>
 
23
 
 
24
#if !defined (USE_AS_STPCPY) && !defined (USE_AS_STRNCPY)
 
25
# ifndef STRCPY
 
26
#  define STRCPY strcpy
 
27
# endif
 
28
#endif
 
29
 
 
30
#ifdef USE_AS_STPCPY
 
31
# ifdef USE_AS_STRNCPY
 
32
#  define STRCPY_SSSE3  __stpncpy_ssse3
 
33
#  define STRCPY_SSE2           __stpncpy_sse2
 
34
#  define STRCPY_IA32           __stpncpy_ia32
 
35
#  define __GI_STRCPY           __GI_stpncpy
 
36
#  define __GI___STRCPY         __GI___stpncpy
 
37
# else
 
38
#  define STRCPY_SSSE3  __stpcpy_ssse3
 
39
#  define STRCPY_SSE2           __stpcpy_sse2
 
40
#  define STRCPY_IA32           __stpcpy_ia32
 
41
#  define __GI_STRCPY           __GI_stpcpy
 
42
#  define __GI___STRCPY         __GI___stpcpy
 
43
# endif
 
44
#else
 
45
# ifdef USE_AS_STRNCPY
 
46
#  define STRCPY_SSSE3  __strncpy_ssse3
 
47
#  define STRCPY_SSE2           __strncpy_sse2
 
48
#  define STRCPY_IA32           __strncpy_ia32
 
49
#  define __GI_STRCPY           __GI_strncpy
 
50
# else
 
51
#  define STRCPY_SSSE3  __strcpy_ssse3
 
52
#  define STRCPY_SSE2           __strcpy_sse2
 
53
#  define STRCPY_IA32           __strcpy_ia32
 
54
#  define __GI_STRCPY           __GI_strcpy
 
55
# endif
 
56
#endif
 
57
 
 
58
 
 
59
/* Define multiple versions only for the definition in libc.  Don't
 
60
   define multiple versions for strncpy in static library since we
 
61
   need strncpy before the initialization happened.  */
 
62
#ifndef NOT_IN_libc
 
63
 
 
64
# ifdef SHARED
 
65
        .section        .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits
 
66
        .globl  __i686.get_pc_thunk.bx
 
67
        .hidden __i686.get_pc_thunk.bx
 
68
        .p2align 4
 
69
        .type   __i686.get_pc_thunk.bx,@function
 
70
__i686.get_pc_thunk.bx:
 
71
        movl    (%esp), %ebx
 
72
        ret
 
73
 
 
74
        .text
 
75
ENTRY(STRCPY)
 
76
        .type   STRCPY, @gnu_indirect_function
 
77
        pushl   %ebx
 
78
        cfi_adjust_cfa_offset (4)
 
79
        cfi_rel_offset (ebx, 0)
 
80
        call    __i686.get_pc_thunk.bx
 
81
        addl    $_GLOBAL_OFFSET_TABLE_, %ebx
 
82
        cmpl    $0, KIND_OFFSET+__cpu_features@GOTOFF(%ebx)
 
83
        jne     1f
 
84
        call    __init_cpu_features
 
85
1:      leal    STRCPY_IA32@GOTOFF(%ebx), %eax
 
86
        testl   $bit_SSE2, CPUID_OFFSET+index_SSE2+__cpu_features@GOTOFF(%ebx)
 
87
        jz      2f
 
88
        leal    STRCPY_SSE2@GOTOFF(%ebx), %eax
 
89
        testl   $bit_Fast_Unaligned_Load, FEATURE_OFFSET+index_Fast_Unaligned_Load+__cpu_features@GOTOFF(%ebx)
 
90
        jnz     2f
 
91
        testl   $bit_SSSE3, CPUID_OFFSET+index_SSSE3+__cpu_features@GOTOFF(%ebx)
 
92
        jz      2f
 
93
        leal    STRCPY_SSSE3@GOTOFF(%ebx), %eax
 
94
2:      popl    %ebx
 
95
        cfi_adjust_cfa_offset (-4)
 
96
        cfi_restore (ebx)
 
97
        ret
 
98
END(STRCPY)
 
99
# else
 
100
 
 
101
ENTRY(STRCPY)
 
102
        .type   STRCPY, @gnu_indirect_function
 
103
        cmpl    $0, KIND_OFFSET+__cpu_features
 
104
        jne     1f
 
105
        call    __init_cpu_features
 
106
1:      leal    STRCPY_IA32, %eax
 
107
        testl   $bit_SSE2, CPUID_OFFSET+index_SSE2+__cpu_features
 
108
        jz      2f
 
109
        leal    STRCPY_SSE2, %eax
 
110
        testl   $bit_Fast_Unaligned_Load, FEATURE_OFFSET+index_Fast_Unaligned_Load+__cpu_features
 
111
        jnz     2f
 
112
        testl   $bit_SSSE3, CPUID_OFFSET+index_SSSE3+__cpu_features
 
113
        jz      2f
 
114
        leal    STRCPY_SSSE3, %eax
 
115
2:      ret
 
116
END(STRCPY)
 
117
 
 
118
# endif
 
119
 
 
120
# undef ENTRY
 
121
# define ENTRY(name) \
 
122
        .type STRCPY_IA32, @function; \
 
123
        .align 16; \
 
124
        STRCPY_IA32: cfi_startproc; \
 
125
        CALL_MCOUNT
 
126
# undef END
 
127
# define END(name) \
 
128
        cfi_endproc; .size STRCPY_IA32, .-STRCPY_IA32
 
129
 
 
130
# ifdef SHARED
 
131
#  undef libc_hidden_builtin_def
 
132
/* It doesn't make sense to send libc-internal strcpy calls through a PLT.
 
133
   The speedup we get from using SSSE3 instruction is likely eaten away
 
134
   by the indirect call in the PLT.  */
 
135
#  define libc_hidden_builtin_def(name) \
 
136
        .globl __GI_STRCPY; __GI_STRCPY = STRCPY_IA32
 
137
#  undef libc_hidden_def
 
138
#  define libc_hidden_def(name) \
 
139
        .globl __GI___STRCPY; __GI___STRCPY = STRCPY_IA32
 
140
 
 
141
# endif
 
142
#endif
 
143
 
 
144
#ifdef USE_AS_STPCPY
 
145
# ifdef USE_AS_STRNCPY
 
146
#  include "../../stpncpy.S"
 
147
# else
 
148
#  include "../../i586/stpcpy.S"
 
149
# endif
 
150
#else
 
151
# ifndef USE_AS_STRNCPY
 
152
#  include "../../i586/strcpy.S"
 
153
# endif
 
154
#endif