github.com/hbdrawn/golang@v0.0.0-20141214014649-6b835209aba2/src/runtime/noasm.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 // +build arm ppc64 ppc64le 9 10 package runtime 11 12 func cmpstring(s1, s2 string) int { 13 l := len(s1) 14 if len(s2) < l { 15 l = len(s2) 16 } 17 for i := 0; i < l; i++ { 18 c1, c2 := s1[i], s2[i] 19 if c1 < c2 { 20 return -1 21 } 22 if c1 > c2 { 23 return +1 24 } 25 } 26 if len(s1) < len(s2) { 27 return -1 28 } 29 if len(s1) > len(s2) { 30 return +1 31 } 32 return 0 33 } 34 35 func cmpbytes(s1, s2 []byte) int { 36 l := len(s1) 37 if len(s2) < l { 38 l = len(s2) 39 } 40 for i := 0; i < l; i++ { 41 c1, c2 := s1[i], s2[i] 42 if c1 < c2 { 43 return -1 44 } 45 if c1 > c2 { 46 return +1 47 } 48 } 49 if len(s1) < len(s2) { 50 return -1 51 } 52 if len(s1) > len(s2) { 53 return +1 54 } 55 return 0 56 }