1 /* go-strcmp.c -- the go string comparison function. 2 3 Copyright 2009 The Go Authors. All rights reserved. 4 Use of this source code is governed by a BSD-style 5 license that can be found in the LICENSE file. */ 6 7 #include "runtime.h" 8 9 intgo __go_strcmp(String s1,String s2)10__go_strcmp(String s1, String s2) 11 { 12 int i; 13 14 i = __builtin_memcmp(s1.str, s2.str, 15 (s1.len < s2.len ? s1.len : s2.len)); 16 if (i != 0) 17 return i; 18 19 if (s1.len < s2.len) 20 return -1; 21 else if (s1.len > s2.len) 22 return 1; 23 else 24 return 0; 25 } 26