OSDN Git Service

mn10300: Add attribute enabled.
[pf3gnuchains/gcc-fork.git] / libgo / runtime / go-unsafe-pointer.c
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 "go-string.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
18   asm ("__go_tdn_libgo_unsafe.unsafe.Pointer");
19
20 /* Used to determine the field alignment.  */
21 struct field_align
22 {
23   char c;
24   void *p;
25 };
26
27 /* The reflection string.  */
28 #define REFLECTION "unsafe.Pointer"
29 static const struct __go_string reflection_string =
30 {
31   (const unsigned char *) REFLECTION,
32   sizeof REFLECTION - 1
33 };
34
35 const struct __go_type_descriptor unsafe_Pointer =
36 {
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 };
56
57 /* We also need the type descriptor for the pointer to unsafe.Pointer,
58    since any package which refers to that type descriptor will expect
59    it to be defined elsewhere.  */
60
61 extern const struct __go_ptr_type pointer_unsafe_Pointer
62   asm ("__go_td_pN27_libgo_unsafe.unsafe.Pointer");
63
64 /* The reflection string.  */
65 #define PREFLECTION "*unsafe.Pointer"
66 static const struct __go_string preflection_string =
67 {
68   (const unsigned char *) PREFLECTION,
69   sizeof PREFLECTION - 1,
70 };
71
72 const struct __go_ptr_type pointer_unsafe_Pointer =
73 {
74   /* __common */
75   {
76     /* __code */
77     GO_PTR,
78     /* __align */
79     __alignof (void *),
80     /* __field_align */
81     offsetof (struct field_align, p) - 1,
82     /* __size */
83     sizeof (void *),
84     /* __hash */
85     1256018616U,
86     /* __hashfn */
87     __go_type_hash_identity,
88     /* __equalfn */
89     __go_type_equal_identity,
90     /* __reflection */
91     &preflection_string,
92     /* __uncommon */
93     NULL
94   },
95   /* __element_type */
96   &unsafe_Pointer
97 };