annotate libgo/runtime/go-typedesc-equal.c @ 136:4627f235cf2a

fix c-next example
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:11:56 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* go-typedesc-equal.c -- return whether two type descriptors are equal.
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 Copyright 2009 The Go Authors. All rights reserved.
kono
parents:
diff changeset
4 Use of this source code is governed by a BSD-style
kono
parents:
diff changeset
5 license that can be found in the LICENSE file. */
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 #include "runtime.h"
kono
parents:
diff changeset
8 #include "go-string.h"
kono
parents:
diff changeset
9 #include "go-type.h"
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 /* Compare type descriptors for equality. This is necessary because
kono
parents:
diff changeset
12 types may have different descriptors in different shared libraries.
kono
parents:
diff changeset
13 Also, unnamed types may have multiple type descriptors even in a
kono
parents:
diff changeset
14 single shared library. */
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 _Bool
kono
parents:
diff changeset
17 __go_type_descriptors_equal (const struct __go_type_descriptor *td1,
kono
parents:
diff changeset
18 const struct __go_type_descriptor *td2)
kono
parents:
diff changeset
19 {
kono
parents:
diff changeset
20 if (td1 == td2)
kono
parents:
diff changeset
21 return 1;
kono
parents:
diff changeset
22 /* In a type switch we can get a NULL descriptor. */
kono
parents:
diff changeset
23 if (td1 == NULL || td2 == NULL)
kono
parents:
diff changeset
24 return 0;
kono
parents:
diff changeset
25 if (td1->__code != td2->__code || td1->__hash != td2->__hash)
kono
parents:
diff changeset
26 return 0;
kono
parents:
diff changeset
27 return __go_ptr_strings_equal (td1->__reflection, td2->__reflection);
kono
parents:
diff changeset
28 }