2010-12-03 05:34:57 +01:00
|
|
|
/* go-unsafe-pointer.c -- unsafe.Pointer type descriptor for Go.
|
|
|
|
|
|
|
|
Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
Use of this source code is governed by a BSD-style
|
|
|
|
license that can be found in the LICENSE file. */
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2012-11-01 04:02:13 +01:00
|
|
|
#include "runtime.h"
|
2010-12-03 05:34:57 +01:00
|
|
|
#include "go-type.h"
|
2014-09-04 00:56:09 +02:00
|
|
|
#include "mgc0.h"
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
/* This file provides the type descriptor for the unsafe.Pointer type.
|
|
|
|
The unsafe package is defined by the compiler itself, which means
|
|
|
|
that there is no package to compile to define the type
|
|
|
|
descriptor. */
|
|
|
|
|
|
|
|
extern const struct __go_type_descriptor unsafe_Pointer
|
2013-01-24 20:44:23 +01:00
|
|
|
__asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer");
|
2010-12-03 05:34:57 +01:00
|
|
|
|
2014-09-04 00:56:09 +02:00
|
|
|
extern const uintptr unsafe_Pointer_gc[]
|
|
|
|
__asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer$gc");
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
/* Used to determine the field alignment. */
|
|
|
|
struct field_align
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
void *p;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The reflection string. */
|
|
|
|
#define REFLECTION "unsafe.Pointer"
|
2012-11-01 04:02:13 +01:00
|
|
|
static const String reflection_string =
|
2010-12-03 05:34:57 +01:00
|
|
|
{
|
2012-11-01 04:02:13 +01:00
|
|
|
(const byte *) REFLECTION,
|
2010-12-03 05:34:57 +01:00
|
|
|
sizeof REFLECTION - 1
|
|
|
|
};
|
|
|
|
|
2014-09-05 16:43:24 +02:00
|
|
|
const uintptr unsafe_Pointer_gc[] = {sizeof(void*), GC_APTR, 0, GC_END};
|
2014-09-04 00:56:09 +02:00
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
const struct __go_type_descriptor unsafe_Pointer =
|
|
|
|
{
|
|
|
|
/* __code */
|
2015-01-15 01:27:56 +01:00
|
|
|
GO_UNSAFE_POINTER | GO_DIRECT_IFACE,
|
2010-12-03 05:34:57 +01:00
|
|
|
/* __align */
|
|
|
|
__alignof (void *),
|
|
|
|
/* __field_align */
|
|
|
|
offsetof (struct field_align, p) - 1,
|
|
|
|
/* __size */
|
|
|
|
sizeof (void *),
|
|
|
|
/* __hash */
|
|
|
|
78501163U,
|
|
|
|
/* __hashfn */
|
2015-10-29 18:14:51 +01:00
|
|
|
&__go_type_hash_identity_descriptor,
|
2010-12-03 05:34:57 +01:00
|
|
|
/* __equalfn */
|
2015-10-29 18:14:51 +01:00
|
|
|
&__go_type_equal_identity_descriptor,
|
2014-09-04 00:56:09 +02:00
|
|
|
/* __gc */
|
|
|
|
unsafe_Pointer_gc,
|
2010-12-03 05:34:57 +01:00
|
|
|
/* __reflection */
|
|
|
|
&reflection_string,
|
|
|
|
/* __uncommon */
|
2011-03-17 00:05:44 +01:00
|
|
|
NULL,
|
|
|
|
/* __pointer_to_this */
|
2015-10-29 19:14:50 +01:00
|
|
|
NULL
|
2010-12-03 05:34:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* We also need the type descriptor for the pointer to unsafe.Pointer,
|
|
|
|
since any package which refers to that type descriptor will expect
|
|
|
|
it to be defined elsewhere. */
|
|
|
|
|
|
|
|
extern const struct __go_ptr_type pointer_unsafe_Pointer
|
2013-01-24 20:44:23 +01:00
|
|
|
__asm__ (GOSYM_PREFIX "__go_td_pN14_unsafe.Pointer");
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
/* The reflection string. */
|
|
|
|
#define PREFLECTION "*unsafe.Pointer"
|
2012-11-01 04:02:13 +01:00
|
|
|
static const String preflection_string =
|
2010-12-03 05:34:57 +01:00
|
|
|
{
|
2012-11-01 04:02:13 +01:00
|
|
|
(const byte *) PREFLECTION,
|
2010-12-03 05:34:57 +01:00
|
|
|
sizeof PREFLECTION - 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct __go_ptr_type pointer_unsafe_Pointer =
|
|
|
|
{
|
|
|
|
/* __common */
|
|
|
|
{
|
|
|
|
/* __code */
|
2015-01-15 01:27:56 +01:00
|
|
|
GO_PTR | GO_DIRECT_IFACE,
|
2010-12-03 05:34:57 +01:00
|
|
|
/* __align */
|
|
|
|
__alignof (void *),
|
|
|
|
/* __field_align */
|
|
|
|
offsetof (struct field_align, p) - 1,
|
|
|
|
/* __size */
|
|
|
|
sizeof (void *),
|
|
|
|
/* __hash */
|
|
|
|
1256018616U,
|
|
|
|
/* __hashfn */
|
2015-10-29 18:14:51 +01:00
|
|
|
&__go_type_hash_identity_descriptor,
|
2010-12-03 05:34:57 +01:00
|
|
|
/* __equalfn */
|
2015-10-29 18:14:51 +01:00
|
|
|
&__go_type_equal_identity_descriptor,
|
2014-09-04 00:56:09 +02:00
|
|
|
/* __gc */
|
|
|
|
unsafe_Pointer_gc,
|
2010-12-03 05:34:57 +01:00
|
|
|
/* __reflection */
|
|
|
|
&preflection_string,
|
|
|
|
/* __uncommon */
|
2011-03-17 00:05:44 +01:00
|
|
|
NULL,
|
|
|
|
/* __pointer_to_this */
|
2015-10-29 19:14:50 +01:00
|
|
|
NULL
|
2010-12-03 05:34:57 +01:00
|
|
|
},
|
|
|
|
/* __element_type */
|
|
|
|
&unsafe_Pointer
|
|
|
|
};
|