re PR c++/64514 (Error in template instantiation in GCC 4.9, works fine in GCC 4.8)
[official-gcc.git] / libgo / runtime / go-eface-compare.c
blob3555a65d9ccbe77a5961c081c80807ed74004351
1 /* go-eface-compare.c -- compare two empty values.
3 Copyright 2010 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 two interface values. Return 0 for equal, not zero for not
12 equal (return value is like strcmp). */
14 intgo
15 __go_empty_interface_compare (struct __go_empty_interface left,
16 struct __go_empty_interface right)
18 const struct __go_type_descriptor *left_descriptor;
20 left_descriptor = left.__type_descriptor;
22 if (left_descriptor == NULL && right.__type_descriptor == NULL)
23 return 0;
24 if (left_descriptor == NULL || right.__type_descriptor == NULL)
25 return 1;
26 if (!__go_type_descriptors_equal (left_descriptor,
27 right.__type_descriptor))
28 return 1;
29 if (__go_is_pointer_type (left_descriptor))
30 return left.__object == right.__object ? 0 : 1;
31 if (!left_descriptor->__equalfn (left.__object, right.__object,
32 left_descriptor->__size))
33 return 1;
34 return 0;