go-eface-compare.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /* go-eface-compare.c -- compare two empty values.
  2. Copyright 2010 The Go Authors. All rights reserved.
  3. Use of this source code is governed by a BSD-style
  4. license that can be found in the LICENSE file. */
  5. #include "runtime.h"
  6. #include "go-type.h"
  7. #include "interface.h"
  8. /* Compare two interface values. Return 0 for equal, not zero for not
  9. equal (return value is like strcmp). */
  10. intgo
  11. __go_empty_interface_compare (struct __go_empty_interface left,
  12. struct __go_empty_interface right)
  13. {
  14. const struct __go_type_descriptor *left_descriptor;
  15. left_descriptor = left.__type_descriptor;
  16. if (left_descriptor == NULL && right.__type_descriptor == NULL)
  17. return 0;
  18. if (left_descriptor == NULL || right.__type_descriptor == NULL)
  19. return 1;
  20. if (!__go_type_descriptors_equal (left_descriptor,
  21. right.__type_descriptor))
  22. return 1;
  23. if (__go_is_pointer_type (left_descriptor))
  24. return left.__object == right.__object ? 0 : 1;
  25. if (!left_descriptor->__equalfn (left.__object, right.__object,
  26. left_descriptor->__size))
  27. return 1;
  28. return 0;
  29. }