github.com/prattmic/llgo-embedded@v0.0.0-20150820070356-41cfecea0e1e/third_party/gofrontend/libgo/runtime/go-unsafe-pointer.c (about) 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 #include "mgc0.h" 12 13 /* A pointer with a zero value. */ 14 static void *zero_pointer; 15 16 /* This file provides the type descriptor for the unsafe.Pointer type. 17 The unsafe package is defined by the compiler itself, which means 18 that there is no package to compile to define the type 19 descriptor. */ 20 21 extern const struct __go_type_descriptor unsafe_Pointer 22 __asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer"); 23 24 extern const uintptr unsafe_Pointer_gc[] 25 __asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer$gc"); 26 27 /* Used to determine the field alignment. */ 28 struct field_align 29 { 30 char c; 31 void *p; 32 }; 33 34 /* The reflection string. */ 35 #define REFLECTION "unsafe.Pointer" 36 static const String reflection_string = 37 { 38 (const byte *) REFLECTION, 39 sizeof REFLECTION - 1 40 }; 41 42 const uintptr unsafe_Pointer_gc[] = {sizeof(void*), GC_APTR, 0, GC_END}; 43 44 const struct __go_type_descriptor unsafe_Pointer = 45 { 46 /* __code */ 47 GO_UNSAFE_POINTER | GO_DIRECT_IFACE, 48 /* __align */ 49 __alignof (void *), 50 /* __field_align */ 51 offsetof (struct field_align, p) - 1, 52 /* __size */ 53 sizeof (void *), 54 /* __hash */ 55 78501163U, 56 /* __hashfn */ 57 __go_type_hash_identity, 58 /* __equalfn */ 59 __go_type_equal_identity, 60 /* __gc */ 61 unsafe_Pointer_gc, 62 /* __reflection */ 63 &reflection_string, 64 /* __uncommon */ 65 NULL, 66 /* __pointer_to_this */ 67 NULL, 68 /* __zero */ 69 &zero_pointer 70 }; 71 72 /* We also need the type descriptor for the pointer to unsafe.Pointer, 73 since any package which refers to that type descriptor will expect 74 it to be defined elsewhere. */ 75 76 extern const struct __go_ptr_type pointer_unsafe_Pointer 77 __asm__ (GOSYM_PREFIX "__go_td_pN14_unsafe.Pointer"); 78 79 /* The reflection string. */ 80 #define PREFLECTION "*unsafe.Pointer" 81 static const String preflection_string = 82 { 83 (const byte *) PREFLECTION, 84 sizeof PREFLECTION - 1, 85 }; 86 87 const struct __go_ptr_type pointer_unsafe_Pointer = 88 { 89 /* __common */ 90 { 91 /* __code */ 92 GO_PTR | GO_DIRECT_IFACE, 93 /* __align */ 94 __alignof (void *), 95 /* __field_align */ 96 offsetof (struct field_align, p) - 1, 97 /* __size */ 98 sizeof (void *), 99 /* __hash */ 100 1256018616U, 101 /* __hashfn */ 102 __go_type_hash_identity, 103 /* __equalfn */ 104 __go_type_equal_identity, 105 /* __gc */ 106 unsafe_Pointer_gc, 107 /* __reflection */ 108 &preflection_string, 109 /* __uncommon */ 110 NULL, 111 /* __pointer_to_this */ 112 NULL, 113 /* __zero */ 114 &zero_pointer 115 }, 116 /* __element_type */ 117 &unsafe_Pointer 118 };