blob: ce82fcd4070638b1a1b0018a25357bd0b8fd791b [file] [log] [blame]
Peter Collingbourne594c10d2014-11-27 00:12:26 +00001/* 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#include "mgc0.h"
12
Peter Collingbourne594c10d2014-11-27 00:12:26 +000013/* 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. */
17
18extern const struct __go_type_descriptor unsafe_Pointer
19 __asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer");
20
21extern const uintptr unsafe_Pointer_gc[]
22 __asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer$gc");
23
24/* Used to determine the field alignment. */
25struct field_align
26{
27 char c;
28 void *p;
29};
30
31/* The reflection string. */
32#define REFLECTION "unsafe.Pointer"
33static const String reflection_string =
34{
35 (const byte *) REFLECTION,
36 sizeof REFLECTION - 1
37};
38
39const uintptr unsafe_Pointer_gc[] = {sizeof(void*), GC_APTR, 0, GC_END};
40
41const struct __go_type_descriptor unsafe_Pointer =
42{
43 /* __code */
Peter Collingbourne93c73eb2015-04-05 23:30:42 +000044 GO_UNSAFE_POINTER | GO_DIRECT_IFACE,
Peter Collingbourne594c10d2014-11-27 00:12:26 +000045 /* __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 */
Andrew Wilkins6436a4a2016-03-15 05:36:43 +000054 &__go_type_hash_identity_descriptor,
Peter Collingbourne594c10d2014-11-27 00:12:26 +000055 /* __equalfn */
Andrew Wilkins6436a4a2016-03-15 05:36:43 +000056 &__go_type_equal_identity_descriptor,
Peter Collingbourne594c10d2014-11-27 00:12:26 +000057 /* __gc */
58 unsafe_Pointer_gc,
59 /* __reflection */
60 &reflection_string,
61 /* __uncommon */
62 NULL,
63 /* __pointer_to_this */
Andrew Wilkins6436a4a2016-03-15 05:36:43 +000064 NULL
Peter Collingbourne594c10d2014-11-27 00:12:26 +000065};
66
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. */
70
71extern const struct __go_ptr_type pointer_unsafe_Pointer
72 __asm__ (GOSYM_PREFIX "__go_td_pN14_unsafe.Pointer");
73
74/* The reflection string. */
75#define PREFLECTION "*unsafe.Pointer"
76static const String preflection_string =
77{
78 (const byte *) PREFLECTION,
79 sizeof PREFLECTION - 1,
80};
81
82const struct __go_ptr_type pointer_unsafe_Pointer =
83{
84 /* __common */
85 {
86 /* __code */
Peter Collingbourne93c73eb2015-04-05 23:30:42 +000087 GO_PTR | GO_DIRECT_IFACE,
Peter Collingbourne594c10d2014-11-27 00:12:26 +000088 /* __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 */
Andrew Wilkins6436a4a2016-03-15 05:36:43 +000097 &__go_type_hash_identity_descriptor,
Peter Collingbourne594c10d2014-11-27 00:12:26 +000098 /* __equalfn */
Andrew Wilkins6436a4a2016-03-15 05:36:43 +000099 &__go_type_equal_identity_descriptor,
Peter Collingbourne594c10d2014-11-27 00:12:26 +0000100 /* __gc */
101 unsafe_Pointer_gc,
102 /* __reflection */
103 &preflection_string,
104 /* __uncommon */
105 NULL,
106 /* __pointer_to_this */
Andrew Wilkins6436a4a2016-03-15 05:36:43 +0000107 NULL
Peter Collingbourne594c10d2014-11-27 00:12:26 +0000108 },
109 /* __element_type */
110 &unsafe_Pointer
111};