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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
/* go-type-interface.c -- hash and equality interface functions.
2
 
3
   Copyright 2009 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 "interface.h"
8
#include "go-type.h"
9
 
10
/* A hash function for an interface.  */
11
 
12
uintptr_t
13
__go_type_hash_interface (const void *vval,
14
                          uintptr_t key_size __attribute__ ((unused)))
15
{
16
  const struct __go_interface *val;
17
  const struct __go_type_descriptor *descriptor;
18
  uintptr_t size;
19
 
20
  val = (const struct __go_interface *) vval;
21
  if (val->__methods == NULL)
22
    return 0;
23
  descriptor = (const struct __go_type_descriptor *) val->__methods[0];
24
  size = descriptor->__size;
25
  if (__go_is_pointer_type (descriptor))
26
    return descriptor->__hashfn (&val->__object, size);
27
  else
28
    return descriptor->__hashfn (val->__object, size);
29
}
30
 
31
/* An equality function for an interface.  */
32
 
33
_Bool
34
__go_type_equal_interface (const void *vv1, const void *vv2,
35
                           uintptr_t key_size __attribute__ ((unused)))
36
{
37
  const struct __go_interface *v1;
38
  const struct __go_interface *v2;
39
  const struct __go_type_descriptor* v1_descriptor;
40
  const struct __go_type_descriptor* v2_descriptor;
41
 
42
  v1 = (const struct __go_interface *) vv1;
43
  v2 = (const struct __go_interface *) vv2;
44
  if (v1->__methods == NULL || v2->__methods == NULL)
45
    return v1->__methods == v2->__methods;
46
  v1_descriptor = (const struct __go_type_descriptor *) v1->__methods[0];
47
  v2_descriptor = (const struct __go_type_descriptor *) v2->__methods[0];
48
  if (!__go_type_descriptors_equal (v1_descriptor, v2_descriptor))
49
    return 0;
50
  if (__go_is_pointer_type (v1_descriptor))
51
    return v1->__object == v2->__object;
52
  else
53
    return v1_descriptor->__equalfn (v1->__object, v2->__object,
54
                                     v1_descriptor->__size);
55
}

powered by: WebSVN 2.1.0

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