2012-01-13 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / libgo / runtime / go-unsafe-pointer.c
blob9ec18003f1f57e2ca27bcbaacb343baff6b92335
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 "go-string.h"
10 #include "go-type.h"
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. */
17 extern const struct __go_type_descriptor unsafe_Pointer
18 asm ("__go_tdn_libgo_unsafe.unsafe.Pointer");
20 /* Used to determine the field alignment. */
21 struct field_align
23 char c;
24 void *p;
27 /* The reflection string. */
28 #define REFLECTION "unsafe.Pointer"
29 static const struct __go_string reflection_string =
31 (const unsigned char *) REFLECTION,
32 sizeof REFLECTION - 1
35 const struct __go_type_descriptor unsafe_Pointer =
37 /* __code */
38 GO_UNSAFE_POINTER,
39 /* __align */
40 __alignof (void *),
41 /* __field_align */
42 offsetof (struct field_align, p) - 1,
43 /* __size */
44 sizeof (void *),
45 /* __hash */
46 78501163U,
47 /* __hashfn */
48 __go_type_hash_identity,
49 /* __equalfn */
50 __go_type_equal_identity,
51 /* __reflection */
52 &reflection_string,
53 /* __uncommon */
54 NULL,
55 /* __pointer_to_this */
56 NULL
59 /* We also need the type descriptor for the pointer to unsafe.Pointer,
60 since any package which refers to that type descriptor will expect
61 it to be defined elsewhere. */
63 extern const struct __go_ptr_type pointer_unsafe_Pointer
64 asm ("__go_td_pN27_libgo_unsafe.unsafe.Pointer");
66 /* The reflection string. */
67 #define PREFLECTION "*unsafe.Pointer"
68 static const struct __go_string preflection_string =
70 (const unsigned char *) PREFLECTION,
71 sizeof PREFLECTION - 1,
74 const struct __go_ptr_type pointer_unsafe_Pointer =
76 /* __common */
78 /* __code */
79 GO_PTR,
80 /* __align */
81 __alignof (void *),
82 /* __field_align */
83 offsetof (struct field_align, p) - 1,
84 /* __size */
85 sizeof (void *),
86 /* __hash */
87 1256018616U,
88 /* __hashfn */
89 __go_type_hash_identity,
90 /* __equalfn */
91 __go_type_equal_identity,
92 /* __reflection */
93 &preflection_string,
94 /* __uncommon */
95 NULL,
96 /* __pointer_to_this */
97 NULL
99 /* __element_type */
100 &unsafe_Pointer