]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
s390: Use 64bit branch relative on count instruction in strncpy-z900.S [BZ #34398]
authorStefan Liebler <stli@linux.ibm.com>
Tue, 14 Jul 2026 08:56:49 +0000 (10:56 +0200)
committerStefan Liebler <stli@linux.ibm.com>
Tue, 14 Jul 2026 12:39:21 +0000 (14:39 +0200)
At the time the s390-32 strncpy implementation was adjusted for the
s390-64 port, the brct (branch relative on count) instruction was
not adjusted from 32bit to 64bit instruction.

If n contains a value >32bit, the number of 8 byte chunks is computed
with srlg (64bit shift right). The processing of 8 byte chunks is then
processed by looping with brct (32bit branch relative on count) instruction.

This patch just uses the brctg (64bit branch relative on count) instruciton.

Note 1: There is a second loop copying the remaining seven bytes.  The usage
of 32bit brct for looping is fine here.

Note 2: If glibc is build with architecture level set >=z13, the z900 variant
of strncpy is not build at all.

Note 3: If glibc is build for <z13, the z900 ifunc variant is only chosen if
not run on >=z13 or if called via __GI_strncpy.

sysdeps/s390/strncpy-z900.S

index 6d954cf4024ea964f2bfc54dde78d9d8fd5b333f..141cba22942ca4927f6d3c9850dee22b409ad95f 100644 (file)
@@ -56,7 +56,7 @@ ENTRY(STRNCPY_Z900)
        jz    .L10
        stg   %r0,0(%r2,%r3)        # store all eight to dest.
        la    %r3,8(%r3)
-       brct  %r4,.L0
+       brctg %r4,.L0
 .L1:   ltgr  %r1,%r1
        jz    .Lexit
 .L2:   icm   %r0,1,0(%r3)