github.com/razvanm/vanadium-go-1.3@v0.0.0-20160721203343-4a65068e5915/src/runtime/noasm_arm.go (about)

     1  // Copyright 2013 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Routines that are implemented in assembly in asm_{amd64,386}.s
     6  // but are implemented in Go for arm.
     7  
     8  package runtime
     9  
    10  func cmpstring(s1, s2 string) int {
    11  	l := len(s1)
    12  	if len(s2) < l {
    13  		l = len(s2)
    14  	}
    15  	for i := 0; i < l; i++ {
    16  		c1, c2 := s1[i], s2[i]
    17  		if c1 < c2 {
    18  			return -1
    19  		}
    20  		if c1 > c2 {
    21  			return +1
    22  		}
    23  	}
    24  	if len(s1) < len(s2) {
    25  		return -1
    26  	}
    27  	if len(s1) > len(s2) {
    28  		return +1
    29  	}
    30  	return 0
    31  }
    32  
    33  func cmpbytes(s1, s2 []byte) int {
    34  	l := len(s1)
    35  	if len(s2) < l {
    36  		l = len(s2)
    37  	}
    38  	for i := 0; i < l; i++ {
    39  		c1, c2 := s1[i], s2[i]
    40  		if c1 < c2 {
    41  			return -1
    42  		}
    43  		if c1 > c2 {
    44  			return +1
    45  		}
    46  	}
    47  	if len(s1) < len(s2) {
    48  		return -1
    49  	}
    50  	if len(s1) > len(s2) {
    51  		return +1
    52  	}
    53  	return 0
    54  }