Peter Collingbourne | 594c10d | 2014-11-27 00:12:26 +0000 | [diff] [blame] | 1 | /* go-eface-compare.c -- compare two empty values. |
| 2 | |
| 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. */ |
| 6 | |
| 7 | #include "runtime.h" |
| 8 | #include "go-type.h" |
| 9 | #include "interface.h" |
| 10 | |
| 11 | /* Compare two interface values. Return 0 for equal, not zero for not |
| 12 | equal (return value is like strcmp). */ |
| 13 | |
| 14 | intgo |
| 15 | __go_empty_interface_compare (struct __go_empty_interface left, |
| 16 | struct __go_empty_interface right) |
| 17 | { |
| 18 | const struct __go_type_descriptor *left_descriptor; |
| 19 | |
| 20 | left_descriptor = left.__type_descriptor; |
| 21 | |
| 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; |
Andrew Wilkins | 6436a4a | 2016-03-15 05:36:43 +0000 | [diff] [blame] | 31 | if (!__go_call_equalfn (left_descriptor->__equalfn, left.__object, |
| 32 | right.__object, left_descriptor->__size)) |
Peter Collingbourne | 594c10d | 2014-11-27 00:12:26 +0000 | [diff] [blame] | 33 | return 1; |
| 34 | return 0; |
| 35 | } |