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. */
10 /* Compare a non-empty interface value with an empty interface value.
11 Return 0 for equal, not zero for not equal (return value is like
15 __go_interface_empty_compare (struct __go_interface left
,
16 struct __go_empty_interface right
)
18 const struct __go_type_descriptor
*left_descriptor
;
20 if (((uintptr_t) right
.__type_descriptor
& reflectFlags
) != 0)
21 runtime_panicstring ("invalid interface value");
22 if (left
.__methods
== NULL
&& right
.__type_descriptor
== NULL
)
24 if (left
.__methods
== NULL
|| right
.__type_descriptor
== NULL
)
26 left_descriptor
= left
.__methods
[0];
27 if (!__go_type_descriptors_equal (left_descriptor
, right
.__type_descriptor
))
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
))