]>
Commit | Line | Data |
---|---|---|
5302cd02 | 1 | /* go-ffi.c -- libffi support functions. |
dffa7328 ILT |
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 | ||
dffa7328 ILT |
7 | #include <stdlib.h> |
8 | ||
9 | #include "runtime.h" | |
dffa7328 ILT |
10 | |
11 | #ifdef USE_LIBFFI | |
12 | ||
13 | #include "ffi.h" | |
14 | ||
5302cd02 ILT |
15 | /* The functions in this file are called by the Go runtime code to get |
16 | the libffi type values. */ | |
17 | ||
18 | ffi_type *go_ffi_type_pointer(void) __attribute__ ((no_split_stack)); | |
a01dda3c | 19 | ffi_type *go_ffi_type_pointer(void) __asm__ ("runtime.ffi__type__pointer"); |
5302cd02 | 20 | ffi_type *go_ffi_type_sint8(void) __attribute__ ((no_split_stack)); |
a01dda3c | 21 | ffi_type *go_ffi_type_sint8(void) __asm__ ("runtime.ffi__type__sint8"); |
5302cd02 | 22 | ffi_type *go_ffi_type_sint16(void) __attribute__ ((no_split_stack)); |
a01dda3c | 23 | ffi_type *go_ffi_type_sint16(void) __asm__ ("runtime.ffi__type__sint16"); |
5302cd02 | 24 | ffi_type *go_ffi_type_sint32(void) __attribute__ ((no_split_stack)); |
a01dda3c | 25 | ffi_type *go_ffi_type_sint32(void) __asm__ ("runtime.ffi__type__sint32"); |
5302cd02 | 26 | ffi_type *go_ffi_type_sint64(void) __attribute__ ((no_split_stack)); |
a01dda3c | 27 | ffi_type *go_ffi_type_sint64(void) __asm__ ("runtime.ffi__type__sint64"); |
5302cd02 | 28 | ffi_type *go_ffi_type_uint8(void) __attribute__ ((no_split_stack)); |
a01dda3c | 29 | ffi_type *go_ffi_type_uint8(void) __asm__ ("runtime.ffi__type__uint8"); |
5302cd02 | 30 | ffi_type *go_ffi_type_uint16(void) __attribute__ ((no_split_stack)); |
a01dda3c | 31 | ffi_type *go_ffi_type_uint16(void) __asm__ ("runtime.ffi__type__uint16"); |
5302cd02 | 32 | ffi_type *go_ffi_type_uint32(void) __attribute__ ((no_split_stack)); |
a01dda3c | 33 | ffi_type *go_ffi_type_uint32(void) __asm__ ("runtime.ffi__type__uint32"); |
5302cd02 | 34 | ffi_type *go_ffi_type_uint64(void) __attribute__ ((no_split_stack)); |
a01dda3c | 35 | ffi_type *go_ffi_type_uint64(void) __asm__ ("runtime.ffi__type__uint64"); |
5302cd02 | 36 | ffi_type *go_ffi_type_float(void) __attribute__ ((no_split_stack)); |
a01dda3c | 37 | ffi_type *go_ffi_type_float(void) __asm__ ("runtime.ffi__type__float"); |
5302cd02 | 38 | ffi_type *go_ffi_type_double(void) __attribute__ ((no_split_stack)); |
a01dda3c | 39 | ffi_type *go_ffi_type_double(void) __asm__ ("runtime.ffi__type__double"); |
5302cd02 | 40 | ffi_type *go_ffi_type_complex_float(void) __attribute__ ((no_split_stack)); |
a01dda3c | 41 | ffi_type *go_ffi_type_complex_float(void) __asm__ ("runtime.ffi__type__complex__float"); |
5302cd02 | 42 | ffi_type *go_ffi_type_complex_double(void) __attribute__ ((no_split_stack)); |
a01dda3c | 43 | ffi_type *go_ffi_type_complex_double(void) __asm__ ("runtime.ffi__type__complex__double"); |
5302cd02 | 44 | ffi_type *go_ffi_type_void(void) __attribute__ ((no_split_stack)); |
a01dda3c | 45 | ffi_type *go_ffi_type_void(void) __asm__ ("runtime.ffi__type__void"); |
5302cd02 ILT |
46 | |
47 | _Bool go_ffi_supports_complex(void) __attribute__ ((no_split_stack)); | |
a01dda3c | 48 | _Bool go_ffi_supports_complex(void) __asm__ ("runtime.ffi__supports__complex"); |
5302cd02 ILT |
49 | |
50 | ffi_type * | |
51 | go_ffi_type_pointer(void) | |
dffa7328 | 52 | { |
5302cd02 | 53 | return &ffi_type_pointer; |
dffa7328 ILT |
54 | } |
55 | ||
5302cd02 ILT |
56 | ffi_type * |
57 | go_ffi_type_sint8(void) | |
dffa7328 | 58 | { |
5302cd02 | 59 | return &ffi_type_sint8; |
dffa7328 ILT |
60 | } |
61 | ||
5302cd02 ILT |
62 | ffi_type * |
63 | go_ffi_type_sint16(void) | |
dffa7328 | 64 | { |
5302cd02 | 65 | return &ffi_type_sint16; |
dffa7328 ILT |
66 | } |
67 | ||
5302cd02 ILT |
68 | ffi_type * |
69 | go_ffi_type_sint32(void) | |
dffa7328 | 70 | { |
5302cd02 | 71 | return &ffi_type_sint32; |
dffa7328 ILT |
72 | } |
73 | ||
5302cd02 ILT |
74 | ffi_type * |
75 | go_ffi_type_sint64(void) | |
dffa7328 | 76 | { |
5302cd02 | 77 | return &ffi_type_sint64; |
dffa7328 ILT |
78 | } |
79 | ||
5302cd02 ILT |
80 | ffi_type * |
81 | go_ffi_type_uint8(void) | |
82 | { | |
83 | return &ffi_type_uint8; | |
84 | } | |
38bf819a | 85 | |
5302cd02 ILT |
86 | ffi_type * |
87 | go_ffi_type_uint16(void) | |
dffa7328 | 88 | { |
5302cd02 ILT |
89 | return &ffi_type_uint16; |
90 | } | |
dffa7328 | 91 | |
5302cd02 ILT |
92 | ffi_type * |
93 | go_ffi_type_uint32(void) | |
94 | { | |
95 | return &ffi_type_uint32; | |
dffa7328 ILT |
96 | } |
97 | ||
5302cd02 ILT |
98 | ffi_type * |
99 | go_ffi_type_uint64(void) | |
100 | { | |
101 | return &ffi_type_uint64; | |
102 | } | |
dffa7328 | 103 | |
5302cd02 ILT |
104 | ffi_type * |
105 | go_ffi_type_float(void) | |
dffa7328 | 106 | { |
dffa7328 | 107 | return &ffi_type_float; |
5302cd02 ILT |
108 | } |
109 | ||
110 | ffi_type * | |
111 | go_ffi_type_double(void) | |
112 | { | |
dffa7328 | 113 | return &ffi_type_double; |
5302cd02 ILT |
114 | } |
115 | ||
116 | _Bool | |
117 | go_ffi_supports_complex(void) | |
118 | { | |
38bf819a | 119 | #ifdef FFI_TARGET_HAS_COMPLEX_TYPE |
5302cd02 | 120 | return true; |
38bf819a | 121 | #else |
5302cd02 | 122 | return false; |
dffa7328 | 123 | #endif |
5302cd02 ILT |
124 | } |
125 | ||
126 | ffi_type * | |
127 | go_ffi_type_complex_float(void) | |
128 | { | |
38bf819a | 129 | #ifdef FFI_TARGET_HAS_COMPLEX_TYPE |
5302cd02 | 130 | return &ffi_type_complex_float; |
38bf819a | 131 | #else |
5302cd02 | 132 | abort(); |
dffa7328 | 133 | #endif |
dffa7328 ILT |
134 | } |
135 | ||
5302cd02 ILT |
136 | ffi_type * |
137 | go_ffi_type_complex_double(void) | |
dffa7328 | 138 | { |
5302cd02 ILT |
139 | #ifdef FFI_TARGET_HAS_COMPLEX_TYPE |
140 | return &ffi_type_complex_double; | |
141 | #else | |
142 | abort(); | |
143 | #endif | |
dffa7328 ILT |
144 | } |
145 | ||
5302cd02 ILT |
146 | ffi_type * |
147 | go_ffi_type_void(void) | |
dffa7328 | 148 | { |
5302cd02 | 149 | return &ffi_type_void; |
dffa7328 ILT |
150 | } |
151 | ||
152 | #endif /* defined(USE_LIBFFI) */ |