2018-12-18 Stefan Liebler <stli@linux.ibm.com>
* sysdeps/s390/multiarch/Makefile
+ (sysdep_routines): Remove strncpy variants.
+ * sysdeps/s390/Makefile (sysdep_routines): Add strncpy variants.
+ * sysdeps/s390/multiarch/ifunc-impl-list.c
+ (__libc_ifunc_impl_list): Refactor ifunc handling for strncpy.
+ * sysdeps/s390/multiarch/strncpy-vx.S: Move to ...
+ * sysdeps/s390/strncpy-vx.S: ... here and adjust ifunc handling.
+ * sysdeps/s390/multiarch/strncpy.c: Move to ...
+ * sysdeps/s390/strncpy.c: ... here and adjust ifunc handling.
+ * sysdeps/s390/ifunc-strncpy.h: New file.
+ * sysdeps/s390/s390-64/strncpy.S: Move to ...
+ * sysdeps/s390/s390-64/strncpy-z900.S: ... here
+ and adjust ifunc handling.
+ * sysdeps/s390/s390-32/strncpy.S: Move to ...
+ * sysdeps/s390/s390-32/strncpy-z900.S: ... here
+ and adjust ifunc handling.
+ * sysdeps/s390/s390-32/multiarch/strncpy.c: Delete file.
+ * sysdeps/s390/s390-64/multiarch/strncpy.c: Likewise.
+
+2018-12-18 Stefan Liebler <stli@linux.ibm.com>
+
+ * sysdeps/s390/multiarch/Makefile
(sysdep_routines): Remove stpcpy variants.
* sysdeps/s390/Makefile (sysdep_routines): Add stpcpy variants.
* sysdeps/s390/multiarch/ifunc-impl-list.c
strlen strlen-vx strlen-c \
strnlen strnlen-vx strnlen-c \
strcpy strcpy-vx strcpy-z900 \
- stpcpy stpcpy-vx stpcpy-c
+ stpcpy stpcpy-vx stpcpy-c \
+ strncpy strncpy-vx strncpy-z900
endif
--- /dev/null
+/* strncpy variant information on S/390 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#if defined USE_MULTIARCH && IS_IN (libc) \
+ && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT
+# define HAVE_STRNCPY_IFUNC 1
+#else
+# define HAVE_STRNCPY_IFUNC 0
+#endif
+
+#ifdef HAVE_S390_VX_ASM_SUPPORT
+# define HAVE_STRNCPY_IFUNC_AND_VX_SUPPORT HAVE_STRNCPY_IFUNC
+#else
+# define HAVE_STRNCPY_IFUNC_AND_VX_SUPPORT 0
+#endif
+
+#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT
+# define STRNCPY_DEFAULT STRNCPY_Z13
+# define HAVE_STRNCPY_Z900_G5 0
+# define HAVE_STRNCPY_Z13 1
+#else
+# define STRNCPY_DEFAULT STRNCPY_Z900_G5
+# define HAVE_STRNCPY_Z900_G5 1
+# define HAVE_STRNCPY_Z13 HAVE_STRNCPY_IFUNC_AND_VX_SUPPORT
+#endif
+
+#if HAVE_STRNCPY_Z900_G5
+# define STRNCPY_Z900_G5 __strncpy_default
+#else
+# define STRNCPY_Z900_G5 NULL
+#endif
+
+#if HAVE_STRNCPY_Z13
+# define STRNCPY_Z13 __strncpy_vx
+#else
+# define STRNCPY_Z13 NULL
+#endif
ifeq ($(subdir),string)
-sysdep_routines += strncpy strncpy-vx \
- stpncpy stpncpy-vx stpncpy-c \
+sysdep_routines += stpncpy stpncpy-vx stpncpy-c \
strcat strcat-vx strcat-c \
strncat strncat-vx strncat-c \
strcmp strcmp-vx \
#include <ifunc-strnlen.h>
#include <ifunc-strcpy.h>
#include <ifunc-stpcpy.h>
+#include <ifunc-strncpy.h>
/* Maximum number of IFUNC implementations. */
#define MAX_IFUNC 3
)
#endif /* HAVE_STPCPY_IFUNC */
+#if HAVE_STRNCPY_IFUNC
+ IFUNC_IMPL (i, name, strncpy,
+# if HAVE_STRNCPY_Z13
+ IFUNC_IMPL_ADD (array, i, strncpy,
+ dl_hwcap & HWCAP_S390_VX, STRNCPY_Z13)
+# endif
+# if HAVE_STRNCPY_Z900_G5
+ IFUNC_IMPL_ADD (array, i, strncpy, 1, STRNCPY_Z900_G5)
+# endif
+ )
+#endif /* HAVE_STRNCPY_IFUNC */
+
+
#ifdef HAVE_S390_VX_ASM_SUPPORT
# define IFUNC_VX_IMPL(FUNC) \
IFUNC_VX_IMPL (wcpcpy);
- IFUNC_VX_IMPL (strncpy);
IFUNC_VX_IMPL (wcsncpy);
IFUNC_VX_IMPL (stpncpy);
+++ /dev/null
-/* Multiple versions of strncpy.
- Copyright (C) 2015-2018 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-/* This wrapper-file is needed, because otherwise file
- sysdeps/s390/s390-[32|64]/strncpy.S will be used. */
-#include <sysdeps/s390/multiarch/strncpy.c>
* R4 = max of bytes to copy
*/
+#include <ifunc-strncpy.h>
#include "sysdep.h"
#include "asm-syntax.h"
-ENTRY(strncpy)
+#if HAVE_STRNCPY_Z900_G5
+ENTRY(STRNCPY_Z900_G5)
.text
st %r2,24(%r15) # save dst pointer
slr %r2,%r3 # %r3 points to src, %r2+%r3 to dst
jo .L9
.Lexit: l %r2,24(%r15) # return dst pointer
br %r14
-END(strncpy)
-libc_hidden_builtin_def (strncpy)
+END(STRNCPY_Z900_G5)
+
+# if ! HAVE_STRNCPY_IFUNC
+strong_alias (STRNCPY_Z900_G5, strncpy)
+# endif
+
+# if defined SHARED && IS_IN (libc)
+strong_alias (STRNCPY_Z900_G5, __GI_strncpy)
+# endif
+#endif
+++ /dev/null
-/* Multiple versions of strncpy.
- Copyright (C) 2015-2018 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-/* This wrapper-file is needed, because otherwise file
- sysdeps/s390/s390-[32|64]/strncpy.S will be used. */
-#include <sysdeps/s390/multiarch/strncpy.c>
%r3 = address of source (src)
%r4 = max of bytes to copy. */
+#include <ifunc-strncpy.h>
#include "sysdep.h"
#include "asm-syntax.h"
-ENTRY(strncpy)
+#if HAVE_STRNCPY_Z900_G5
+ENTRY(STRNCPY_Z900_G5)
.text
stg %r2,48(%r15) # save dst pointer
slgr %r2,%r3 # %r3 points to src, %r2+%r3 to dst
jo .L13
.Lexit: lg %r2,48(%r15) # return dst pointer
br %r14
-END(strncpy)
-libc_hidden_builtin_def (strncpy)
+END(STRNCPY_Z900_G5)
+
+# if ! HAVE_STRNCPY_IFUNC
+strong_alias (STRNCPY_Z900_G5, strncpy)
+# endif
+
+# if defined SHARED && IS_IN (libc)
+strong_alias (STRNCPY_Z900_G5, __GI_strncpy)
+# endif
+#endif
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
-
-# include "sysdep.h"
-# include "asm-syntax.h"
+#include <ifunc-strncpy.h>
+#include "sysdep.h"
+#include "asm-syntax.h"
.text
+#if HAVE_STRNCPY_Z13
/* char * strncpy (const char *dest, const char *src, size_t n)
Copy at most n characters of string src to dest.
-v18=part of src
-v31=register save area for r6, r7
*/
-ENTRY(__strncpy_vx)
+ENTRY(STRNCPY_Z13)
.machine "z13"
.machinemode "zarch_nohighgprs"
vl %v16,0(%r5,%r3) /* Load s. */
j .Llt64
-END(__strncpy_vx)
+END(STRNCPY_Z13)
-# define strncpy __strncpy_c
-# undef libc_hidden_builtin_def
-# define libc_hidden_builtin_def(name) strong_alias(__strncpy_c, __GI_strncpy)
-#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */
+# if ! HAVE_STRNCPY_IFUNC
+strong_alias (STRNCPY_Z13, strncpy)
+# endif
-/* Include strncpy-implementation in s390-32/s390-64 subdirectory. */
-#include <strncpy.S>
+# if ! HAVE_STRNCPY_Z900_G5 && defined SHARED && IS_IN (libc)
+strong_alias (STRNCPY_Z13, __GI_strncpy)
+# endif
+#endif
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+#include <ifunc-strncpy.h>
+
+#if HAVE_STRNCPY_IFUNC
# define strncpy __redirect_strncpy
/* Omit the strncpy inline definitions because it would redefine strncpy. */
# define __NO_STRING_INLINES
# undef strncpy
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc2_redirected (__redirect_strncpy, __strncpy, strncpy);
+# if HAVE_STRNCPY_Z900_G5
+extern __typeof (__redirect_strncpy) STRNCPY_Z900_G5 attribute_hidden;
+# endif
+
+# if HAVE_STRNCPY_Z13
+extern __typeof (__redirect_strncpy) STRNCPY_Z13 attribute_hidden;
+# endif
+s390_libc_ifunc_expr (__redirect_strncpy, strncpy,
+ (HAVE_STRNCPY_Z13 && (hwcap & HWCAP_S390_VX))
+ ? STRNCPY_Z13
+ : STRNCPY_DEFAULT
+ )
#endif