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. */
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
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
)
23 if (left
.__methods
== NULL
|| right
.__type_descriptor
== NULL
)
25 left_descriptor
= left
.__methods
[0];
26 if (!__go_type_descriptors_equal (left_descriptor
, right
.__type_descriptor
))
28 if (__go_is_pointer_type (left_descriptor
))
29 return left
.__object
== right
.__object
? 0 : 1;
30 if (!__go_call_equalfn (left_descriptor
->__equalfn
, left
.__object
,
31 right
.__object
, left_descriptor
->__size
))