OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [runtime/] [go-interface-eface-compare.c] - Blame information for rev 760

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
/* go-interface-eface-compare.c -- compare non-empty and empty interface.
2
 
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.  */
6
 
7
#include "runtime.h"
8
#include "interface.h"
9
 
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
12
   strcmp).  */
13
 
14
int
15
__go_interface_empty_compare (struct __go_interface left,
16
                              struct __go_empty_interface right)
17
{
18
  const struct __go_type_descriptor *left_descriptor;
19
 
20
  if (((uintptr_t) right.__type_descriptor & reflectFlags) != 0)
21
    runtime_panicstring ("invalid interface value");
22
  if (left.__methods == NULL && right.__type_descriptor == NULL)
23
    return 0;
24
  if (left.__methods == NULL || right.__type_descriptor == NULL)
25
    return 1;
26
  left_descriptor = left.__methods[0];
27
  if (!__go_type_descriptors_equal (left_descriptor, 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;
35
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.