2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / libgo / runtime / go-unsafe-pointer.c
blobb71804ac741d9feed2ad6fd50394d60fc08efc1c
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"
12 /* A pointer with a zero value. */
13 static void *zero_pointer;
15 /* This file provides the type descriptor for the unsafe.Pointer type.
16 The unsafe package is defined by the compiler itself, which means
17 that there is no package to compile to define the type
18 descriptor. */
20 extern const struct __go_type_descriptor unsafe_Pointer
21 __asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer");
23 /* Used to determine the field alignment. */
24 struct field_align
26 char c;
27 void *p;
30 /* The reflection string. */
31 #define REFLECTION "unsafe.Pointer"
32 static const String reflection_string =
34 (const byte *) REFLECTION,
35 sizeof REFLECTION - 1
38 const struct __go_type_descriptor unsafe_Pointer =
40 /* __code */
41 GO_UNSAFE_POINTER,
42 /* __align */
43 __alignof (void *),
44 /* __field_align */
45 offsetof (struct field_align, p) - 1,
46 /* __size */
47 sizeof (void *),
48 /* __hash */
49 78501163U,
50 /* __hashfn */
51 __go_type_hash_identity,
52 /* __equalfn */
53 __go_type_equal_identity,
54 /* __reflection */
55 &reflection_string,
56 /* __uncommon */
57 NULL,
58 /* __pointer_to_this */
59 NULL,
60 /* __zero */
61 &zero_pointer
64 /* We also need the type descriptor for the pointer to unsafe.Pointer,
65 since any package which refers to that type descriptor will expect
66 it to be defined elsewhere. */
68 extern const struct __go_ptr_type pointer_unsafe_Pointer
69 __asm__ (GOSYM_PREFIX "__go_td_pN14_unsafe.Pointer");
71 /* The reflection string. */
72 #define PREFLECTION "*unsafe.Pointer"
73 static const String preflection_string =
75 (const byte *) PREFLECTION,
76 sizeof PREFLECTION - 1,
79 const struct __go_ptr_type pointer_unsafe_Pointer =
81 /* __common */
83 /* __code */
84 GO_PTR,
85 /* __align */
86 __alignof (void *),
87 /* __field_align */
88 offsetof (struct field_align, p) - 1,
89 /* __size */
90 sizeof (void *),
91 /* __hash */
92 1256018616U,
93 /* __hashfn */
94 __go_type_hash_identity,
95 /* __equalfn */
96 __go_type_equal_identity,
97 /* __reflection */
98 &preflection_string,
99 /* __uncommon */
100 NULL,
101 /* __pointer_to_this */
102 NULL,
103 /* __zero */
104 &zero_pointer
106 /* __element_type */
107 &unsafe_Pointer