diff options
Diffstat (limited to 'sysdeps/s390/s390-64')
40 files changed, 416 insertions, 1860 deletions
diff --git a/sysdeps/s390/s390-64/Makefile b/sysdeps/s390/s390-64/Makefile index ce4f0c5c88..b4d793bb3d 100644 --- a/sysdeps/s390/s390-64/Makefile +++ b/sysdeps/s390/s390-64/Makefile @@ -1,5 +1,3 @@ -pic-ccflag = -fpic - ifeq ($(subdir),gmon) sysdep_routines += s390x-mcount endif @@ -9,84 +7,3 @@ CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused CFLAGS-dl-load.c += -Wno-unused CFLAGS-dl-reloc.c += -Wno-unused endif - -ifeq ($(subdir),iconvdata) -ISO-8859-1_CP037_Z900-routines := iso-8859-1_cp037_z900 -ISO-8859-1_CP037_Z900-map := gconv.map - -UTF8_UTF32_Z9-routines := utf8-utf32-z9 -UTF8_UTF32_Z9-map := gconv.map - -UTF16_UTF32_Z9-routines := utf16-utf32-z9 -UTF16_UTF32_Z9-map := gconv.map - -UTF8_UTF16_Z9-routines := utf8-utf16-z9 -UTF8_UTF16_Z9-map := gconv.map - -s390x-iconv-modules = ISO-8859-1_CP037_Z900 UTF8_UTF16_Z9 UTF16_UTF32_Z9 UTF8_UTF32_Z9 - -extra-modules-left += $(s390x-iconv-modules) -include extra-module.mk - -cpp-srcs-left := $(foreach mod,$(s390x-iconv-modules),$($(mod)-routines)) -lib := iconvdata -include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left)) - -extra-objs += $(addsuffix .so, $(s390x-iconv-modules)) -install-others += $(patsubst %, $(inst_gconvdir)/%.so, $(s390x-iconv-modules)) - -$(patsubst %, $(inst_gconvdir)/%.so, $(s390x-iconv-modules)) : \ -$(inst_gconvdir)/%.so: $(objpfx)%.so $(+force) - $(do-install-program) - -$(objpfx)gconv-modules-s390: gconv-modules $(+force) - cp $< $@ - echo >> $@ - echo "# S/390 hardware accelerated modules" >> $@ - echo -n "module ISO-8859-1// IBM037// " >> $@ - echo " ISO-8859-1_CP037_Z900 1" >> $@ - echo -n "module IBM037// ISO-8859-1// " >> $@ - echo " ISO-8859-1_CP037_Z900 1" >> $@ - echo -n "module ISO-10646/UTF8/ UTF-32// " >> $@ - echo " UTF8_UTF32_Z9 1" >> $@ - echo -n "module UTF-32BE// ISO-10646/UTF8/ " >> $@ - echo " UTF8_UTF32_Z9 1" >> $@ - echo -n "module ISO-10646/UTF8/ UTF-32BE// " >> $@ - echo " UTF8_UTF32_Z9 1" >> $@ - echo -n "module UTF-16BE// UTF-32// " >> $@ - echo " UTF16_UTF32_Z9 1" >> $@ - echo -n "module UTF-32BE// UTF-16// " >> $@ - echo " UTF16_UTF32_Z9 1" >> $@ - echo -n "module INTERNAL UTF-16// " >> $@ - echo " UTF16_UTF32_Z9 1" >> $@ - echo -n "module UTF-32BE// UTF-16BE// " >> $@ - echo " UTF16_UTF32_Z9 1" >> $@ - echo -n "module INTERNAL UTF-16BE// " >> $@ - echo " UTF16_UTF32_Z9 1" >> $@ - echo -n "module UTF-16BE// UTF-32BE// " >> $@ - echo " UTF16_UTF32_Z9 1" >> $@ - echo -n "module UTF-16BE// INTERNAL " >> $@ - echo " UTF16_UTF32_Z9 1" >> $@ - echo -n "module UTF-16BE// ISO-10646/UTF8/ " >> $@ - echo " UTF8_UTF16_Z9 1" >> $@ - echo -n "module ISO-10646/UTF8/ UTF-16// " >> $@ - echo " UTF8_UTF16_Z9 1" >> $@ - echo -n "module ISO-10646/UTF8/ UTF-16BE// " >> $@ - echo " UTF8_UTF16_Z9 1" >> $@ - -$(inst_gconvdir)/gconv-modules: $(objpfx)gconv-modules-s390 $(+force) - $(do-install) -ifeq (no,$(cross-compiling)) -# Update the $(prefix)/lib/gconv/gconv-modules.cache file. This is necessary -# if this libc has more gconv modules than the previously installed one. - if test -f "$(inst_gconvdir)/gconv-modules.cache"; then \ - LC_ALL=C \ - $(rtld-prefix) \ - $(common-objpfx)iconv/iconvconfig \ - $(addprefix --prefix=,$(install_root)); \ - fi -else - @echo '*@*@*@ You should recreate $(inst_gconvdir)/gconv-modules.cache' -endif - -endif diff --git a/sysdeps/s390/s390-64/__longjmp.c b/sysdeps/s390/s390-64/__longjmp.c index 66005b82ac..17aa0810e6 100644 --- a/sysdeps/s390/s390-64/__longjmp.c +++ b/sysdeps/s390/s390-64/__longjmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2016 Free Software Foundation, Inc. +/* Copyright (C) 2001-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). diff --git a/sysdeps/s390/s390-64/add_n.S b/sysdeps/s390/s390-64/add_n.S index 11bc60170b..5cbc6d0d8e 100644 --- a/sysdeps/s390/s390-64/add_n.S +++ b/sysdeps/s390/s390-64/add_n.S @@ -1,6 +1,6 @@ /* Add two limb vectors of the same length > 0 and store sum in a third limb vector. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU MP Library. diff --git a/sysdeps/s390/s390-64/backtrace.c b/sysdeps/s390/s390-64/backtrace.c index 5f8b7f8fff..3efcbe4096 100644 --- a/sysdeps/s390/s390-64/backtrace.c +++ b/sysdeps/s390/s390-64/backtrace.c @@ -1,5 +1,5 @@ /* Return backtrace of current program state. 64 bit S/390 version. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>. This file is part of the GNU C Library. diff --git a/sysdeps/s390/s390-64/bcopy.S b/sysdeps/s390/s390-64/bcopy.S index 7eeeae499c..806dd15d02 100644 --- a/sysdeps/s390/s390-64/bcopy.S +++ b/sysdeps/s390/s390-64/bcopy.S @@ -1,6 +1,6 @@ /* bcopy -- copy a block from source to destination. 64 bit S/390 version. This file is part of the GNU C Library. - Copyright (C) 2000-2016 Free Software Foundation, Inc. + Copyright (C) 2000-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/s390/s390-64/bits/wordsize.h b/sysdeps/s390/s390-64/bits/wordsize.h index da791fa28e..00e88b0628 100644 --- a/sysdeps/s390/s390-64/bits/wordsize.h +++ b/sysdeps/s390/s390-64/bits/wordsize.h @@ -5,15 +5,7 @@ #else # define __WORDSIZE 32 # define __WORDSIZE32_SIZE_ULONG 1 +# define __WORDSIZE32_PTRDIFF_LONG 0 #endif -#if !defined __NO_LONG_DOUBLE_MATH && !defined __LONG_DOUBLE_MATH_OPTIONAL - -/* Signal that we didn't used to have a `long double'. The changes all - the `long double' function variants to be redirects to the double - functions. */ -# define __LONG_DOUBLE_MATH_OPTIONAL 1 -# ifndef __LONG_DOUBLE_128__ -# define __NO_LONG_DOUBLE_MATH 1 -# endif -#endif +#define __WORDSIZE_TIME64_COMPAT32 0 diff --git a/sysdeps/s390/s390-64/bzero.S b/sysdeps/s390/s390-64/bzero.S index 891efc2d6e..b321665298 100644 --- a/sysdeps/s390/s390-64/bzero.S +++ b/sysdeps/s390/s390-64/bzero.S @@ -1,6 +1,6 @@ /* bzero -- set a block of memory to zero. 64 bit S/390 version. This file is part of the GNU C Library. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/s390/s390-64/crti.S b/sysdeps/s390/s390-64/crti.S index 248ef83dbe..f676eb5259 100644 --- a/sysdeps/s390/s390-64/crti.S +++ b/sysdeps/s390/s390-64/crti.S @@ -1,5 +1,5 @@ /* Special .init and .fini section support for 64 bit S/390. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -59,6 +59,7 @@ .section .init,"ax",@progbits .align 4 .globl _init + .hidden _init .type _init,@function _init: stmg %r6,%r15,48(%r15) @@ -81,6 +82,7 @@ _init: .section .fini,"ax",@progbits .align 4 .globl _fini + .hidden _fini .type _fini,@function _fini: stmg %r6,%r15,48(%r15) diff --git a/sysdeps/s390/s390-64/crtn.S b/sysdeps/s390/s390-64/crtn.S index ce906acffc..8ae6394b72 100644 --- a/sysdeps/s390/s390-64/crtn.S +++ b/sysdeps/s390/s390-64/crtn.S @@ -1,5 +1,5 @@ /* Special .init and .fini section support for 64 bit S/390. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h index cb81aafc5d..f22db7860b 100644 --- a/sysdeps/s390/s390-64/dl-machine.h +++ b/sysdeps/s390/s390-64/dl-machine.h @@ -1,6 +1,6 @@ /* Machine-dependent ELF dynamic relocation inline functions. 64 bit S/390 Version. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -26,6 +26,7 @@ #include <sys/param.h> #include <string.h> #include <link.h> +#include <sysdeps/s390/dl-procinfo.h> #include <dl-irel.h> #define ELF_MACHINE_IRELATIVE R_390_IRELATIVE @@ -78,6 +79,10 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) { extern void _dl_runtime_resolve (Elf64_Word); extern void _dl_runtime_profile (Elf64_Word); +#if defined HAVE_S390_VX_ASM_SUPPORT + extern void _dl_runtime_resolve_vx (Elf64_Word); + extern void _dl_runtime_profile_vx (Elf64_Word); +#endif if (l->l_info[DT_JMPREL] && lazy) { @@ -93,7 +98,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) if (got[1]) { l->l_mach.plt = got[1] + l->l_addr; - l->l_mach.gotplt = (Elf64_Addr) &got[3]; + l->l_mach.jmprel = (const Elf64_Rela *) D_PTR (l, l_info[DT_JMPREL]); } got[1] = (Elf64_Addr) l; /* Identify this shared object. */ @@ -105,7 +110,14 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) end in this function. */ if (__glibc_unlikely (profile)) { +#if defined HAVE_S390_VX_ASM_SUPPORT + if (GLRO(dl_hwcap) & HWCAP_S390_VX) + got[2] = (Elf64_Addr) &_dl_runtime_profile_vx; + else + got[2] = (Elf64_Addr) &_dl_runtime_profile; +#else got[2] = (Elf64_Addr) &_dl_runtime_profile; +#endif if (GLRO(dl_profile) != NULL && _dl_name_match_p (GLRO(dl_profile), l)) @@ -114,9 +126,18 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) GL(dl_profile_map) = l; } else - /* This function will get called to fix up the GOT entry indicated by - the offset on the stack, and then jump to the resolved address. */ - got[2] = (Elf64_Addr) &_dl_runtime_resolve; + { + /* This function will get called to fix up the GOT entry indicated by + the offset on the stack, and then jump to the resolved address. */ +#if defined HAVE_S390_VX_ASM_SUPPORT + if (GLRO(dl_hwcap) & HWCAP_S390_VX) + got[2] = (Elf64_Addr) &_dl_runtime_resolve_vx; + else + got[2] = (Elf64_Addr) &_dl_runtime_resolve; +#else + got[2] = (Elf64_Addr) &_dl_runtime_resolve; +#endif + } } return lazy; @@ -221,6 +242,7 @@ dl_platform_init (void) static inline Elf64_Addr elf_machine_fixup_plt (struct link_map *map, lookup_t t, + const ElfW(Sym) *refsym, const ElfW(Sym) *sym, const Elf64_Rela *reloc, Elf64_Addr *reloc_addr, Elf64_Addr value) { @@ -283,7 +305,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc, const Elf64_Sym *const refsym = sym; #endif struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type); - Elf64_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value; + Elf64_Addr value = SYMBOL_ADDRESS (sym_map, sym, true); if (sym != NULL && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, @@ -439,9 +461,7 @@ elf_machine_lazy_rel (struct link_map *map, if (__builtin_expect (map->l_mach.plt, 0) == 0) *reloc_addr += l_addr; else - *reloc_addr = - map->l_mach.plt - + (((Elf64_Addr) reloc_addr) - map->l_mach.gotplt) * 4; + *reloc_addr = map->l_mach.plt + (reloc - map->l_mach.jmprel) * 32; } else if (__glibc_likely (r_type == R_390_IRELATIVE)) { diff --git a/sysdeps/s390/s390-64/dl-trampoline.S b/sysdeps/s390/s390-64/dl-trampoline.S index 6919ed0138..03c8f0415b 100644 --- a/sysdeps/s390/s390-64/dl-trampoline.S +++ b/sysdeps/s390/s390-64/dl-trampoline.S @@ -1,5 +1,5 @@ /* PLT trampolines. s390x version. - Copyright (C) 2005-2016 Free Software Foundation, Inc. + Copyright (C) 2005-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 @@ -16,126 +16,18 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -/* The PLT stubs will call _dl_runtime_resolve/_dl_runtime_profile - * with the following linkage: - * r2 - r6 : parameter registers - * f0, f2, f4, f6 : floating point parameter registers - * 48(r15), 56(r15) : PLT arguments PLT1, PLT2 - * 160(r15) : additional stack parameters - * The normal clobber rules for function calls apply: - * r0 - r5 : call clobbered - * r6 - r13 : call saved - * r14 : return address (call clobbered) - * r15 : stack pointer (call saved) - * f1, f3, f5, f7 : call saved - * f0 - f3, f5, f7 - f15 : call clobbered - */ - #include <sysdep.h> .text - .globl _dl_runtime_resolve - .type _dl_runtime_resolve, @function - cfi_startproc - .align 16 -_dl_runtime_resolve: - stmg %r2,%r5,64(15) # save call-clobbered argument registers - stg %r14,96(15) - cfi_offset (r14, -64) - lgr %r0,%r15 - aghi %r15,-160 # create stack frame - cfi_adjust_cfa_offset (160) - stg %r0,0(%r15) # write backchain - lmg %r2,%r3,208(%r15)# load args saved by PLT - brasl %r14,_dl_fixup # call fixup - lgr %r1,%r2 # function addr returned in r2 - aghi %r15,160 # remove stack frame - cfi_adjust_cfa_offset (-160) - lg %r14,96(15) # restore registers - lmg %r2,%r5,64(15) - br %r1 - cfi_endproc - .size _dl_runtime_resolve, .-_dl_runtime_resolve - - -#ifndef PROF - .globl _dl_runtime_profile - .type _dl_runtime_profile, @function - cfi_startproc - .align 16 -_dl_runtime_profile: - stmg %r2,%r6,64(%r15) # save call-clobbered arg regs - std %f0,104(%r15) # + r6 needed as arg for - std %f2,112(%r15) # _dl_profile_fixup - std %f4,120(%r15) - std %f6,128(%r15) - stg %r12,24(%r15) # r12 is used as backup of r15 - stg %r14,32(%r15) - cfi_offset (r6, -96) - cfi_offset (f0, -56) - cfi_offset (f2, -48) - cfi_offset (f4, -40) - cfi_offset (f6, -32) - cfi_offset (r12, -136) - cfi_offset (r14, -128) - lgr %r12,%r15 # backup stack pointer - cfi_def_cfa_register (12) - aghi %r15,-160 # create stack frame - stg %r12,0(%r15) # save backchain - lmg %r2,%r3,48(%r12) # load arguments saved by PLT - lgr %r4,%r14 # return address as third parameter - la %r5,64(%r12) # pointer to struct La_s390_32_regs - la %r6,40(%r12) # long int * framesize - brasl %r14,_dl_profile_fixup # call resolver - lgr %r1,%r2 # function addr returned in r2 - lg %r0,40(%r12) # load framesize - ltgr %r0,%r0 - jnm 1f - - lmg %r2,%r6,64(%r12) # framesize < 0 means no pltexit call - ld %f0,104(%r12) # so we can do a tail call without - ld %f2,112(%r12) # copying the arg overflow area - ld %f4,120(%r12) - ld %f6,128(%r12) - - lgr %r15,%r12 # remove stack frame - cfi_def_cfa_register (15) - lg %r14,32(%r15) # restore registers - lg %r12,24(%r15) - br %r1 # tail-call to resolved function - - cfi_def_cfa_register (12) -1: jz 4f # framesize == 0 ? - aghi %r0,7 # align framesize to 8 - nill %r0,0xfff8 - slgr %r15,%r0 # make room for framesize bytes - stg %r12,0(%r15) - la %r2,160(%r15) - la %r3,160(%r12) - srlg %r0,%r0,3 -3: mvc 0(8,%r2),0(%r3) # copy additional parameters - la %r2,8(%r2) - la %r3,8(%r3) - brctg %r0,3b -4: lmg %r2,%r6,64(%r12) # load register parameters - ld %f0,104(%r12) # restore call-clobbered arg regs - ld %f2,112(%r12) - ld %f4,120(%r12) - ld %f6,128(%r12) - basr %r14,%r1 # call resolved function - stg %r2,136(%r12) - std %f0,144(%r12) - lmg %r2,%r3,48(%r12) # load arguments saved by PLT - la %r4,32(%r12) # pointer to struct La_s390_32_regs - la %r5,72(%r12) # pointer to struct La_s390_32_retval - brasl %r14,_dl_call_pltexit - - lgr %r15,%r12 # remove stack frame - cfi_def_cfa_register (15) - lg %r14,32(%r15) # restore registers - lg %r12,24(%r15) - br %r14 - - cfi_endproc - .size _dl_runtime_profile, .-_dl_runtime_profile +/* Create variant of _dl_runtime_resolve/profile for machines before z13. + No vector registers are saved/restored. */ +#include <dl-trampoline.h> + +#if defined HAVE_S390_VX_ASM_SUPPORT +/* Create variant of _dl_runtime_resolve/profile for z13 and newer. + The vector registers are saved/restored, too.*/ +# define _dl_runtime_resolve _dl_runtime_resolve_vx +# define _dl_runtime_profile _dl_runtime_profile_vx +# define RESTORE_VRS +# include <dl-trampoline.h> #endif diff --git a/sysdeps/s390/s390-64/dl-trampoline.h b/sysdeps/s390/s390-64/dl-trampoline.h new file mode 100644 index 0000000000..d313fd521d --- /dev/null +++ b/sysdeps/s390/s390-64/dl-trampoline.h @@ -0,0 +1,224 @@ +/* PLT trampolines. s390x version. + Copyright (C) 2016-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/>. */ + +/* The PLT stubs will call _dl_runtime_resolve/_dl_runtime_profile + * with the following linkage: + * r2 - r6 : parameter registers + * f0, f2, f4, f6 : floating point parameter registers + * v24, v26, v28, v30, v25, v27, v29, v31 : vector parameter registers + * 48(r15), 56(r15) : PLT arguments PLT1, PLT2 + * 160(r15) : additional stack parameters + * The normal clobber rules for function calls apply: + * r0 - r5 : call clobbered + * r6 - r13 : call saved + * r14 : return address (call clobbered) + * r15 : stack pointer (call saved) + * f0 - f7 : call clobbered + * f8 - f15 : call saved + * v0 - v7 : bytes 0-7 overlap with f0-f7: call clobbered + bytes 8-15: call clobbered + * v8 - v15 : bytes 0-7 overlap with f8-f15: call saved + bytes 8-15: call clobbered + * v16 - v31 : call clobbered + */ + + .globl _dl_runtime_resolve + .type _dl_runtime_resolve, @function + cfi_startproc + .align 16 +_dl_runtime_resolve: + stmg %r2,%r5,64(%r15) # save call-clobbered argument registers + cfi_offset (r2, -96) + cfi_offset (r3, -88) + cfi_offset (r4, -80) + cfi_offset (r5, -72) + stmg %r14,%r15,96(%r15) + cfi_offset (r14, -64) + cfi_offset (r15, -56) + std %f0,112(%r15) + cfi_offset (f0, -48) + std %f2,120(%r15) + cfi_offset (f2, -40) + std %f4,128(%r15) + cfi_offset (f4, -32) + std %f6,136(%r15) + cfi_offset (f6, -24) + lmg %r2,%r3,48(%r15) # load args for fixup saved by PLT + lgr %r0,%r15 +#ifdef RESTORE_VRS + aghi %r15,-288 # create stack frame + cfi_adjust_cfa_offset (288) + .machine push + .machine "z13" + vstm %v24,%v31,160(%r15)# store call-clobbered vector argument registers + cfi_offset (v24, -288) + cfi_offset (v25, -272) + cfi_offset (v26, -256) + cfi_offset (v27, -240) + cfi_offset (v28, -224) + cfi_offset (v29, -208) + cfi_offset (v30, -192) + cfi_offset (v31, -176) + .machine pop +#else + aghi %r15,-160 # create stack frame + cfi_adjust_cfa_offset (160) +#endif + stg %r0,0(%r15) # write backchain + brasl %r14,_dl_fixup # call _dl_fixup + lgr %r1,%r2 # function addr returned in r2 +#ifdef RESTORE_VRS + .machine push + .machine "z13" + vlm %v24,%v31,160(%r15)# restore vector registers + .machine pop + lmg %r14,%r15,384(%r15)# remove stack frame and restore registers +#else + lmg %r14,%r15,256(%r15)# remove stack frame and restore registers +#endif + cfi_def_cfa_offset (160) + ld %f0,112(%r15) + ld %f2,120(%r15) + ld %f4,128(%r15) + ld %f6,136(%r15) + lmg %r2,%r5,64(%r15) + br %r1 + cfi_endproc + .size _dl_runtime_resolve, .-_dl_runtime_resolve + + +#ifndef PROF + .globl _dl_runtime_profile + .type _dl_runtime_profile, @function + cfi_startproc + .align 16 +_dl_runtime_profile: + stg %r12,24(%r15) # r12 is used as backup of r15 + cfi_offset (r12, -136) + stg %r14,32(%r15) + cfi_offset (r14, -128) + lgr %r12,%r15 # backup stack pointer + cfi_def_cfa_register (12) + aghi %r15,-360 # create stack frame: + # 160 + sizeof(La_s390_64_regs) + stg %r12,0(%r15) # save backchain + + stmg %r2,%r6,160(%r15) # save call-clobbered arg regs + cfi_offset (r2, -360) # + r6 needed as arg for + cfi_offset (r3, -352) # _dl_profile_fixup + cfi_offset (r4, -344) + cfi_offset (r5, -336) + cfi_offset (r6, -328) + std %f0,200(%r15) + cfi_offset (f0, -320) + std %f2,208(%r15) + cfi_offset (f2, -312) + std %f4,216(%r15) + cfi_offset (f4, -304) + std %f6,224(%r15) + cfi_offset (f6, -296) +#ifdef RESTORE_VRS + .machine push + .machine "z13" + vstm %v24,%v31,232(%r15) # store call-clobbered vector arguments + cfi_offset (v24, -288) + cfi_offset (v25, -272) + cfi_offset (v26, -256) + cfi_offset (v27, -240) + cfi_offset (v28, -224) + cfi_offset (v29, -208) + cfi_offset (v30, -192) + cfi_offset (v31, -176) + .machine pop +#endif + lmg %r2,%r3,48(%r12) # load arguments saved by PLT + lgr %r4,%r14 # return address as third parameter + la %r5,160(%r15) # pointer to struct La_s390_64_regs + la %r6,40(%r12) # long int * framesize + brasl %r14,_dl_profile_fixup # call resolver + lgr %r1,%r2 # function addr returned in r2 + ld %f0,200(%r15) # restore call-clobbered arg fprs + ld %f2,208(%r15) + ld %f4,216(%r15) + ld %f6,224(%r15) +#ifdef RESTORE_VRS + .machine push + .machine "z13" + vlm %v24,%v31,232(%r15) # restore call-clobbered arg vrs + .machine pop +#endif + lg %r0,40(%r12) # load framesize + ltgr %r0,%r0 + jnm 1f + + lmg %r2,%r6,160(%r15) # framesize < 0 means no pltexit call + # so we can do a tail call without + # copying the arg overflow area + lgr %r15,%r12 # remove stack frame + cfi_def_cfa_register (15) + lg %r14,32(%r15) # restore registers + lg %r12,24(%r15) + br %r1 # tail-call to resolved function + + cfi_def_cfa_register (12) +1: la %r4,160(%r15) # pointer to struct La_s390_64_regs + stg %r4,64(%r12) + jz 4f # framesize == 0 ? + aghi %r0,7 # align framesize to 8 + nill %r0,0xfff8 + slgr %r15,%r0 # make room for framesize bytes + stg %r12,0(%r15) # save backchain + la %r2,160(%r15) + la %r3,160(%r12) + srlg %r0,%r0,3 +3: mvc 0(8,%r2),0(%r3) # copy additional parameters + la %r2,8(%r2) # depending on framesize + la %r3,8(%r3) + brctg %r0,3b +4: lmg %r2,%r6,0(%r4) # restore call-clobbered arg gprs + basr %r14,%r1 # call resolved function + stg %r2,72(%r12) # store return values r2, f0 + std %f0,80(%r12) # to struct La_s390_64_retval +#ifdef RESTORE_VRS + .machine push + .machine "z13" + vst %v24,88(%r12) # store return value v24 + .machine pop +#endif + lmg %r2,%r4,48(%r12) # r2, r3: load arguments saved by PLT + # r4: pointer to struct La_s390_64_regs + la %r5,72(%r12) # pointer to struct La_s390_64_retval + brasl %r14,_dl_call_pltexit + + lgr %r15,%r12 # remove stack frame + cfi_def_cfa_register (15) + lg %r14,32(%r15) # restore registers + lg %r12,24(%r15) + lg %r2,72(%r15) # restore return values + ld %f0,80(%r15) +#ifdef RESTORE_VRS + .machine push + .machine "z13" + vl %v24,88(%r15) # restore return value v24 + .machine pop +#endif + br %r14 # Jump back to caller + + cfi_endproc + .size _dl_runtime_profile, .-_dl_runtime_profile +#endif diff --git a/sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c b/sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c deleted file mode 100644 index c59f87f18d..0000000000 --- a/sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c +++ /dev/null @@ -1,237 +0,0 @@ -/* Conversion between ISO 8859-1 and IBM037. - - This module uses the Z900 variant of the Translate One To One - instruction. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - - Author: Andreas Krebbel <Andreas.Krebbel@de.ibm.com> - Based on the work by Ulrich Drepper <drepper@cygnus.com>, 1997. - - Thanks to Daniel Appich who covered the relevant performance work - in his diploma thesis. - - This 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. - - This 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/>. */ - -#include <dlfcn.h> -#include <stdint.h> - -// conversion table from ISO-8859-1 to IBM037 -static const unsigned char table_iso8859_1_to_cp037[256] -__attribute__ ((aligned (8))) = -{ - [0x00] = 0x00, [0x01] = 0x01, [0x02] = 0x02, [0x03] = 0x03, - [0x04] = 0x37, [0x05] = 0x2D, [0x06] = 0x2E, [0x07] = 0x2F, - [0x08] = 0x16, [0x09] = 0x05, [0x0A] = 0x25, [0x0B] = 0x0B, - [0x0C] = 0x0C, [0x0D] = 0x0D, [0x0E] = 0x0E, [0x0F] = 0x0F, - [0x10] = 0x10, [0x11] = 0x11, [0x12] = 0x12, [0x13] = 0x13, - [0x14] = 0x3C, [0x15] = 0x3D, [0x16] = 0x32, [0x17] = 0x26, - [0x18] = 0x18, [0x19] = 0x19, [0x1A] = 0x3F, [0x1B] = 0x27, - [0x1C] = 0x1C, [0x1D] = 0x1D, [0x1E] = 0x1E, [0x1F] = 0x1F, - [0x20] = 0x40, [0x21] = 0x5A, [0x22] = 0x7F, [0x23] = 0x7B, - [0x24] = 0x5B, [0x25] = 0x6C, [0x26] = 0x50, [0x27] = 0x7D, - [0x28] = 0x4D, [0x29] = 0x5D, [0x2A] = 0x5C, [0x2B] = 0x4E, - [0x2C] = 0x6B, [0x2D] = 0x60, [0x2E] = 0x4B, [0x2F] = 0x61, - [0x30] = 0xF0, [0x31] = 0xF1, [0x32] = 0xF2, [0x33] = 0xF3, - [0x34] = 0xF4, [0x35] = 0xF5, [0x36] = 0xF6, [0x37] = 0xF7, - [0x38] = 0xF8, [0x39] = 0xF9, [0x3A] = 0x7A, [0x3B] = 0x5E, - [0x3C] = 0x4C, [0x3D] = 0x7E, [0x3E] = 0x6E, [0x3F] = 0x6F, - [0x40] = 0x7C, [0x41] = 0xC1, [0x42] = 0xC2, [0x43] = 0xC3, - [0x44] = 0xC4, [0x45] = 0xC5, [0x46] = 0xC6, [0x47] = 0xC7, - [0x48] = 0xC8, [0x49] = 0xC9, [0x4A] = 0xD1, [0x4B] = 0xD2, - [0x4C] = 0xD3, [0x4D] = 0xD4, [0x4E] = 0xD5, [0x4F] = 0xD6, - [0x50] = 0xD7, [0x51] = 0xD8, [0x52] = 0xD9, [0x53] = 0xE2, - [0x54] = 0xE3, [0x55] = 0xE4, [0x56] = 0xE5, [0x57] = 0xE6, - [0x58] = 0xE7, [0x59] = 0xE8, [0x5A] = 0xE9, [0x5B] = 0xBA, - [0x5C] = 0xE0, [0x5D] = 0xBB, [0x5E] = 0xB0, [0x5F] = 0x6D, - [0x60] = 0x79, [0x61] = 0x81, [0x62] = 0x82, [0x63] = 0x83, - [0x64] = 0x84, [0x65] = 0x85, [0x66] = 0x86, [0x67] = 0x87, - [0x68] = 0x88, [0x69] = 0x89, [0x6A] = 0x91, [0x6B] = 0x92, - [0x6C] = 0x93, [0x6D] = 0x94, [0x6E] = 0x95, [0x6F] = 0x96, - [0x70] = 0x97, [0x71] = 0x98, [0x72] = 0x99, [0x73] = 0xA2, - [0x74] = 0xA3, [0x75] = 0xA4, [0x76] = 0xA5, [0x77] = 0xA6, - [0x78] = 0xA7, [0x79] = 0xA8, [0x7A] = 0xA9, [0x7B] = 0xC0, - [0x7C] = 0x4F, [0x7D] = 0xD0, [0x7E] = 0xA1, [0x7F] = 0x07, - [0x80] = 0x20, [0x81] = 0x21, [0x82] = 0x22, [0x83] = 0x23, - [0x84] = 0x24, [0x85] = 0x15, [0x86] = 0x06, [0x87] = 0x17, - [0x88] = 0x28, [0x89] = 0x29, [0x8A] = 0x2A, [0x8B] = 0x2B, - [0x8C] = 0x2C, [0x8D] = 0x09, [0x8E] = 0x0A, [0x8F] = 0x1B, - [0x90] = 0x30, [0x91] = 0x31, [0x92] = 0x1A, [0x93] = 0x33, - [0x94] = 0x34, [0x95] = 0x35, [0x96] = 0x36, [0x97] = 0x08, - [0x98] = 0x38, [0x99] = 0x39, [0x9A] = 0x3A, [0x9B] = 0x3B, - [0x9C] = 0x04, [0x9D] = 0x14, [0x9E] = 0x3E, [0x9F] = 0xFF, - [0xA0] = 0x41, [0xA1] = 0xAA, [0xA2] = 0x4A, [0xA3] = 0xB1, - [0xA4] = 0x9F, [0xA5] = 0xB2, [0xA6] = 0x6A, [0xA7] = 0xB5, - [0xA8] = 0xBD, [0xA9] = 0xB4, [0xAA] = 0x9A, [0xAB] = 0x8A, - [0xAC] = 0x5F, [0xAD] = 0xCA, [0xAE] = 0xAF, [0xAF] = 0xBC, - [0xB0] = 0x90, [0xB1] = 0x8F, [0xB2] = 0xEA, [0xB3] = 0xFA, - [0xB4] = 0xBE, [0xB5] = 0xA0, [0xB6] = 0xB6, [0xB7] = 0xB3, - [0xB8] = 0x9D, [0xB9] = 0xDA, [0xBA] = 0x9B, [0xBB] = 0x8B, - [0xBC] = 0xB7, [0xBD] = 0xB8, [0xBE] = 0xB9, [0xBF] = 0xAB, - [0xC0] = 0x64, [0xC1] = 0x65, [0xC2] = 0x62, [0xC3] = 0x66, - [0xC4] = 0x63, [0xC5] = 0x67, [0xC6] = 0x9E, [0xC7] = 0x68, - [0xC8] = 0x74, [0xC9] = 0x71, [0xCA] = 0x72, [0xCB] = 0x73, - [0xCC] = 0x78, [0xCD] = 0x75, [0xCE] = 0x76, [0xCF] = 0x77, - [0xD0] = 0xAC, [0xD1] = 0x69, [0xD2] = 0xED, [0xD3] = 0xEE, - [0xD4] = 0xEB, [0xD5] = 0xEF, [0xD6] = 0xEC, [0xD7] = 0xBF, - [0xD8] = 0x80, [0xD9] = 0xFD, [0xDA] = 0xFE, [0xDB] = 0xFB, - [0xDC] = 0xFC, [0xDD] = 0xAD, [0xDE] = 0xAE, [0xDF] = 0x59, - [0xE0] = 0x44, [0xE1] = 0x45, [0xE2] = 0x42, [0xE3] = 0x46, - [0xE4] = 0x43, [0xE5] = 0x47, [0xE6] = 0x9C, [0xE7] = 0x48, - [0xE8] = 0x54, [0xE9] = 0x51, [0xEA] = 0x52, [0xEB] = 0x53, - [0xEC] = 0x58, [0xED] = 0x55, [0xEE] = 0x56, [0xEF] = 0x57, - [0xF0] = 0x8C, [0xF1] = 0x49, [0xF2] = 0xCD, [0xF3] = 0xCE, - [0xF4] = 0xCB, [0xF5] = 0xCF, [0xF6] = 0xCC, [0xF7] = 0xE1, - [0xF8] = 0x70, [0xF9] = 0xDD, [0xFA] = 0xDE, [0xFB] = 0xDB, - [0xFC] = 0xDC, [0xFD] = 0x8D, [0xFE] = 0x8E, [0xFF] = 0xDF -}; - -// conversion table from IBM037 to ISO-8859-1 -static const unsigned char table_cp037_iso8859_1[256] -__attribute__ ((aligned (8))) = -{ - [0x00] = 0x00, [0x01] = 0x01, [0x02] = 0x02, [0x03] = 0x03, - [0x04] = 0x9C, [0x05] = 0x09, [0x06] = 0x86, [0x07] = 0x7F, - [0x08] = 0x97, [0x09] = 0x8D, [0x0A] = 0x8E, [0x0B] = 0x0B, - [0x0C] = 0x0C, [0x0D] = 0x0D, [0x0E] = 0x0E, [0x0F] = 0x0F, - [0x10] = 0x10, [0x11] = 0x11, [0x12] = 0x12, [0x13] = 0x13, - [0x14] = 0x9D, [0x15] = 0x85, [0x16] = 0x08, [0x17] = 0x87, - [0x18] = 0x18, [0x19] = 0x19, [0x1A] = 0x92, [0x1B] = 0x8F, - [0x1C] = 0x1C, [0x1D] = 0x1D, [0x1E] = 0x1E, [0x1F] = 0x1F, - [0x20] = 0x80, [0x21] = 0x81, [0x22] = 0x82, [0x23] = 0x83, - [0x24] = 0x84, [0x25] = 0x0A, [0x26] = 0x17, [0x27] = 0x1B, - [0x28] = 0x88, [0x29] = 0x89, [0x2A] = 0x8A, [0x2B] = 0x8B, - [0x2C] = 0x8C, [0x2D] = 0x05, [0x2E] = 0x06, [0x2F] = 0x07, - [0x30] = 0x90, [0x31] = 0x91, [0x32] = 0x16, [0x33] = 0x93, - [0x34] = 0x94, [0x35] = 0x95, [0x36] = 0x96, [0x37] = 0x04, - [0x38] = 0x98, [0x39] = 0x99, [0x3A] = 0x9A, [0x3B] = 0x9B, - [0x3C] = 0x14, [0x3D] = 0x15, [0x3E] = 0x9E, [0x3F] = 0x1A, - [0x40] = 0x20, [0x41] = 0xA0, [0x42] = 0xE2, [0x43] = 0xE4, - [0x44] = 0xE0, [0x45] = 0xE1, [0x46] = 0xE3, [0x47] = 0xE5, - [0x48] = 0xE7, [0x49] = 0xF1, [0x4A] = 0xA2, [0x4B] = 0x2E, - [0x4C] = 0x3C, [0x4D] = 0x28, [0x4E] = 0x2B, [0x4F] = 0x7C, - [0x50] = 0x26, [0x51] = 0xE9, [0x52] = 0xEA, [0x53] = 0xEB, - [0x54] = 0xE8, [0x55] = 0xED, [0x56] = 0xEE, [0x57] = 0xEF, - [0x58] = 0xEC, [0x59] = 0xDF, [0x5A] = 0x21, [0x5B] = 0x24, - [0x5C] = 0x2A, [0x5D] = 0x29, [0x5E] = 0x3B, [0x5F] = 0xAC, - [0x60] = 0x2D, [0x61] = 0x2F, [0x62] = 0xC2, [0x63] = 0xC4, - [0x64] = 0xC0, [0x65] = 0xC1, [0x66] = 0xC3, [0x67] = 0xC5, - [0x68] = 0xC7, [0x69] = 0xD1, [0x6A] = 0xA6, [0x6B] = 0x2C, - [0x6C] = 0x25, [0x6D] = 0x5F, [0x6E] = 0x3E, [0x6F] = 0x3F, - [0x70] = 0xF8, [0x71] = 0xC9, [0x72] = 0xCA, [0x73] = 0xCB, - [0x74] = 0xC8, [0x75] = 0xCD, [0x76] = 0xCE, [0x77] = 0xCF, - [0x78] = 0xCC, [0x79] = 0x60, [0x7A] = 0x3A, [0x7B] = 0x23, - [0x7C] = 0x40, [0x7D] = 0x27, [0x7E] = 0x3D, [0x7F] = 0x22, - [0x80] = 0xD8, [0x81] = 0x61, [0x82] = 0x62, [0x83] = 0x63, - [0x84] = 0x64, [0x85] = 0x65, [0x86] = 0x66, [0x87] = 0x67, - [0x88] = 0x68, [0x89] = 0x69, [0x8A] = 0xAB, [0x8B] = 0xBB, - [0x8C] = 0xF0, [0x8D] = 0xFD, [0x8E] = 0xFE, [0x8F] = 0xB1, - [0x90] = 0xB0, [0x91] = 0x6A, [0x92] = 0x6B, [0x93] = 0x6C, - [0x94] = 0x6D, [0x95] = 0x6E, [0x96] = 0x6F, [0x97] = 0x70, - [0x98] = 0x71, [0x99] = 0x72, [0x9A] = 0xAA, [0x9B] = 0xBA, - [0x9C] = 0xE6, [0x9D] = 0xB8, [0x9E] = 0xC6, [0x9F] = 0xA4, - [0xA0] = 0xB5, [0xA1] = 0x7E, [0xA2] = 0x73, [0xA3] = 0x74, - [0xA4] = 0x75, [0xA5] = 0x76, [0xA6] = 0x77, [0xA7] = 0x78, - [0xA8] = 0x79, [0xA9] = 0x7A, [0xAA] = 0xA1, [0xAB] = 0xBF, - [0xAC] = 0xD0, [0xAD] = 0xDD, [0xAE] = 0xDE, [0xAF] = 0xAE, - [0xB0] = 0x5E, [0xB1] = 0xA3, [0xB2] = 0xA5, [0xB3] = 0xB7, - [0xB4] = 0xA9, [0xB5] = 0xA7, [0xB6] = 0xB6, [0xB7] = 0xBC, - [0xB8] = 0xBD, [0xB9] = 0xBE, [0xBA] = 0x5B, [0xBB] = 0x5D, - [0xBC] = 0xAF, [0xBD] = 0xA8, [0xBE] = 0xB4, [0xBF] = 0xD7, - [0xC0] = 0x7B, [0xC1] = 0x41, [0xC2] = 0x42, [0xC3] = 0x43, - [0xC4] = 0x44, [0xC5] = 0x45, [0xC6] = 0x46, [0xC7] = 0x47, - [0xC8] = 0x48, [0xC9] = 0x49, [0xCA] = 0xAD, [0xCB] = 0xF4, - [0xCC] = 0xF6, [0xCD] = 0xF2, [0xCE] = 0xF3, [0xCF] = 0xF5, - [0xD0] = 0x7D, [0xD1] = 0x4A, [0xD2] = 0x4B, [0xD3] = 0x4C, - [0xD4] = 0x4D, [0xD5] = 0x4E, [0xD6] = 0x4F, [0xD7] = 0x50, - [0xD8] = 0x51, [0xD9] = 0x52, [0xDA] = 0xB9, [0xDB] = 0xFB, - [0xDC] = 0xFC, [0xDD] = 0xF9, [0xDE] = 0xFA, [0xDF] = 0xFF, - [0xE0] = 0x5C, [0xE1] = 0xF7, [0xE2] = 0x53, [0xE3] = 0x54, - [0xE4] = 0x55, [0xE5] = 0x56, [0xE6] = 0x57, [0xE7] = 0x58, - [0xE8] = 0x59, [0xE9] = 0x5A, [0xEA] = 0xB2, [0xEB] = 0xD4, - [0xEC] = 0xD6, [0xED] = 0xD2, [0xEE] = 0xD3, [0xEF] = 0xD5, - [0xF0] = 0x30, [0xF1] = 0x31, [0xF2] = 0x32, [0xF3] = 0x33, - [0xF4] = 0x34, [0xF5] = 0x35, [0xF6] = 0x36, [0xF7] = 0x37, - [0xF8] = 0x38, [0xF9] = 0x39, [0xFA] = 0xB3, [0xFB] = 0xDB, - [0xFC] = 0xDC, [0xFD] = 0xD9, [0xFE] = 0xDA, [0xFF] = 0x9F -}; - -/* Definitions used in the body of the `gconv' function. */ -#define CHARSET_NAME "ISO-8859-1//" -#define FROM_LOOP iso8859_1_to_cp037_z900 -#define TO_LOOP cp037_to_iso8859_1_z900 -#define DEFINE_INIT 1 -#define DEFINE_FINI 1 -#define MIN_NEEDED_FROM 1 -#define MIN_NEEDED_TO 1 - -/* The Z900 variant of troo forces us to always specify a test - character which ends the translation. So if we run into the - situation where the translation has been interrupted due to the - test character we translate the character by hand and jump back - into the instruction. */ - -#define TROO_LOOP(TABLE) \ - { \ - register const unsigned char test __asm__ ("0") = 0; \ - register const unsigned char *pTable __asm__ ("1") = TABLE; \ - register unsigned char *pOutput __asm__ ("2") = outptr; \ - register uint64_t length __asm__ ("3"); \ - const unsigned char* pInput = inptr; \ - uint64_t tmp; \ - \ - length = (inend - inptr < outend - outptr \ - ? inend - inptr : outend - outptr); \ - \ - __asm__ volatile ("0: \n\t" \ - " troo %0,%1 \n\t" \ - " jz 1f \n\t" \ - " jo 0b \n\t" \ - " llgc %3,0(%1) \n\t" \ - " la %3,0(%3,%4) \n\t" \ - " mvc 0(1,%0),0(%3) \n\t" \ - " aghi %1,1 \n\t" \ - " aghi %0,1 \n\t" \ - " aghi %2,-1 \n\t" \ - " j 0b \n\t" \ - "1: \n" \ - \ - : "+a" (pOutput), "+a" (pInput), "+d" (length), "=&a" (tmp) \ - : "a" (pTable), "d" (test) \ - : "cc"); \ - \ - inptr = pInput; \ - outptr = pOutput; \ - } - -/* First define the conversion function from ISO 8859-1 to CP037. */ -#define MIN_NEEDED_INPUT MIN_NEEDED_FROM -#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO -#define LOOPFCT FROM_LOOP -#define BODY TROO_LOOP (table_iso8859_1_to_cp037) - -#include <iconv/loop.c> - - -/* Next, define the conversion function from CP037 to ISO 8859-1. */ -#define MIN_NEEDED_INPUT MIN_NEEDED_TO -#define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM -#define LOOPFCT TO_LOOP -#define BODY TROO_LOOP (table_cp037_iso8859_1); - -#include <iconv/loop.c> - - -/* Now define the toplevel functions. */ -#include <iconv/skeleton.c> diff --git a/sysdeps/s390/s390-64/memchr.S b/sysdeps/s390/s390-64/memchr.S index 8d50dcfe86..a19fcafa14 100644 --- a/sysdeps/s390/s390-64/memchr.S +++ b/sysdeps/s390/s390-64/memchr.S @@ -1,5 +1,5 @@ /* Search a character in a block of memory. 64 bit S/390 version. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. diff --git a/sysdeps/s390/s390-64/memcmp.S b/sysdeps/s390/s390-64/memcmp.S index 5e79d544bf..005b19de45 100644 --- a/sysdeps/s390/s390-64/memcmp.S +++ b/sysdeps/s390/s390-64/memcmp.S @@ -1,5 +1,5 @@ /* memcmp - compare two memory blocks. 64 bit S/390 version. - Copyright (C) 2012-2016 Free Software Foundation, Inc. + Copyright (C) 2012-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 diff --git a/sysdeps/s390/s390-64/memcpy.S b/sysdeps/s390/s390-64/memcpy.S index e84a3572cb..2e5490df23 100644 --- a/sysdeps/s390/s390-64/memcpy.S +++ b/sysdeps/s390/s390-64/memcpy.S @@ -1,5 +1,5 @@ /* memcpy - copy a block from source to destination. 64 bit S/390 version. - Copyright (C) 2012-2016 Free Software Foundation, Inc. + Copyright (C) 2012-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 @@ -27,19 +27,27 @@ .text +ENTRY(__mempcpy) + .machine "z900" + lgr %r1,%r2 # Use as dest + la %r2,0(%r4,%r2) # Return dest + n + j .L_Z900_start +END(__mempcpy) +#ifndef USE_MULTIARCH +libc_hidden_def (__mempcpy) +weak_alias (__mempcpy, mempcpy) +libc_hidden_builtin_def (mempcpy) +#endif -#ifdef USE_MULTIARCH -ENTRY(__memcpy_default) -#else ENTRY(memcpy) -#endif .machine "z900" + lgr %r1,%r2 # r1: Use as dest ; r2: Return dest +.L_Z900_start: ltgr %r4,%r4 je .L_Z900_4 aghi %r4,-1 srlg %r5,%r4,8 ltgr %r5,%r5 - lgr %r1,%r2 jne .L_Z900_13 .L_Z900_3: larl %r5,.L_Z900_15 @@ -47,7 +55,7 @@ ENTRY(memcpy) .L_Z900_4: br %r14 .L_Z900_13: - chi %r5,4096 # Switch to mvcle for copies >1MB + cghi %r5,4096 # Switch to mvcle for copies >1MB jh __memcpy_mvcle .L_Z900_12: mvc 0(256,%r1),0(%r3) @@ -57,25 +65,24 @@ ENTRY(memcpy) j .L_Z900_3 .L_Z900_15: mvc 0(1,%r1),0(%r3) - -#ifdef USE_MULTIARCH -END(__memcpy_default) -#else END(memcpy) +#ifndef USE_MULTIARCH libc_hidden_builtin_def (memcpy) #endif ENTRY(__memcpy_mvcle) - # Using as standalone function will result in unexpected - # results since the length field is incremented by 1 in order to - # compensate the changes already done in the functions above. - aghi %r4,1 # length + 1 - lgr %r5,%r4 # source length - lgr %r4,%r3 # source address - lgr %r3,%r5 # destination length = source length + # Using as standalone function will result in unexpected + # results since the length field is incremented by 1 in order to + # compensate the changes already done in the functions above. + lgr %r0,%r2 # backup return dest [ + n ] + aghi %r4,1 # length + 1 + lgr %r5,%r4 # source length + lgr %r4,%r3 # source address + lgr %r2,%r1 # destination address + lgr %r3,%r5 # destination length = source length .L_MVCLE_1: - mvcle %r2,%r4,0 # thats it, MVCLE is your friend - jo .L_MVCLE_1 - lgr %r2,%r1 # return destination address - br %r14 + mvcle %r2,%r4,0 # thats it, MVCLE is your friend + jo .L_MVCLE_1 + lgr %r2,%r0 # return destination address + br %r14 END(__memcpy_mvcle) diff --git a/sysdeps/s390/s390-64/memset.S b/sysdeps/s390/s390-64/memset.S index cab7855549..8799c6592c 100644 --- a/sysdeps/s390/s390-64/memset.S +++ b/sysdeps/s390/s390-64/memset.S @@ -1,5 +1,5 @@ /* Set a block of memory to some byte value. 64 bit S/390 version. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. diff --git a/sysdeps/s390/s390-64/multiarch/memchr.c b/sysdeps/s390/s390-64/multiarch/memchr.c index 2281e43056..5e1610afa4 100644 --- a/sysdeps/s390/s390-64/multiarch/memchr.c +++ b/sysdeps/s390/s390-64/multiarch/memchr.c @@ -1,5 +1,5 @@ /* Multiple versions of memchr. - Copyright (C) 2015-2016 Free Software Foundation, Inc. + 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 diff --git a/sysdeps/s390/s390-64/multiarch/memcmp-s390x.S b/sysdeps/s390/s390-64/multiarch/memcmp-s390x.S index 2a4c0ae9a6..35f9bf9cf7 100644 --- a/sysdeps/s390/s390-64/multiarch/memcmp-s390x.S +++ b/sysdeps/s390/s390-64/multiarch/memcmp-s390x.S @@ -1,5 +1,5 @@ /* CPU specific memcmp implementations. 64 bit S/390 version. - Copyright (C) 2012-2016 Free Software Foundation, Inc. + Copyright (C) 2012-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 @@ -98,4 +98,7 @@ END(__memcmp_z10) .set memcmp,__memcmp_default .weak bcmp .set bcmp,__memcmp_default +#elif defined SHARED && IS_IN (libc) +.globl __GI_memcmp +.set __GI_memcmp,__memcmp_default #endif diff --git a/sysdeps/s390/s390-64/multiarch/memcmp.c b/sysdeps/s390/s390-64/multiarch/memcmp.c index 44f72dc8ca..1e6f31806e 100644 --- a/sysdeps/s390/s390-64/multiarch/memcmp.c +++ b/sysdeps/s390/s390-64/multiarch/memcmp.c @@ -1,5 +1,5 @@ /* Multiple versions of memcmp. - Copyright (C) 2015-2016 Free Software Foundation, Inc. + 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 @@ -17,8 +17,11 @@ <http://www.gnu.org/licenses/>. */ #if IS_IN (libc) +# define memcmp __redirect_memcmp +# include <string.h> +# undef memcmp # include <ifunc-resolve.h> -s390_libc_ifunc (memcmp) -__asm__(".weak bcmp ; bcmp = memcmp"); +s390_libc_ifunc (__redirect_memcmp, __memcmp, memcmp) +weak_alias (memcmp, bcmp); #endif diff --git a/sysdeps/s390/s390-64/multiarch/memcpy-s390x.S b/sysdeps/s390/s390-64/multiarch/memcpy-s390x.S index 69fa562060..6d60a70834 100644 --- a/sysdeps/s390/s390-64/multiarch/memcpy-s390x.S +++ b/sysdeps/s390/s390-64/multiarch/memcpy-s390x.S @@ -1,5 +1,5 @@ /* CPU specific memcpy implementations. 64 bit S/390 version. - Copyright (C) 2012-2016 Free Software Foundation, Inc. + Copyright (C) 2012-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 @@ -29,12 +29,20 @@ #if defined SHARED && IS_IN (libc) +ENTRY(____mempcpy_z196) + .machine "z196" + lgr %r1,%r2 # Use as dest + la %r2,0(%r4,%r2) # Return dest + n + j .L_Z196_start +END(____mempcpy_z196) + ENTRY(__memcpy_z196) .machine "z196" + lgr %r1,%r2 # r1: Use as dest ; r2: Return dest +.L_Z196_start: ltgr %r4,%r4 je .L_Z196_4 aghi %r4,-1 - lgr %r1,%r2 srlg %r5,%r4,8 ltgr %r5,%r5 jne .L_Z196_5 @@ -58,11 +66,19 @@ ENTRY(__memcpy_z196) mvc 0(1,%r1),0(%r3) END(__memcpy_z196) +ENTRY(____mempcpy_z10) + .machine "z10" + lgr %r1,%r2 # Use as dest + la %r2,0(%r4,%r2) # Return dest + n + j .L_Z10_start +END(____mempcpy_z10) + ENTRY(__memcpy_z10) .machine "z10" + lgr %r1,%r2 # r1: Use as dest ; r2: Return dest +.L_Z10_start: cgije %r4,0,.L_Z10_4 aghi %r4,-1 - lgr %r1,%r2 srlg %r5,%r4,8 cgijlh %r5,0,.L_Z10_13 .L_Z10_3: @@ -84,11 +100,23 @@ ENTRY(__memcpy_z10) mvc 0(1,%r1),0(%r3) END(__memcpy_z10) +# define __mempcpy ____mempcpy_default #endif /* SHARED && IS_IN (libc) */ +#define memcpy __memcpy_default #include "../memcpy.S" +#undef memcpy -#if !defined SHARED || !IS_IN (libc) +#if defined SHARED && IS_IN (libc) +.globl __GI_memcpy +.set __GI_memcpy,__memcpy_default +.globl __GI_mempcpy +.set __GI_mempcpy,____mempcpy_default +.globl __GI___mempcpy +.set __GI___mempcpy,____mempcpy_default +#else .globl memcpy .set memcpy,__memcpy_default +.weak mempcpy +.set mempcpy,__mempcpy #endif diff --git a/sysdeps/s390/s390-64/multiarch/memcpy.c b/sysdeps/s390/s390-64/multiarch/memcpy.c index 2a98aa0b82..c9577a854a 100644 --- a/sysdeps/s390/s390-64/multiarch/memcpy.c +++ b/sysdeps/s390/s390-64/multiarch/memcpy.c @@ -1,5 +1,5 @@ /* Multiple versions of memcpy. - Copyright (C) 2015-2016 Free Software Foundation, Inc. + 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 @@ -18,7 +18,10 @@ /* In the static lib memcpy is needed before the reloc is resolved. */ #if defined SHARED && IS_IN (libc) +# define memcpy __redirect_memcpy +# include <string.h> +# undef memcpy # include <ifunc-resolve.h> -s390_libc_ifunc (memcpy) +s390_libc_ifunc (__redirect_memcpy, __memcpy, memcpy) #endif diff --git a/sysdeps/s390/s390-64/multiarch/memset-s390x.S b/sysdeps/s390/s390-64/multiarch/memset-s390x.S index 05e068279d..0c5aaef34f 100644 --- a/sysdeps/s390/s390-64/multiarch/memset-s390x.S +++ b/sysdeps/s390/s390-64/multiarch/memset-s390x.S @@ -1,5 +1,5 @@ /* Set a block of memory to some byte value. 64 bit S/390 version. - Copyright (C) 2012-2016 Free Software Foundation, Inc. + Copyright (C) 2012-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 @@ -106,4 +106,7 @@ END(__memset_mvcle) #if !IS_IN (libc) .globl memset .set memset,__memset_default +#elif defined SHARED && IS_IN (libc) +.globl __GI_memset +.set __GI_memset,__memset_default #endif diff --git a/sysdeps/s390/s390-64/multiarch/memset.c b/sysdeps/s390/s390-64/multiarch/memset.c index 89b8102f2a..760b3e9df2 100644 --- a/sysdeps/s390/s390-64/multiarch/memset.c +++ b/sysdeps/s390/s390-64/multiarch/memset.c @@ -1,5 +1,5 @@ /* Multiple versions of memset. - Copyright (C) 2015-2016 Free Software Foundation, Inc. + 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 @@ -17,7 +17,10 @@ <http://www.gnu.org/licenses/>. */ #if IS_IN (libc) +# define memset __redirect_memset +# include <string.h> +# undef memset # include <ifunc-resolve.h> -s390_libc_ifunc (memset) +s390_libc_ifunc (__redirect_memset, __memset, memset) #endif diff --git a/sysdeps/s390/s390-64/multiarch/strcmp.c b/sysdeps/s390/s390-64/multiarch/strcmp.c index b7eebc017f..d06b0f3436 100644 --- a/sysdeps/s390/s390-64/multiarch/strcmp.c +++ b/sysdeps/s390/s390-64/multiarch/strcmp.c @@ -1,5 +1,5 @@ /* Multiple versions of strcmp. - Copyright (C) 2015-2016 Free Software Foundation, Inc. + 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 diff --git a/sysdeps/s390/s390-64/multiarch/strcpy.c b/sysdeps/s390/s390-64/multiarch/strcpy.c index ae140d22b7..6a22e31a03 100644 --- a/sysdeps/s390/s390-64/multiarch/strcpy.c +++ b/sysdeps/s390/s390-64/multiarch/strcpy.c @@ -1,5 +1,5 @@ /* Multiple versions of strcpy. - Copyright (C) 2015-2016 Free Software Foundation, Inc. + 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 diff --git a/sysdeps/s390/s390-64/multiarch/strncpy.c b/sysdeps/s390/s390-64/multiarch/strncpy.c index 28a2af72e4..57f9df18d1 100644 --- a/sysdeps/s390/s390-64/multiarch/strncpy.c +++ b/sysdeps/s390/s390-64/multiarch/strncpy.c @@ -1,5 +1,5 @@ /* Multiple versions of strncpy. - Copyright (C) 2015-2016 Free Software Foundation, Inc. + 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 diff --git a/sysdeps/s390/s390-64/s390x-mcount.S b/sysdeps/s390/s390-64/s390x-mcount.S index cb67ddb7ff..c6b5d65e17 100644 --- a/sysdeps/s390/s390-64/s390x-mcount.S +++ b/sysdeps/s390/s390-64/s390x-mcount.S @@ -1,5 +1,5 @@ -/* 64 bit S/390-specific implemetation of profiling support. - Copyright (C) 2001-2016 Free Software Foundation, Inc. +/* 64 bit S/390-specific implementation of profiling support. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com) This file is part of the GNU C Library. diff --git a/sysdeps/s390/s390-64/setjmp.S b/sysdeps/s390/s390-64/setjmp.S index bbcb70db5f..f512589fb9 100644 --- a/sysdeps/s390/s390-64/setjmp.S +++ b/sysdeps/s390/s390-64/setjmp.S @@ -1,5 +1,5 @@ /* setjmp for 64 bit S/390, ELF version. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -24,17 +24,16 @@ #include <shlib-compat.h> #include <stap-probe.h> -#if !IS_IN (rtld) -# if defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_19, GLIBC_2_20) - /* we need a unique name in case of symbol versioning. */ -# define setjmp __v1setjmp -# define _setjmp __v1_setjmp -# define __sigsetjmp __v1__sigsetjmp - -# undef libc_hidden_def -# define libc_hidden_def(name) strong_alias(_setjmp, __GI__setjmp) -# endif /* if defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_19, GLIBC_2_20) */ -#endif /* !IS_IN (rtld) */ +#if !IS_IN (rtld) && defined SHARED \ + && SHLIB_COMPAT (libc, GLIBC_2_19, GLIBC_2_20) +# define NEED_COMPAT_SYMBOLS 1 +/* We need a unique name in case of symbol versioning. */ +# define setjmp __v1setjmp +# define _setjmp __v1_setjmp +# define __sigsetjmp __v1__sigsetjmp +#else +# define NEED_COMPAT_SYMBOLS 0 +#endif /* We include the BSD entry points here as well. */ ENTRY (setjmp) @@ -47,7 +46,11 @@ ENTRY(_setjmp) slgr %r3,%r3 /* Second argument of zero. */ j .Linternal_sigsetjmp /* Branch relativ to __sigsetjmp. */ END (_setjmp) +#if NEED_COMPAT_SYMBOLS +strong_alias (_setjmp, __GI__setjmp) +#else libc_hidden_def (_setjmp) +#endif ENTRY(__setjmp) slgr %r3,%r3 /* Second argument of zero. */ @@ -87,15 +90,19 @@ ENTRY(__sigsetjmp) jg __sigjmp_save #endif END (__sigsetjmp) +#if NEED_COMPAT_SYMBOLS +strong_alias (__sigsetjmp, __GI___sigsetjmp) +#else +libc_hidden_def (__sigsetjmp) +#endif -#if !IS_IN (rtld) -# if defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_19, GLIBC_2_20) +#if NEED_COMPAT_SYMBOLS /* In glibc release 2.19 new versions of setjmp-functions were introduced, but were reverted before 2.20. Thus both versions are the same function. */ -# undef setjmp -# undef _setjmp -# undef __sigsetjmp +# undef setjmp +# undef _setjmp +# undef __sigsetjmp strong_alias (__v1setjmp, __v2setjmp); versioned_symbol (libc, __v1setjmp, setjmp, GLIBC_2_0); @@ -108,5 +115,4 @@ compat_symbol (libc, __v2_setjmp, _setjmp, GLIBC_2_19); strong_alias (__v1__sigsetjmp, __v2__sigsetjmp); versioned_symbol (libc, __v1__sigsetjmp, __sigsetjmp, GLIBC_2_0); compat_symbol (libc, __v2__sigsetjmp, __sigsetjmp, GLIBC_2_19); -# endif /* if defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_19, GLIBC_2_20) */ -#endif /* if !IS_IN (rtld) */ +#endif /* NEED_COMPAT_SYMBOLS */ diff --git a/sysdeps/s390/s390-64/start.S b/sysdeps/s390/s390-64/start.S index e261460dd5..79e7b69f1d 100644 --- a/sysdeps/s390/s390-64/start.S +++ b/sysdeps/s390/s390-64/start.S @@ -1,5 +1,5 @@ /* Startup code compliant to the 64 bit S/390 ELF ABI. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -34,6 +34,8 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#include <sysdep.h> + /* This is the canonical entry point, usually the first thing in the text segment. Most registers' values are unspecified, except for: @@ -57,6 +59,9 @@ .globl _start .type _start,@function _start: + cfi_startproc + /* Mark r14 as undefined in order to stop unwinding here! */ + cfi_undefined (r14) /* Load argc and argv from stack. */ la %r4,8(%r15) # get argv lg %r3,0(%r15) # get argc @@ -91,6 +96,8 @@ _start: /* Crash if __libc_start_main returns. */ .word 0 + cfi_endproc + /* Define a symbol for the first piece of initialized data. */ .data .globl __data_start diff --git a/sysdeps/s390/s390-64/strcmp.S b/sysdeps/s390/s390-64/strcmp.S index 245b54cc9d..6cf1addd8b 100644 --- a/sysdeps/s390/s390-64/strcmp.S +++ b/sysdeps/s390/s390-64/strcmp.S @@ -1,6 +1,6 @@ /* strcmp - compare two string. 64 bit S/390 version. This file is part of the GNU C Library. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). The GNU C Library is free software; you can redistribute it and/or diff --git a/sysdeps/s390/s390-64/strcpy.S b/sysdeps/s390/s390-64/strcpy.S index 9864e98b24..203c73c905 100644 --- a/sysdeps/s390/s390-64/strcpy.S +++ b/sysdeps/s390/s390-64/strcpy.S @@ -1,5 +1,5 @@ /* strcpy - copy a string from source to destination. 64 bit S/390 version. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. diff --git a/sysdeps/s390/s390-64/strncpy.S b/sysdeps/s390/s390-64/strncpy.S index 56c8a526ae..be40aa32d5 100644 --- a/sysdeps/s390/s390-64/strncpy.S +++ b/sysdeps/s390/s390-64/strncpy.S @@ -1,6 +1,6 @@ /* strncpy - copy at most n characters from a string from source to destination. 64 bit S/390 version - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. diff --git a/sysdeps/s390/s390-64/sub_n.S b/sysdeps/s390/s390-64/sub_n.S index 7318836db9..ad5c7fc9ca 100644 --- a/sysdeps/s390/s390-64/sub_n.S +++ b/sysdeps/s390/s390-64/sub_n.S @@ -1,6 +1,6 @@ /* __mpn_sub_n -- Add two limb vectors of the same length > 0 and store sum in a third limb vector. 64 bit S/390 version. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU MP Library. diff --git a/sysdeps/s390/s390-64/sysdep.h b/sysdeps/s390/s390-64/sysdep.h index 7fac89da51..a573e08e92 100644 --- a/sysdeps/s390/s390-64/sysdep.h +++ b/sysdeps/s390/s390-64/sysdep.h @@ -1,5 +1,5 @@ /* Assembler macros for 64 bit S/390. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -77,7 +77,7 @@ lose: SYSCALL_PIC_SETUP \ END (name) #undef JUMPTARGET -#ifdef PIC +#ifdef SHARED #define JUMPTARGET(name) name##@PLT #define SYSCALL_PIC_SETUP \ larl %r12,_GLOBAL_OFFSET_TABLE_ diff --git a/sysdeps/s390/s390-64/tls-macros.h b/sysdeps/s390/s390-64/tls-macros.h index d70ea6ce0c..449a843d69 100644 --- a/sysdeps/s390/s390-64/tls-macros.h +++ b/sysdeps/s390/s390-64/tls-macros.h @@ -8,13 +8,15 @@ #ifdef PIC # define TLS_IE(x) \ - ({ unsigned long __offset, __got; \ + ({ unsigned long __offset, __save12; \ __asm__ ("bras %0,0f\n\t" \ ".quad " #x "@gotntpoff\n" \ - "0:\tlarl %1,_GLOBAL_OFFSET_TABLE_\n\t" \ + "0:\tlgr %1,%%r12\n\t" \ + "larl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \ "lg %0,0(%0)\n\t" \ - "lg %0,0(%0,%1):tls_load:" #x "\n" \ - : "=&a" (__offset), "=&a" (__got) : : "cc" ); \ + "lg %0,0(%0,%%r12):tls_load:" #x "\n\t" \ + "lgr %%r12,%1\n" \ + : "=&a" (__offset), "=&a" (__save12) : : "cc" ); \ (int *) (__builtin_thread_pointer() + __offset); }) #else # define TLS_IE(x) \ diff --git a/sysdeps/s390/s390-64/tst-audit.h b/sysdeps/s390/s390-64/tst-audit.h index 3283e95037..954373e24f 100644 --- a/sysdeps/s390/s390-64/tst-audit.h +++ b/sysdeps/s390/s390-64/tst-audit.h @@ -1,6 +1,6 @@ /* Definitions for testing PLT entry/exit auditing. S/390 64-bit version. - Copyright (C) 2012-2016 Free Software Foundation, Inc. + Copyright (C) 2012-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/sysdeps/s390/s390-64/utf16-utf32-z9.c b/sysdeps/s390/s390-64/utf16-utf32-z9.c deleted file mode 100644 index a3863ee244..0000000000 --- a/sysdeps/s390/s390-64/utf16-utf32-z9.c +++ /dev/null @@ -1,337 +0,0 @@ -/* Conversion between UTF-16 and UTF-32 BE/internal. - - This module uses the Z9-109 variants of the Convert Unicode - instructions. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - - Author: Andreas Krebbel <Andreas.Krebbel@de.ibm.com> - Based on the work by Ulrich Drepper <drepper@cygnus.com>, 1997. - - Thanks to Daniel Appich who covered the relevant performance work - in his diploma thesis. - - This 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. - - This 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/>. */ - -#include <dlfcn.h> -#include <stdint.h> -#include <unistd.h> -#include <dl-procinfo.h> -#include <gconv.h> - -/* UTF-32 big endian byte order mark. */ -#define BOM_UTF32 0x0000feffu - -/* UTF-16 big endian byte order mark. */ -#define BOM_UTF16 0xfeff - -#define DEFINE_INIT 0 -#define DEFINE_FINI 0 -#define MIN_NEEDED_FROM 2 -#define MAX_NEEDED_FROM 4 -#define MIN_NEEDED_TO 4 -#define FROM_LOOP from_utf16_loop -#define TO_LOOP to_utf16_loop -#define FROM_DIRECTION (dir == from_utf16) -#define ONE_DIRECTION 0 -#define PREPARE_LOOP \ - enum direction dir = ((struct utf16_data *) step->__data)->dir; \ - int emit_bom = ((struct utf16_data *) step->__data)->emit_bom; \ - \ - if (emit_bom && !data->__internal_use \ - && data->__invocation_counter == 0) \ - { \ - if (dir == to_utf16) \ - { \ - /* Emit the UTF-16 Byte Order Mark. */ \ - if (__glibc_unlikely (outbuf + 2 > outend)) \ - return __GCONV_FULL_OUTPUT; \ - \ - put16u (outbuf, BOM_UTF16); \ - outbuf += 2; \ - } \ - else \ - { \ - /* Emit the UTF-32 Byte Order Mark. */ \ - if (__glibc_unlikely (outbuf + 4 > outend)) \ - return __GCONV_FULL_OUTPUT; \ - \ - put32u (outbuf, BOM_UTF32); \ - outbuf += 4; \ - } \ - } - -/* Direction of the transformation. */ -enum direction -{ - illegal_dir, - to_utf16, - from_utf16 -}; - -struct utf16_data -{ - enum direction dir; - int emit_bom; -}; - - -extern int gconv_init (struct __gconv_step *step); -int -gconv_init (struct __gconv_step *step) -{ - /* Determine which direction. */ - struct utf16_data *new_data; - enum direction dir = illegal_dir; - int emit_bom; - int result; - - emit_bom = (__strcasecmp (step->__to_name, "UTF-32//") == 0 - || __strcasecmp (step->__to_name, "UTF-16//") == 0); - - if (__strcasecmp (step->__from_name, "UTF-16BE//") == 0 - && (__strcasecmp (step->__to_name, "UTF-32//") == 0 - || __strcasecmp (step->__to_name, "UTF-32BE//") == 0 - || __strcasecmp (step->__to_name, "INTERNAL") == 0)) - { - dir = from_utf16; - } - else if ((__strcasecmp (step->__to_name, "UTF-16//") == 0 - || __strcasecmp (step->__to_name, "UTF-16BE//") == 0) - && (__strcasecmp (step->__from_name, "UTF-32BE//") == 0 - || __strcasecmp (step->__from_name, "INTERNAL") == 0)) - { - dir = to_utf16; - } - - result = __GCONV_NOCONV; - if (dir != illegal_dir) - { - new_data = (struct utf16_data *) malloc (sizeof (struct utf16_data)); - - result = __GCONV_NOMEM; - if (new_data != NULL) - { - new_data->dir = dir; - new_data->emit_bom = emit_bom; - step->__data = new_data; - - if (dir == from_utf16) - { - step->__min_needed_from = MIN_NEEDED_FROM; - step->__max_needed_from = MIN_NEEDED_FROM; - step->__min_needed_to = MIN_NEEDED_TO; - step->__max_needed_to = MIN_NEEDED_TO; - } - else - { - step->__min_needed_from = MIN_NEEDED_TO; - step->__max_needed_from = MIN_NEEDED_TO; - step->__min_needed_to = MIN_NEEDED_FROM; - step->__max_needed_to = MIN_NEEDED_FROM; - } - - step->__stateful = 0; - - result = __GCONV_OK; - } - } - - return result; -} - - -extern void gconv_end (struct __gconv_step *data); -void -gconv_end (struct __gconv_step *data) -{ - free (data->__data); -} - -/* The macro for the hardware loop. This is used for both - directions. */ -#define HARDWARE_CONVERT(INSTRUCTION) \ - { \ - register const unsigned char* pInput __asm__ ("8") = inptr; \ - register unsigned long long inlen __asm__ ("9") = inend - inptr; \ - register unsigned char* pOutput __asm__ ("10") = outptr; \ - register unsigned long long outlen __asm__("11") = outend - outptr; \ - uint64_t cc = 0; \ - \ - __asm__ volatile (".machine push \n\t" \ - ".machine \"z9-109\" \n\t" \ - "0: " INSTRUCTION " \n\t" \ - ".machine pop \n\t" \ - " jo 0b \n\t" \ - " ipm %2 \n" \ - : "+a" (pOutput), "+a" (pInput), "+d" (cc), \ - "+d" (outlen), "+d" (inlen) \ - : \ - : "cc", "memory"); \ - \ - inptr = pInput; \ - outptr = pOutput; \ - cc >>= 28; \ - \ - if (cc == 1) \ - { \ - result = __GCONV_FULL_OUTPUT; \ - break; \ - } \ - else if (cc == 2) \ - { \ - result = __GCONV_ILLEGAL_INPUT; \ - break; \ - } \ - } - -/* Conversion function from UTF-16 to UTF-32 internal/BE. */ - -#define MIN_NEEDED_INPUT MIN_NEEDED_FROM -#define MAX_NEEDED_INPUT MAX_NEEDED_FROM -#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO -#define LOOPFCT FROM_LOOP -/* The software routine is copied from utf-16.c (minus bytes - swapping). */ -#define BODY \ - { \ - /* The hardware instruction currently fails to report an error for \ - isolated low surrogates so we have to disable the instruction \ - until this gets resolved. */ \ - if (0) /* (GLRO (dl_hwcap) & HWCAP_S390_ETF3EH) */ \ - { \ - HARDWARE_CONVERT ("cu24 %0, %1, 1"); \ - if (inptr != inend) \ - { \ - /* Check if the third byte is \ - a valid start of a UTF-16 surrogate. */ \ - if (inend - inptr == 3 && (inptr[3] & 0xfc) != 0xdc) \ - STANDARD_FROM_LOOP_ERR_HANDLER (3); \ - \ - result = __GCONV_INCOMPLETE_INPUT; \ - break; \ - } \ - continue; \ - } \ - \ - uint16_t u1 = get16 (inptr); \ - \ - if (__builtin_expect (u1 < 0xd800, 1) || u1 > 0xdfff) \ - { \ - /* No surrogate. */ \ - put32 (outptr, u1); \ - inptr += 2; \ - } \ - else \ - { \ - /* An isolated low-surrogate was found. This has to be \ - considered ill-formed. */ \ - if (__glibc_unlikely (u1 >= 0xdc00)) \ - { \ - STANDARD_FROM_LOOP_ERR_HANDLER (2); \ - } \ - /* It's a surrogate character. At least the first word says \ - it is. */ \ - if (__glibc_unlikely (inptr + 4 > inend)) \ - { \ - /* We don't have enough input for another complete input \ - character. */ \ - result = __GCONV_INCOMPLETE_INPUT; \ - break; \ - } \ - \ - inptr += 2; \ - uint16_t u2 = get16 (inptr); \ - if (__builtin_expect (u2 < 0xdc00, 0) \ - || __builtin_expect (u2 > 0xdfff, 0)) \ - { \ - /* This is no valid second word for a surrogate. */ \ - inptr -= 2; \ - STANDARD_FROM_LOOP_ERR_HANDLER (2); \ - } \ - \ - put32 (outptr, ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00)); \ - inptr += 2; \ - } \ - outptr += 4; \ - } -#define LOOP_NEED_FLAGS -#include <iconv/loop.c> - -/* Conversion from UTF-32 internal/BE to UTF-16. */ - -#define MIN_NEEDED_INPUT MIN_NEEDED_TO -#define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM -#define MAX_NEEDED_OUTPUT MAX_NEEDED_FROM -#define LOOPFCT TO_LOOP -/* The software routine is copied from utf-16.c (minus bytes - swapping). */ -#define BODY \ - { \ - if (GLRO (dl_hwcap) & HWCAP_S390_ETF3EH) \ - { \ - HARDWARE_CONVERT ("cu42 %0, %1"); \ - \ - if (inptr != inend) \ - { \ - result = __GCONV_INCOMPLETE_INPUT; \ - break; \ - } \ - continue; \ - } \ - \ - uint32_t c = get32 (inptr); \ - \ - if (__builtin_expect (c <= 0xd7ff, 1) \ - || (c >=0xdc00 && c <= 0xffff)) \ - { \ - /* Two UTF-16 chars. */ \ - put16 (outptr, c); \ - } \ - else if (__builtin_expect (c >= 0x10000, 1) \ - && __builtin_expect (c <= 0x10ffff, 1)) \ - { \ - /* Four UTF-16 chars. */ \ - uint16_t zabcd = ((c & 0x1f0000) >> 16) - 1; \ - uint16_t out; \ - \ - /* Generate a surrogate character. */ \ - if (__glibc_unlikely (outptr + 4 > outend)) \ - { \ - /* Overflow in the output buffer. */ \ - result = __GCONV_FULL_OUTPUT; \ - break; \ - } \ - \ - out = 0xd800; \ - out |= (zabcd & 0xff) << 6; \ - out |= (c >> 10) & 0x3f; \ - put16 (outptr, out); \ - outptr += 2; \ - \ - out = 0xdc00; \ - out |= c & 0x3ff; \ - put16 (outptr, out); \ - } \ - else \ - { \ - STANDARD_TO_LOOP_ERR_HANDLER (4); \ - } \ - outptr += 2; \ - inptr += 4; \ - } -#define LOOP_NEED_FLAGS -#include <iconv/loop.c> - -#include <iconv/skeleton.c> diff --git a/sysdeps/s390/s390-64/utf8-utf16-z9.c b/sysdeps/s390/s390-64/utf8-utf16-z9.c deleted file mode 100644 index 4148ed796b..0000000000 --- a/sysdeps/s390/s390-64/utf8-utf16-z9.c +++ /dev/null @@ -1,471 +0,0 @@ -/* Conversion between UTF-16 and UTF-32 BE/internal. - - This module uses the Z9-109 variants of the Convert Unicode - instructions. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - - Author: Andreas Krebbel <Andreas.Krebbel@de.ibm.com> - Based on the work by Ulrich Drepper <drepper@cygnus.com>, 1997. - - Thanks to Daniel Appich who covered the relevant performance work - in his diploma thesis. - - This 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. - - This 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/>. */ - -#include <dlfcn.h> -#include <stdint.h> -#include <unistd.h> -#include <dl-procinfo.h> -#include <gconv.h> - -/* UTF-16 big endian byte order mark. */ -#define BOM_UTF16 0xfeff - -#define DEFINE_INIT 0 -#define DEFINE_FINI 0 -#define MIN_NEEDED_FROM 1 -#define MAX_NEEDED_FROM 4 -#define MIN_NEEDED_TO 2 -#define MAX_NEEDED_TO 4 -#define FROM_LOOP from_utf8_loop -#define TO_LOOP to_utf8_loop -#define FROM_DIRECTION (dir == from_utf8) -#define ONE_DIRECTION 0 -#define PREPARE_LOOP \ - enum direction dir = ((struct utf8_data *) step->__data)->dir; \ - int emit_bom = ((struct utf8_data *) step->__data)->emit_bom; \ - \ - if (emit_bom && !data->__internal_use \ - && data->__invocation_counter == 0) \ - { \ - /* Emit the UTF-16 Byte Order Mark. */ \ - if (__glibc_unlikely (outbuf + 2 > outend)) \ - return __GCONV_FULL_OUTPUT; \ - \ - put16u (outbuf, BOM_UTF16); \ - outbuf += 2; \ - } - -/* Direction of the transformation. */ -enum direction -{ - illegal_dir, - to_utf8, - from_utf8 -}; - -struct utf8_data -{ - enum direction dir; - int emit_bom; -}; - - -extern int gconv_init (struct __gconv_step *step); -int -gconv_init (struct __gconv_step *step) -{ - /* Determine which direction. */ - struct utf8_data *new_data; - enum direction dir = illegal_dir; - int emit_bom; - int result; - - emit_bom = (__strcasecmp (step->__to_name, "UTF-16//") == 0); - - if (__strcasecmp (step->__from_name, "ISO-10646/UTF8/") == 0 - && (__strcasecmp (step->__to_name, "UTF-16//") == 0 - || __strcasecmp (step->__to_name, "UTF-16BE//") == 0)) - { - dir = from_utf8; - } - else if (__strcasecmp (step->__from_name, "UTF-16BE//") == 0 - && __strcasecmp (step->__to_name, "ISO-10646/UTF8/") == 0) - { - dir = to_utf8; - } - - result = __GCONV_NOCONV; - if (dir != illegal_dir) - { - new_data = (struct utf8_data *) malloc (sizeof (struct utf8_data)); - - result = __GCONV_NOMEM; - if (new_data != NULL) - { - new_data->dir = dir; - new_data->emit_bom = emit_bom; - step->__data = new_data; - - if (dir == from_utf8) - { - step->__min_needed_from = MIN_NEEDED_FROM; - step->__max_needed_from = MIN_NEEDED_FROM; - step->__min_needed_to = MIN_NEEDED_TO; - step->__max_needed_to = MIN_NEEDED_TO; - } - else - { - step->__min_needed_from = MIN_NEEDED_TO; - step->__max_needed_from = MIN_NEEDED_TO; - step->__min_needed_to = MIN_NEEDED_FROM; - step->__max_needed_to = MIN_NEEDED_FROM; - } - - step->__stateful = 0; - - result = __GCONV_OK; - } - } - - return result; -} - - -extern void gconv_end (struct __gconv_step *data); -void -gconv_end (struct __gconv_step *data) -{ - free (data->__data); -} - -/* The macro for the hardware loop. This is used for both - directions. */ -#define HARDWARE_CONVERT(INSTRUCTION) \ - { \ - register const unsigned char* pInput __asm__ ("8") = inptr; \ - register unsigned long long inlen __asm__ ("9") = inend - inptr; \ - register unsigned char* pOutput __asm__ ("10") = outptr; \ - register unsigned long long outlen __asm__("11") = outend - outptr; \ - uint64_t cc = 0; \ - \ - __asm__ volatile (".machine push \n\t" \ - ".machine \"z9-109\" \n\t" \ - "0: " INSTRUCTION " \n\t" \ - ".machine pop \n\t" \ - " jo 0b \n\t" \ - " ipm %2 \n" \ - : "+a" (pOutput), "+a" (pInput), "+d" (cc), \ - "+d" (outlen), "+d" (inlen) \ - : \ - : "cc", "memory"); \ - \ - inptr = pInput; \ - outptr = pOutput; \ - cc >>= 28; \ - \ - if (cc == 1) \ - { \ - result = __GCONV_FULL_OUTPUT; \ - break; \ - } \ - else if (cc == 2) \ - { \ - result = __GCONV_ILLEGAL_INPUT; \ - break; \ - } \ - } - -/* Conversion function from UTF-8 to UTF-16. */ - -#define MIN_NEEDED_INPUT MIN_NEEDED_FROM -#define MAX_NEEDED_INPUT MAX_NEEDED_FROM -#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO -#define MAX_NEEDED_OUTPUT MAX_NEEDED_TO -#define LOOPFCT FROM_LOOP -/* The software implementation is based on the code in gconv_simple.c. */ -#define BODY \ - { \ - if (GLRO (dl_hwcap) & HWCAP_S390_ETF3EH) \ - { \ - HARDWARE_CONVERT ("cu12 %0, %1, 1"); \ - \ - if (inptr != inend) \ - { \ - int i; \ - for (i = 1; inptr + i < inend; ++i) \ - if ((inptr[i] & 0xc0) != 0x80) \ - break; \ - \ - if (__glibc_likely (inptr + i == inend)) \ - { \ - result = __GCONV_INCOMPLETE_INPUT; \ - break; \ - } \ - STANDARD_FROM_LOOP_ERR_HANDLER (i); \ - } \ - continue; \ - } \ - \ - /* Next input byte. */ \ - uint16_t ch = *inptr; \ - \ - if (__glibc_likely (ch < 0x80)) \ - { \ - /* One byte sequence. */ \ - ++inptr; \ - } \ - else \ - { \ - uint_fast32_t cnt; \ - uint_fast32_t i; \ - \ - if (ch >= 0xc2 && ch < 0xe0) \ - { \ - /* We expect two bytes. The first byte cannot be 0xc0 \ - or 0xc1, otherwise the wide character could have been \ - represented using a single byte. */ \ - cnt = 2; \ - ch &= 0x1f; \ - } \ - else if (__glibc_likely ((ch & 0xf0) == 0xe0)) \ - { \ - /* We expect three bytes. */ \ - cnt = 3; \ - ch &= 0x0f; \ - } \ - else if (__glibc_likely ((ch & 0xf8) == 0xf0)) \ - { \ - /* We expect four bytes. */ \ - cnt = 4; \ - ch &= 0x07; \ - } \ - else \ - { \ - /* Search the end of this ill-formed UTF-8 character. This \ - is the next byte with (x & 0xc0) != 0x80. */ \ - i = 0; \ - do \ - ++i; \ - while (inptr + i < inend \ - && (*(inptr + i) & 0xc0) == 0x80 \ - && i < 5); \ - \ - errout: \ - STANDARD_FROM_LOOP_ERR_HANDLER (i); \ - } \ - \ - if (__glibc_unlikely (inptr + cnt > inend)) \ - { \ - /* We don't have enough input. But before we report \ - that check that all the bytes are correct. */ \ - for (i = 1; inptr + i < inend; ++i) \ - if ((inptr[i] & 0xc0) != 0x80) \ - break; \ - \ - if (__glibc_likely (inptr + i == inend)) \ - { \ - result = __GCONV_INCOMPLETE_INPUT; \ - break; \ - } \ - \ - goto errout; \ - } \ - \ - if (cnt == 4) \ - { \ - /* For 4 byte UTF-8 chars two UTF-16 chars (high and \ - low) are needed. */ \ - uint16_t zabcd, high, low; \ - \ - if (__glibc_unlikely (outptr + 4 > outend)) \ - { \ - /* Overflow in the output buffer. */ \ - result = __GCONV_FULL_OUTPUT; \ - break; \ - } \ - \ - /* See Principles of Operations cu12. */ \ - zabcd = (((inptr[0] & 0x7) << 2) | \ - ((inptr[1] & 0x30) >> 4)) - 1; \ - \ - /* z-bit must be zero after subtracting 1. */ \ - if (zabcd & 0x10) \ - STANDARD_FROM_LOOP_ERR_HANDLER (4) \ - \ - high = (uint16_t)(0xd8 << 8); /* high surrogate id */ \ - high |= zabcd << 6; /* abcd bits */ \ - high |= (inptr[1] & 0xf) << 2; /* efgh bits */ \ - high |= (inptr[2] & 0x30) >> 4; /* ij bits */ \ - \ - low = (uint16_t)(0xdc << 8); /* low surrogate id */ \ - low |= ((uint16_t)inptr[2] & 0xc) << 6; /* kl bits */ \ - low |= (inptr[2] & 0x3) << 6; /* mn bits */ \ - low |= inptr[3] & 0x3f; /* opqrst bits */ \ - \ - put16 (outptr, high); \ - outptr += 2; \ - put16 (outptr, low); \ - outptr += 2; \ - inptr += 4; \ - continue; \ - } \ - else \ - { \ - /* Read the possible remaining bytes. */ \ - for (i = 1; i < cnt; ++i) \ - { \ - uint16_t byte = inptr[i]; \ - \ - if ((byte & 0xc0) != 0x80) \ - /* This is an illegal encoding. */ \ - break; \ - \ - ch <<= 6; \ - ch |= byte & 0x3f; \ - } \ - inptr += cnt; \ - \ - } \ - } \ - /* Now adjust the pointers and store the result. */ \ - *((uint16_t *) outptr) = ch; \ - outptr += sizeof (uint16_t); \ - } - -#define LOOP_NEED_FLAGS -#include <iconv/loop.c> - -/* Conversion from UTF-16 to UTF-8. */ - -#define MIN_NEEDED_INPUT MIN_NEEDED_TO -#define MAX_NEEDED_INPUT MAX_NEEDED_TO -#define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM -#define MAX_NEEDED_OUTPUT MAX_NEEDED_FROM -#define LOOPFCT TO_LOOP -/* The software routine is based on the functionality of the S/390 - hardware instruction (cu21) as described in the Principles of - Operation. */ -#define BODY \ - { \ - /* The hardware instruction currently fails to report an error for \ - isolated low surrogates so we have to disable the instruction \ - until this gets resolved. */ \ - if (0) /* (GLRO (dl_hwcap) & HWCAP_S390_ETF3EH) */ \ - { \ - HARDWARE_CONVERT ("cu21 %0, %1, 1"); \ - if (inptr != inend) \ - { \ - /* Check if the third byte is \ - a valid start of a UTF-16 surrogate. */ \ - if (inend - inptr == 3 && (inptr[3] & 0xfc) != 0xdc) \ - STANDARD_TO_LOOP_ERR_HANDLER (3); \ - \ - result = __GCONV_INCOMPLETE_INPUT; \ - break; \ - } \ - continue; \ - } \ - \ - uint16_t c = get16 (inptr); \ - \ - if (__glibc_likely (c <= 0x007f)) \ - { \ - /* Single byte UTF-8 char. */ \ - *outptr = c & 0xff; \ - outptr++; \ - } \ - else if (c >= 0x0080 && c <= 0x07ff) \ - { \ - /* Two byte UTF-8 char. */ \ - \ - if (__glibc_unlikely (outptr + 2 > outend)) \ - { \ - /* Overflow in the output buffer. */ \ - result = __GCONV_FULL_OUTPUT; \ - break; \ - } \ - \ - outptr[0] = 0xc0; \ - outptr[0] |= c >> 6; \ - \ - outptr[1] = 0x80; \ - outptr[1] |= c & 0x3f; \ - \ - outptr += 2; \ - } \ - else if ((c >= 0x0800 && c <= 0xd7ff) || c > 0xdfff) \ - { \ - /* Three byte UTF-8 char. */ \ - \ - if (__glibc_unlikely (outptr + 3 > outend)) \ - { \ - /* Overflow in the output buffer. */ \ - result = __GCONV_FULL_OUTPUT; \ - break; \ - } \ - outptr[0] = 0xe0; \ - outptr[0] |= c >> 12; \ - \ - outptr[1] = 0x80; \ - outptr[1] |= (c >> 6) & 0x3f; \ - \ - outptr[2] = 0x80; \ - outptr[2] |= c & 0x3f; \ - \ - outptr += 3; \ - } \ - else if (c >= 0xd800 && c <= 0xdbff) \ - { \ - /* Four byte UTF-8 char. */ \ - uint16_t low, uvwxy; \ - \ - if (__glibc_unlikely (outptr + 4 > outend)) \ - { \ - /* Overflow in the output buffer. */ \ - result = __GCONV_FULL_OUTPUT; \ - break; \ - } \ - inptr += 2; \ - if (__glibc_unlikely (inptr + 2 > inend)) \ - { \ - result = __GCONV_INCOMPLETE_INPUT; \ - break; \ - } \ - \ - low = get16 (inptr); \ - \ - if ((low & 0xfc00) != 0xdc00) \ - { \ - inptr -= 2; \ - STANDARD_TO_LOOP_ERR_HANDLER (2); \ - } \ - uvwxy = ((c >> 6) & 0xf) + 1; \ - outptr[0] = 0xf0; \ - outptr[0] |= uvwxy >> 2; \ - \ - outptr[1] = 0x80; \ - outptr[1] |= (uvwxy << 4) & 0x30; \ - outptr[1] |= (c >> 2) & 0x0f; \ - \ - outptr[2] = 0x80; \ - outptr[2] |= (c & 0x03) << 4; \ - outptr[2] |= (low >> 6) & 0x0f; \ - \ - outptr[3] = 0x80; \ - outptr[3] |= low & 0x3f; \ - \ - outptr += 4; \ - } \ - else \ - { \ - STANDARD_TO_LOOP_ERR_HANDLER (2); \ - } \ - inptr += 2; \ - } -#define LOOP_NEED_FLAGS -#include <iconv/loop.c> - -#include <iconv/skeleton.c> diff --git a/sysdeps/s390/s390-64/utf8-utf32-z9.c b/sysdeps/s390/s390-64/utf8-utf32-z9.c deleted file mode 100644 index defd47d251..0000000000 --- a/sysdeps/s390/s390-64/utf8-utf32-z9.c +++ /dev/null @@ -1,511 +0,0 @@ -/* Conversion between UTF-8 and UTF-32 BE/internal. - - This module uses the Z9-109 variants of the Convert Unicode - instructions. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - - Author: Andreas Krebbel <Andreas.Krebbel@de.ibm.com> - Based on the work by Ulrich Drepper <drepper@cygnus.com>, 1997. - - Thanks to Daniel Appich who covered the relevant performance work - in his diploma thesis. - - This 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. - - This 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/>. */ - -#include <dlfcn.h> -#include <stdint.h> -#include <unistd.h> -#include <dl-procinfo.h> -#include <gconv.h> - -/* UTF-32 big endian byte order mark. */ -#define BOM 0x0000feffu - -#define DEFINE_INIT 0 -#define DEFINE_FINI 0 -/* These definitions apply to the UTF-8 to UTF-32 direction. The - software implementation for UTF-8 still supports multibyte - characters up to 6 bytes whereas the hardware variant does not. */ -#define MIN_NEEDED_FROM 1 -#define MAX_NEEDED_FROM 6 -#define MIN_NEEDED_TO 4 -#define FROM_LOOP from_utf8_loop -#define TO_LOOP to_utf8_loop -#define FROM_DIRECTION (dir == from_utf8) -#define ONE_DIRECTION 0 -#define PREPARE_LOOP \ - enum direction dir = ((struct utf8_data *) step->__data)->dir; \ - int emit_bom = ((struct utf8_data *) step->__data)->emit_bom; \ - \ - if (emit_bom && !data->__internal_use \ - && data->__invocation_counter == 0) \ - { \ - /* Emit the Byte Order Mark. */ \ - if (__glibc_unlikely (outbuf + 4 > outend)) \ - return __GCONV_FULL_OUTPUT; \ - \ - put32u (outbuf, BOM); \ - outbuf += 4; \ - } - -/* Direction of the transformation. */ -enum direction -{ - illegal_dir, - to_utf8, - from_utf8 -}; - -struct utf8_data -{ - enum direction dir; - int emit_bom; -}; - - -extern int gconv_init (struct __gconv_step *step); -int -gconv_init (struct __gconv_step *step) -{ - /* Determine which direction. */ - struct utf8_data *new_data; - enum direction dir = illegal_dir; - int emit_bom; - int result; - - emit_bom = (__strcasecmp (step->__to_name, "UTF-32//") == 0); - - if (__strcasecmp (step->__from_name, "ISO-10646/UTF8/") == 0 - && (__strcasecmp (step->__to_name, "UTF-32//") == 0 - || __strcasecmp (step->__to_name, "UTF-32BE//") == 0 - || __strcasecmp (step->__to_name, "INTERNAL") == 0)) - { - dir = from_utf8; - } - else if (__strcasecmp (step->__to_name, "ISO-10646/UTF8/") == 0 - && (__strcasecmp (step->__from_name, "UTF-32BE//") == 0 - || __strcasecmp (step->__from_name, "INTERNAL") == 0)) - { - dir = to_utf8; - } - - result = __GCONV_NOCONV; - if (dir != illegal_dir) - { - new_data = (struct utf8_data *) malloc (sizeof (struct utf8_data)); - - result = __GCONV_NOMEM; - if (new_data != NULL) - { - new_data->dir = dir; - new_data->emit_bom = emit_bom; - step->__data = new_data; - - if (dir == from_utf8) - { - step->__min_needed_from = MIN_NEEDED_FROM; - step->__max_needed_from = MIN_NEEDED_FROM; - step->__min_needed_to = MIN_NEEDED_TO; - step->__max_needed_to = MIN_NEEDED_TO; - } - else - { - step->__min_needed_from = MIN_NEEDED_TO; - step->__max_needed_from = MIN_NEEDED_TO; - step->__min_needed_to = MIN_NEEDED_FROM; - step->__max_needed_to = MIN_NEEDED_FROM; - } - - step->__stateful = 0; - - result = __GCONV_OK; - } - } - - return result; -} - - -extern void gconv_end (struct __gconv_step *data); -void -gconv_end (struct __gconv_step *data) -{ - free (data->__data); -} - -/* The macro for the hardware loop. This is used for both - directions. */ -#define HARDWARE_CONVERT(INSTRUCTION) \ - { \ - register const unsigned char* pInput __asm__ ("8") = inptr; \ - register unsigned long long inlen __asm__ ("9") = inend - inptr; \ - register unsigned char* pOutput __asm__ ("10") = outptr; \ - register unsigned long long outlen __asm__("11") = outend - outptr; \ - uint64_t cc = 0; \ - \ - __asm__ volatile (".machine push \n\t" \ - ".machine \"z9-109\" \n\t" \ - "0: " INSTRUCTION " \n\t" \ - ".machine pop \n\t" \ - " jo 0b \n\t" \ - " ipm %2 \n" \ - : "+a" (pOutput), "+a" (pInput), "+d" (cc), \ - "+d" (outlen), "+d" (inlen) \ - : \ - : "cc", "memory"); \ - \ - inptr = pInput; \ - outptr = pOutput; \ - cc >>= 28; \ - \ - if (cc == 1) \ - { \ - result = __GCONV_FULL_OUTPUT; \ - break; \ - } \ - else if (cc == 2) \ - { \ - result = __GCONV_ILLEGAL_INPUT; \ - break; \ - } \ - } - -/* Conversion function from UTF-8 to UTF-32 internal/BE. */ - -#define MIN_NEEDED_INPUT MIN_NEEDED_FROM -#define MAX_NEEDED_INPUT MAX_NEEDED_FROM -#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO -#define LOOPFCT FROM_LOOP -/* The software routine is copied from gconv_simple.c. */ -#define BODY \ - { \ - if (GLRO (dl_hwcap) & HWCAP_S390_ETF3EH) \ - { \ - HARDWARE_CONVERT ("cu14 %0, %1, 1"); \ - \ - if (inptr != inend) \ - { \ - int i; \ - for (i = 1; inptr + i < inend; ++i) \ - if ((inptr[i] & 0xc0) != 0x80) \ - break; \ - \ - if (__glibc_likely (inptr + i == inend)) \ - { \ - result = __GCONV_INCOMPLETE_INPUT; \ - break; \ - } \ - STANDARD_FROM_LOOP_ERR_HANDLER (i); \ - } \ - continue; \ - } \ - \ - /* Next input byte. */ \ - uint32_t ch = *inptr; \ - \ - if (__glibc_likely (ch < 0x80)) \ - { \ - /* One byte sequence. */ \ - ++inptr; \ - } \ - else \ - { \ - uint_fast32_t cnt; \ - uint_fast32_t i; \ - \ - if (ch >= 0xc2 && ch < 0xe0) \ - { \ - /* We expect two bytes. The first byte cannot be 0xc0 or \ - 0xc1, otherwise the wide character could have been \ - represented using a single byte. */ \ - cnt = 2; \ - ch &= 0x1f; \ - } \ - else if (__glibc_likely ((ch & 0xf0) == 0xe0)) \ - { \ - /* We expect three bytes. */ \ - cnt = 3; \ - ch &= 0x0f; \ - } \ - else if (__glibc_likely ((ch & 0xf8) == 0xf0)) \ - { \ - /* We expect four bytes. */ \ - cnt = 4; \ - ch &= 0x07; \ - } \ - else if (__glibc_likely ((ch & 0xfc) == 0xf8)) \ - { \ - /* We expect five bytes. */ \ - cnt = 5; \ - ch &= 0x03; \ - } \ - else if (__glibc_likely ((ch & 0xfe) == 0xfc)) \ - { \ - /* We expect six bytes. */ \ - cnt = 6; \ - ch &= 0x01; \ - } \ - else \ - { \ - /* Search the end of this ill-formed UTF-8 character. This \ - is the next byte with (x & 0xc0) != 0x80. */ \ - i = 0; \ - do \ - ++i; \ - while (inptr + i < inend \ - && (*(inptr + i) & 0xc0) == 0x80 \ - && i < 5); \ - \ - errout: \ - STANDARD_FROM_LOOP_ERR_HANDLER (i); \ - } \ - \ - if (__glibc_unlikely (inptr + cnt > inend)) \ - { \ - /* We don't have enough input. But before we report \ - that check that all the bytes are correct. */ \ - for (i = 1; inptr + i < inend; ++i) \ - if ((inptr[i] & 0xc0) != 0x80) \ - break; \ - \ - if (__glibc_likely (inptr + i == inend)) \ - { \ - result = __GCONV_INCOMPLETE_INPUT; \ - break; \ - } \ - \ - goto errout; \ - } \ - \ - /* Read the possible remaining bytes. */ \ - for (i = 1; i < cnt; ++i) \ - { \ - uint32_t byte = inptr[i]; \ - \ - if ((byte & 0xc0) != 0x80) \ - /* This is an illegal encoding. */ \ - break; \ - \ - ch <<= 6; \ - ch |= byte & 0x3f; \ - } \ - \ - /* If i < cnt, some trail byte was not >= 0x80, < 0xc0. \ - If cnt > 2 and ch < 2^(5*cnt-4), the wide character ch could \ - have been represented with fewer than cnt bytes. */ \ - if (i < cnt || (cnt > 2 && (ch >> (5 * cnt - 4)) == 0)) \ - { \ - /* This is an illegal encoding. */ \ - goto errout; \ - } \ - \ - inptr += cnt; \ - } \ - \ - /* Now adjust the pointers and store the result. */ \ - *((uint32_t *) outptr) = ch; \ - outptr += sizeof (uint32_t); \ - } -#define LOOP_NEED_FLAGS - -#define STORE_REST \ - { \ - /* We store the remaining bytes while converting them into the UCS4 \ - format. We can assume that the first byte in the buffer is \ - correct and that it requires a larger number of bytes than there \ - are in the input buffer. */ \ - wint_t ch = **inptrp; \ - size_t cnt, r; \ - \ - state->__count = inend - *inptrp; \ - \ - if (ch >= 0xc2 && ch < 0xe0) \ - { \ - /* We expect two bytes. The first byte cannot be 0xc0 or \ - 0xc1, otherwise the wide character could have been \ - represented using a single byte. */ \ - cnt = 2; \ - ch &= 0x1f; \ - } \ - else if (__glibc_likely ((ch & 0xf0) == 0xe0)) \ - { \ - /* We expect three bytes. */ \ - cnt = 3; \ - ch &= 0x0f; \ - } \ - else if (__glibc_likely ((ch & 0xf8) == 0xf0)) \ - { \ - /* We expect four bytes. */ \ - cnt = 4; \ - ch &= 0x07; \ - } \ - else if (__glibc_likely ((ch & 0xfc) == 0xf8)) \ - { \ - /* We expect five bytes. */ \ - cnt = 5; \ - ch &= 0x03; \ - } \ - else \ - { \ - /* We expect six bytes. */ \ - cnt = 6; \ - ch &= 0x01; \ - } \ - \ - /* The first byte is already consumed. */ \ - r = cnt - 1; \ - while (++(*inptrp) < inend) \ - { \ - ch <<= 6; \ - ch |= **inptrp & 0x3f; \ - --r; \ - } \ - \ - /* Shift for the so far missing bytes. */ \ - ch <<= r * 6; \ - \ - /* Store the number of bytes expected for the entire sequence. */ \ - state->__count |= cnt << 8; \ - \ - /* Store the value. */ \ - state->__value.__wch = ch; \ - } - -#define UNPACK_BYTES \ - { \ - static const unsigned char inmask[5] = { 0xc0, 0xe0, 0xf0, 0xf8, 0xfc }; \ - wint_t wch = state->__value.__wch; \ - size_t ntotal = state->__count >> 8; \ - \ - inlen = state->__count & 255; \ - \ - bytebuf[0] = inmask[ntotal - 2]; \ - \ - do \ - { \ - if (--ntotal < inlen) \ - bytebuf[ntotal] = 0x80 | (wch & 0x3f); \ - wch >>= 6; \ - } \ - while (ntotal > 1); \ - \ - bytebuf[0] |= wch; \ - } - -#define CLEAR_STATE \ - state->__count = 0 - -#include <iconv/loop.c> - -/* Conversion from UTF-32 internal/BE to UTF-8. */ - -#define MIN_NEEDED_INPUT MIN_NEEDED_TO -#define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM -#define MAX_NEEDED_OUTPUT MAX_NEEDED_FROM -#define LOOPFCT TO_LOOP -/* The software routine mimics the S/390 cu41 instruction. */ -#define BODY \ - { \ - if (GLRO (dl_hwcap) & HWCAP_S390_ETF3EH) \ - { \ - HARDWARE_CONVERT ("cu41 %0, %1"); \ - \ - if (inptr != inend) \ - { \ - result = __GCONV_INCOMPLETE_INPUT; \ - break; \ - } \ - continue; \ - } \ - \ - uint32_t wc = *((const uint32_t *) inptr); \ - \ - if (__glibc_likely (wc <= 0x7f)) \ - { \ - /* Single UTF-8 char. */ \ - *outptr = (uint8_t)wc; \ - outptr++; \ - } \ - else if (wc <= 0x7ff) \ - { \ - /* Two UTF-8 chars. */ \ - if (__glibc_unlikely (outptr + 2 > outend)) \ - { \ - /* Overflow in the output buffer. */ \ - result = __GCONV_FULL_OUTPUT; \ - break; \ - } \ - \ - outptr[0] = 0xc0; \ - outptr[0] |= wc >> 6; \ - \ - outptr[1] = 0x80; \ - outptr[1] |= wc & 0x3f; \ - \ - outptr += 2; \ - } \ - else if (wc <= 0xffff) \ - { \ - /* Three UTF-8 chars. */ \ - if (__glibc_unlikely (outptr + 3 > outend)) \ - { \ - /* Overflow in the output buffer. */ \ - result = __GCONV_FULL_OUTPUT; \ - break; \ - } \ - outptr[0] = 0xe0; \ - outptr[0] |= wc >> 12; \ - \ - outptr[1] = 0x80; \ - outptr[1] |= (wc >> 6) & 0x3f; \ - \ - outptr[2] = 0x80; \ - outptr[2] |= wc & 0x3f; \ - \ - outptr += 3; \ - } \ - else if (wc <= 0x10ffff) \ - { \ - /* Four UTF-8 chars. */ \ - if (__glibc_unlikely (outptr + 4 > outend)) \ - { \ - /* Overflow in the output buffer. */ \ - result = __GCONV_FULL_OUTPUT; \ - break; \ - } \ - outptr[0] = 0xf0; \ - outptr[0] |= wc >> 18; \ - \ - outptr[1] = 0x80; \ - outptr[1] |= (wc >> 12) & 0x3f; \ - \ - outptr[2] = 0x80; \ - outptr[2] |= (wc >> 6) & 0x3f; \ - \ - outptr[3] = 0x80; \ - outptr[3] |= wc & 0x3f; \ - \ - outptr += 4; \ - } \ - else \ - { \ - STANDARD_TO_LOOP_ERR_HANDLER (4); \ - } \ - inptr += 4; \ - } -#define LOOP_NEED_FLAGS -#include <iconv/loop.c> - -#include <iconv/skeleton.c> |