2016-07-13 Thomas Preud'homme <thomas.preudhomme@arm.com>
[official-gcc.git] / libgo / runtime / go-unsafe-pointer.c
blobce82fcd4070638b1a1b0018a25357bd0b8fd791b
1 /* go-unsafe-pointer.c -- unsafe.Pointer type descriptor for Go.
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. */
7 #include <stddef.h>
9 #include "runtime.h"
10 #include "go-type.h"
11 #include "mgc0.h"
13 /* This file provides the type descriptor for the unsafe.Pointer type.
14 The unsafe package is defined by the compiler itself, which means
15 that there is no package to compile to define the type
16 descriptor. */
18 extern const struct __go_type_descriptor unsafe_Pointer
19 __asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer");
21 extern const uintptr unsafe_Pointer_gc[]
22 __asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer$gc");
24 /* Used to determine the field alignment. */
25 struct field_align
27 char c;
28 void *p;
31 /* The reflection string. */
32 #define REFLECTION "unsafe.Pointer"
33 static const String reflection_string =
35 (const byte *) REFLECTION,
36 sizeof REFLECTION - 1
39 const uintptr unsafe_Pointer_gc[] = {sizeof(void*), GC_APTR, 0, GC_END};
41 const struct __go_type_descriptor unsafe_Pointer =
43 /* __code */
44 GO_UNSAFE_POINTER | GO_DIRECT_IFACE,
45 /* __align */
46 __alignof (void *),
47 /* __field_align */
48 offsetof (struct field_align, p) - 1,
49 /* __size */
50 sizeof (void *),
51 /* __hash */
52 78501163U,
53 /* __hashfn */
54 &__go_type_hash_identity_descriptor,
55 /* __equalfn */
56 &__go_type_equal_identity_descriptor,
57 /* __gc */
58 unsafe_Pointer_gc,
59 /* __reflection */
60 &reflection_string,
61 /* __uncommon */
62 NULL,
63 /* __pointer_to_this */
64 NULL
67 /* We also need the type descriptor for the pointer to unsafe.Pointer,
68 since any package which refers to that type descriptor will expect
69 it to be defined elsewhere. */
71 extern const struct __go_ptr_type pointer_unsafe_Pointer
72 __asm__ (GOSYM_PREFIX "__go_td_pN14_unsafe.Pointer");
74 /* The reflection string. */
75 #define PREFLECTION "*unsafe.Pointer"
76 static const String preflection_string =
78 (const byte *) PREFLECTION,
79 sizeof PREFLECTION - 1,
82 const struct __go_ptr_type pointer_unsafe_Pointer =
84 /* __common */
86 /* __code */
87 GO_PTR | GO_DIRECT_IFACE,
88 /* __align */
89 __alignof (void *),
90 /* __field_align */
91 offsetof (struct field_align, p) - 1,
92 /* __size */
93 sizeof (void *),
94 /* __hash */
95 1256018616U,
96 /* __hashfn */
97 &__go_type_hash_identity_descriptor,
98 /* __equalfn */
99 &__go_type_equal_identity_descriptor,
100 /* __gc */
101 unsafe_Pointer_gc,
102 /* __reflection */
103 &preflection_string,
104 /* __uncommon */
105 NULL,
106 /* __pointer_to_this */
107 NULL
109 /* __element_type */
110 &unsafe_Pointer