~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/alpha/lib/strncat.S

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/alpha/lib/strncat.S (Architecture i386) and /arch/alpha/lib/strncat.S (Architecture alpha)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*                                                  2 /*
  3  * arch/alpha/lib/strncat.S                         3  * arch/alpha/lib/strncat.S
  4  * Contributed by Richard Henderson (rth@tamu.      4  * Contributed by Richard Henderson (rth@tamu.edu)
  5  *                                                  5  *
  6  * Append no more than COUNT characters from t      6  * Append no more than COUNT characters from the null-terminated string SRC
  7  * to the null-terminated string DST.  Always       7  * to the null-terminated string DST.  Always null-terminate the new DST.
  8  *                                                  8  *
  9  * This differs slightly from the semantics in      9  * This differs slightly from the semantics in libc in that we never write
 10  * past count, whereas libc may write to count     10  * past count, whereas libc may write to count+1.  This follows the generic
 11  * implementation in lib/string.c and is, IMHO     11  * implementation in lib/string.c and is, IMHO, more sensible.
 12  */                                                12  */
 13 #include <linux/export.h>                          13 #include <linux/export.h>
 14         .text                                      14         .text
 15                                                    15 
 16         .align 3                                   16         .align 3
 17         .globl strncat                             17         .globl strncat
 18         .ent strncat                               18         .ent strncat
 19 strncat:                                           19 strncat:
 20         .frame $30, 0, $26                         20         .frame $30, 0, $26
 21         .prologue 0                                21         .prologue 0
 22                                                    22 
 23         mov     $16, $0         # set up retur     23         mov     $16, $0         # set up return value
 24         beq     $18, $zerocount                    24         beq     $18, $zerocount
 25                                                    25 
 26         /* Find the end of the string.  */         26         /* Find the end of the string.  */
 27                                                    27 
 28         ldq_u   $1, 0($16)      # load first q     28         ldq_u   $1, 0($16)      # load first quadword ($16 may be misaligned)
 29         lda     $2, -1($31)                        29         lda     $2, -1($31)
 30         insqh   $2, $16, $2                        30         insqh   $2, $16, $2
 31         andnot  $16, 7, $16                        31         andnot  $16, 7, $16
 32         or      $2, $1, $1                         32         or      $2, $1, $1
 33         cmpbge  $31, $1, $2     # bits set iff     33         cmpbge  $31, $1, $2     # bits set iff byte == 0
 34         bne     $2, $found                         34         bne     $2, $found
 35                                                    35 
 36 $loop:  ldq     $1, 8($16)                         36 $loop:  ldq     $1, 8($16)
 37         addq    $16, 8, $16                        37         addq    $16, 8, $16
 38         cmpbge  $31, $1, $2                        38         cmpbge  $31, $1, $2
 39         beq     $2, $loop                          39         beq     $2, $loop
 40                                                    40 
 41 $found: negq    $2, $3          # clear all bu     41 $found: negq    $2, $3          # clear all but least set bit
 42         and     $2, $3, $2                         42         and     $2, $3, $2
 43                                                    43 
 44         and     $2, 0xf0, $3    # binary searc     44         and     $2, 0xf0, $3    # binary search for that set bit
 45         and     $2, 0xcc, $4                       45         and     $2, 0xcc, $4
 46         and     $2, 0xaa, $5                       46         and     $2, 0xaa, $5
 47         cmovne  $3, 4, $3                          47         cmovne  $3, 4, $3
 48         cmovne  $4, 2, $4                          48         cmovne  $4, 2, $4
 49         cmovne  $5, 1, $5                          49         cmovne  $5, 1, $5
 50         addq    $3, $4, $3                         50         addq    $3, $4, $3
 51         addq    $16, $5, $16                       51         addq    $16, $5, $16
 52         addq    $16, $3, $16                       52         addq    $16, $3, $16
 53                                                    53 
 54         /* Now do the append.  */                  54         /* Now do the append.  */
 55                                                    55 
 56         bsr     $23, __stxncpy                     56         bsr     $23, __stxncpy
 57                                                    57 
 58         /* Worry about the null termination.       58         /* Worry about the null termination.  */
 59                                                    59 
 60         zapnot  $1, $27, $2     # was last byt     60         zapnot  $1, $27, $2     # was last byte a null?
 61         bne     $2, 0f                             61         bne     $2, 0f
 62         ret                                        62         ret
 63                                                    63 
 64 0:      cmplt   $27, $24, $2    # did we fill      64 0:      cmplt   $27, $24, $2    # did we fill the buffer completely?
 65         or      $2, $18, $2                        65         or      $2, $18, $2
 66         bne     $2, 2f                             66         bne     $2, 2f
 67                                                    67 
 68         and     $24, 0x80, $2   # no zero next     68         and     $24, 0x80, $2   # no zero next byte
 69         bne     $2, 1f                             69         bne     $2, 1f
 70                                                    70 
 71         /* Here there are bytes left in the cu     71         /* Here there are bytes left in the current word.  Clear one.  */
 72         addq    $24, $24, $24   # end-of-count     72         addq    $24, $24, $24   # end-of-count bit <<= 1
 73 2:      zap     $1, $24, $1                        73 2:      zap     $1, $24, $1
 74         stq_u   $1, 0($16)                         74         stq_u   $1, 0($16)
 75         ret                                        75         ret
 76                                                    76 
 77 1:      /* Here we must read the next DST word     77 1:      /* Here we must read the next DST word and clear the first byte.  */
 78         ldq_u   $1, 8($16)                         78         ldq_u   $1, 8($16)
 79         zap     $1, 1, $1                          79         zap     $1, 1, $1
 80         stq_u   $1, 8($16)                         80         stq_u   $1, 8($16)
 81                                                    81 
 82 $zerocount:                                        82 $zerocount:
 83         ret                                        83         ret
 84                                                    84 
 85         .end strncat                               85         .end strncat
 86         EXPORT_SYMBOL(strncat)                     86         EXPORT_SYMBOL(strncat)
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php