noasm_arm.go 868 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. // Routines that are implemented in assembly in asm_{amd64,386}.s
  5. // but are implemented in Go for arm.
  6. package runtime
  7. func cmpstring(s1, s2 string) int {
  8. l := len(s1)
  9. if len(s2) < l {
  10. l = len(s2)
  11. }
  12. for i := 0; i < l; i++ {
  13. c1, c2 := s1[i], s2[i]
  14. if c1 < c2 {
  15. return -1
  16. }
  17. if c1 > c2 {
  18. return +1
  19. }
  20. }
  21. if len(s1) < len(s2) {
  22. return -1
  23. }
  24. if len(s1) > len(s2) {
  25. return +1
  26. }
  27. return 0
  28. }
  29. func cmpbytes(s1, s2 []byte) int {
  30. l := len(s1)
  31. if len(s2) < l {
  32. l = len(s2)
  33. }
  34. for i := 0; i < l; i++ {
  35. c1, c2 := s1[i], s2[i]
  36. if c1 < c2 {
  37. return -1
  38. }
  39. if c1 > c2 {
  40. return +1
  41. }
  42. }
  43. if len(s1) < len(s2) {
  44. return -1
  45. }
  46. if len(s1) > len(s2) {
  47. return +1
  48. }
  49. return 0
  50. }