* testsuite/libgomp.c/examples-4/e.53.5.c: Require
[official-gcc.git] / libgo / runtime / go-interface-eface-compare.c
bloba38917fd0c6d60bdedd59a8571f145fed3f92b55
1 /* go-interface-eface-compare.c -- compare non-empty and empty interface.
3 Copyright 2011 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"
8 #include "go-type.h"
9 #include "interface.h"
11 /* Compare a non-empty interface value with an empty interface value.
12 Return 0 for equal, not zero for not equal (return value is like
13 strcmp). */
15 intgo
16 __go_interface_empty_compare (struct __go_interface left,
17 struct __go_empty_interface right)
19 const struct __go_type_descriptor *left_descriptor;
21 if (left.__methods == NULL && right.__type_descriptor == NULL)
22 return 0;
23 if (left.__methods == NULL || right.__type_descriptor == NULL)
24 return 1;
25 left_descriptor = left.__methods[0];
26 if (!__go_type_descriptors_equal (left_descriptor, right.__type_descriptor))
27 return 1;
28 if (__go_is_pointer_type (left_descriptor))
29 return left.__object == right.__object ? 0 : 1;
30 if (!left_descriptor->__equalfn (left.__object, right.__object,
31 left_descriptor->__size))
32 return 1;
33 return 0;