111
|
1 /* go-unsafe-pointer.c -- unsafe.Pointer type descriptor for Go.
|
|
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 <stddef.h>
|
|
8
|
|
9 #include "runtime.h"
|
|
10 #include "go-type.h"
|
|
11
|
|
12 /* This file provides the type descriptor for the unsafe.Pointer type.
|
|
13 The unsafe package is defined by the compiler itself, which means
|
|
14 that there is no package to compile to define the type
|
|
15 descriptor. */
|
|
16
|
|
17 extern const struct __go_type_descriptor unsafe_Pointer
|
131
|
18 __asm__ (GOSYM_PREFIX "unsafe.Pointer..d");
|
111
|
19
|
|
20 extern const byte unsafe_Pointer_gc[]
|
131
|
21 __asm__ (GOSYM_PREFIX "unsafe.Pointer..g");
|
111
|
22
|
|
23 /* Used to determine the field alignment. */
|
|
24 struct field_align
|
|
25 {
|
|
26 char c;
|
|
27 void *p;
|
|
28 };
|
|
29
|
|
30 /* The reflection string. */
|
|
31 #define REFLECTION "unsafe.Pointer"
|
|
32 static const String reflection_string =
|
|
33 {
|
|
34 (const byte *) REFLECTION,
|
|
35 sizeof REFLECTION - 1
|
|
36 };
|
|
37
|
|
38 const byte unsafe_Pointer_gc[] = { 1 };
|
|
39
|
|
40 extern const FuncVal runtime_pointerhash_descriptor
|
131
|
41 __asm__ (GOSYM_PREFIX "runtime.pointerhash..f");
|
111
|
42 extern const FuncVal runtime_pointerequal_descriptor
|
131
|
43 __asm__ (GOSYM_PREFIX "runtime.pointerequal..f");
|
111
|
44
|
|
45 const struct __go_type_descriptor unsafe_Pointer =
|
|
46 {
|
|
47 /* __size */
|
|
48 sizeof (void *),
|
|
49 /* __ptrdata */
|
|
50 sizeof (void *),
|
|
51 /* __hash */
|
|
52 78501163U,
|
|
53 /* __code */
|
|
54 GO_UNSAFE_POINTER | GO_DIRECT_IFACE,
|
|
55 /* __align */
|
|
56 __alignof (void *),
|
|
57 /* __field_align */
|
|
58 offsetof (struct field_align, p) - 1,
|
|
59 /* __hashfn */
|
|
60 &runtime_pointerhash_descriptor,
|
|
61 /* __equalfn */
|
|
62 &runtime_pointerequal_descriptor,
|
|
63 /* __gcdata */
|
|
64 unsafe_Pointer_gc,
|
|
65 /* __reflection */
|
|
66 &reflection_string,
|
|
67 /* __uncommon */
|
|
68 NULL,
|
|
69 /* __pointer_to_this */
|
|
70 NULL
|
|
71 };
|
|
72
|
|
73 /* We also need the type descriptor for the pointer to unsafe.Pointer,
|
|
74 since any package which refers to that type descriptor will expect
|
|
75 it to be defined elsewhere. */
|
|
76
|
|
77 extern const struct __go_ptr_type pointer_unsafe_Pointer
|
131
|
78 __asm__ (GOSYM_PREFIX "type...1unsafe.Pointer");
|
111
|
79
|
|
80 /* The reflection string. */
|
|
81 #define PREFLECTION "*unsafe.Pointer"
|
|
82 static const String preflection_string =
|
|
83 {
|
|
84 (const byte *) PREFLECTION,
|
|
85 sizeof PREFLECTION - 1,
|
|
86 };
|
|
87
|
|
88 extern const byte pointer_unsafe_Pointer_gc[]
|
131
|
89 __asm__ (GOSYM_PREFIX "type...1unsafe.Pointer..g");
|
111
|
90
|
|
91 const byte pointer_unsafe_Pointer_gc[] = { 1 };
|
|
92
|
|
93 const struct __go_ptr_type pointer_unsafe_Pointer =
|
|
94 {
|
|
95 /* __common */
|
|
96 {
|
|
97 /* __size */
|
|
98 sizeof (void *),
|
|
99 /* __ptrdata */
|
|
100 sizeof (void *),
|
|
101 /* __hash */
|
|
102 1256018616U,
|
|
103 /* __code */
|
|
104 GO_PTR | GO_DIRECT_IFACE,
|
|
105 /* __align */
|
|
106 __alignof (void *),
|
|
107 /* __field_align */
|
|
108 offsetof (struct field_align, p) - 1,
|
|
109 /* __hashfn */
|
|
110 &runtime_pointerhash_descriptor,
|
|
111 /* __equalfn */
|
|
112 &runtime_pointerequal_descriptor,
|
|
113 /* __gcdata */
|
|
114 pointer_unsafe_Pointer_gc,
|
|
115 /* __reflection */
|
|
116 &preflection_string,
|
|
117 /* __uncommon */
|
|
118 NULL,
|
|
119 /* __pointer_to_this */
|
|
120 NULL
|
|
121 },
|
|
122 /* __element_type */
|
|
123 &unsafe_Pointer
|
|
124 };
|