aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-ffi.c
blob: 1ec5f87870cd64f7f605fe5bcef3f4d8d23efb49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/* go-ffi.c -- libffi support functions.

   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 <stdlib.h>

#include "runtime.h"

#ifdef USE_LIBFFI

#include "ffi.h"

/* The functions in this file are called by the Go runtime code to get
   the libffi type values.  */

ffi_type *go_ffi_type_pointer(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_pointer(void) __asm__ ("runtime.ffi__type__pointer");
ffi_type *go_ffi_type_sint8(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_sint8(void) __asm__ ("runtime.ffi__type__sint8");
ffi_type *go_ffi_type_sint16(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_sint16(void) __asm__ ("runtime.ffi__type__sint16");
ffi_type *go_ffi_type_sint32(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_sint32(void) __asm__ ("runtime.ffi__type__sint32");
ffi_type *go_ffi_type_sint64(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_sint64(void) __asm__ ("runtime.ffi__type__sint64");
ffi_type *go_ffi_type_uint8(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_uint8(void) __asm__ ("runtime.ffi__type__uint8");
ffi_type *go_ffi_type_uint16(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_uint16(void) __asm__ ("runtime.ffi__type__uint16");
ffi_type *go_ffi_type_uint32(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_uint32(void) __asm__ ("runtime.ffi__type__uint32");
ffi_type *go_ffi_type_uint64(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_uint64(void) __asm__ ("runtime.ffi__type__uint64");
ffi_type *go_ffi_type_float(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_float(void) __asm__ ("runtime.ffi__type__float");
ffi_type *go_ffi_type_double(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_double(void) __asm__ ("runtime.ffi__type__double");
ffi_type *go_ffi_type_complex_float(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_complex_float(void) __asm__ ("runtime.ffi__type__complex__float");
ffi_type *go_ffi_type_complex_double(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_complex_double(void) __asm__ ("runtime.ffi__type__complex__double");
ffi_type *go_ffi_type_void(void) __attribute__ ((no_split_stack));
ffi_type *go_ffi_type_void(void) __asm__ ("runtime.ffi__type__void");

_Bool go_ffi_supports_complex(void) __attribute__ ((no_split_stack));
_Bool go_ffi_supports_complex(void) __asm__ ("runtime.ffi__supports__complex");

ffi_type *
go_ffi_type_pointer(void)
{
	return &ffi_type_pointer;
}

ffi_type *
go_ffi_type_sint8(void)
{
	return &ffi_type_sint8;
}

ffi_type *
go_ffi_type_sint16(void)
{
	return &ffi_type_sint16;
}

ffi_type *
go_ffi_type_sint32(void)
{
	return &ffi_type_sint32;
}

ffi_type *
go_ffi_type_sint64(void)
{
	return &ffi_type_sint64;
}

ffi_type *
go_ffi_type_uint8(void)
{
	return &ffi_type_uint8;
}

ffi_type *
go_ffi_type_uint16(void)
{
	return &ffi_type_uint16;
}

ffi_type *
go_ffi_type_uint32(void)
{
	return &ffi_type_uint32;
}

ffi_type *
go_ffi_type_uint64(void)
{
	return &ffi_type_uint64;
}

ffi_type *
go_ffi_type_float(void)
{
	return &ffi_type_float;
}

ffi_type *
go_ffi_type_double(void)
{
	return &ffi_type_double;
}

_Bool
go_ffi_supports_complex(void)
{
#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
	return true;
#else
	return false;
#endif
}

ffi_type *
go_ffi_type_complex_float(void)
{
#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
	return &ffi_type_complex_float;
#else
	abort();
#endif
}

ffi_type *
go_ffi_type_complex_double(void)
{
#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
	return &ffi_type_complex_double;
#else
	abort();
#endif
}

ffi_type *
go_ffi_type_void(void)
{
	return &ffi_type_void;
}

#endif /* defined(USE_LIBFFI) */