github.com/llvm-mirror/llgo@v0.0.0-20190322182713-bf6f0a60fce1/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  /* 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  
    18  extern const struct __go_type_descriptor unsafe_Pointer
    19    __asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer");
    20  
    21  extern const uintptr unsafe_Pointer_gc[]
    22    __asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer$gc");
    23  
    24  /* Used to determine the field alignment.  */
    25  struct field_align
    26  {
    27    char c;
    28    void *p;
    29  };
    30  
    31  /* The reflection string.  */
    32  #define REFLECTION "unsafe.Pointer"
    33  static const String reflection_string =
    34  {
    35    (const byte *) REFLECTION,
    36    sizeof REFLECTION - 1
    37  };
    38  
    39  const uintptr unsafe_Pointer_gc[] = {sizeof(void*), GC_APTR, 0, GC_END};
    40  
    41  const struct __go_type_descriptor unsafe_Pointer =
    42  {
    43    /* __code */
    44    GO_UNSAFE_POINTER | GO_DIRECT_IFACE,
    45    /* __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 */
    54    &__go_type_hash_identity_descriptor,
    55    /* __equalfn */
    56    &__go_type_equal_identity_descriptor,
    57    /* __gc */
    58    unsafe_Pointer_gc,
    59    /* __reflection */
    60    &reflection_string,
    61    /* __uncommon */
    62    NULL,
    63    /* __pointer_to_this */
    64    NULL
    65  };
    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  
    71  extern 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"
    76  static const String preflection_string =
    77  {
    78    (const byte *) PREFLECTION,
    79    sizeof PREFLECTION - 1,
    80  };
    81  
    82  const struct __go_ptr_type pointer_unsafe_Pointer =
    83  {
    84    /* __common */
    85    {
    86      /* __code */
    87      GO_PTR | GO_DIRECT_IFACE,
    88      /* __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 */
    97      &__go_type_hash_identity_descriptor,
    98      /* __equalfn */
    99      &__go_type_equal_identity_descriptor,
   100      /* __gc */
   101      unsafe_Pointer_gc,
   102      /* __reflection */
   103      &preflection_string,
   104      /* __uncommon */
   105      NULL,
   106      /* __pointer_to_this */
   107      NULL
   108    },
   109    /* __element_type */
   110    &unsafe_Pointer
   111  };