PR tree-optimization/65984
[official-gcc.git] / libgo / runtime / go-strcmp.c
blobbcc270bf8a57b0b56f9ba0f4549bde80a705e6c5
1 /* go-strcmp.c -- the go string comparison function.
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. */
7 #include "runtime.h"
9 intgo
10 __go_strcmp(String s1, String s2)
12 int i;
14 i = __builtin_memcmp(s1.str, s2.str,
15 (s1.len < s2.len ? s1.len : s2.len));
16 if (i != 0)
17 return i;
19 if (s1.len < s2.len)
20 return -1;
21 else if (s1.len > s2.len)
22 return 1;
23 else
24 return 0;