2017-10-07 00:16:47 +00:00
|
|
|
/* go-ffi.c -- libffi support functions.
|
2015-08-28 15:33:40 +00:00
|
|
|
|
|
|
|
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"
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
/* 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));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_pointer(void) __asm__ ("runtime.ffi__type__pointer");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_sint8(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_sint8(void) __asm__ ("runtime.ffi__type__sint8");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_sint16(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_sint16(void) __asm__ ("runtime.ffi__type__sint16");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_sint32(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_sint32(void) __asm__ ("runtime.ffi__type__sint32");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_sint64(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_sint64(void) __asm__ ("runtime.ffi__type__sint64");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_uint8(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_uint8(void) __asm__ ("runtime.ffi__type__uint8");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_uint16(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_uint16(void) __asm__ ("runtime.ffi__type__uint16");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_uint32(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_uint32(void) __asm__ ("runtime.ffi__type__uint32");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_uint64(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_uint64(void) __asm__ ("runtime.ffi__type__uint64");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_float(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_float(void) __asm__ ("runtime.ffi__type__float");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_double(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_double(void) __asm__ ("runtime.ffi__type__double");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_complex_float(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_complex_float(void) __asm__ ("runtime.ffi__type__complex__float");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_complex_double(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_complex_double(void) __asm__ ("runtime.ffi__type__complex__double");
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *go_ffi_type_void(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
ffi_type *go_ffi_type_void(void) __asm__ ("runtime.ffi__type__void");
|
2017-10-07 00:16:47 +00:00
|
|
|
|
|
|
|
_Bool go_ffi_supports_complex(void) __attribute__ ((no_split_stack));
|
2022-10-27 18:55:19 +00:00
|
|
|
_Bool go_ffi_supports_complex(void) __asm__ ("runtime.ffi__supports__complex");
|
2017-10-07 00:16:47 +00:00
|
|
|
|
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_pointer(void)
|
2015-08-28 15:33:40 +00:00
|
|
|
{
|
2017-10-07 00:16:47 +00:00
|
|
|
return &ffi_type_pointer;
|
2015-08-28 15:33:40 +00:00
|
|
|
}
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_sint8(void)
|
2015-08-28 15:33:40 +00:00
|
|
|
{
|
2017-10-07 00:16:47 +00:00
|
|
|
return &ffi_type_sint8;
|
2015-08-28 15:33:40 +00:00
|
|
|
}
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_sint16(void)
|
2015-08-28 15:33:40 +00:00
|
|
|
{
|
2017-10-07 00:16:47 +00:00
|
|
|
return &ffi_type_sint16;
|
2015-08-28 15:33:40 +00:00
|
|
|
}
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_sint32(void)
|
2015-08-28 15:33:40 +00:00
|
|
|
{
|
2017-10-07 00:16:47 +00:00
|
|
|
return &ffi_type_sint32;
|
2015-08-28 15:33:40 +00:00
|
|
|
}
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_sint64(void)
|
2015-08-28 15:33:40 +00:00
|
|
|
{
|
2017-10-07 00:16:47 +00:00
|
|
|
return &ffi_type_sint64;
|
2015-08-28 15:33:40 +00:00
|
|
|
}
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_uint8(void)
|
|
|
|
{
|
|
|
|
return &ffi_type_uint8;
|
|
|
|
}
|
2015-08-28 15:33:40 +00:00
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_uint16(void)
|
2015-08-28 15:33:40 +00:00
|
|
|
{
|
2017-10-07 00:16:47 +00:00
|
|
|
return &ffi_type_uint16;
|
|
|
|
}
|
2015-08-28 15:33:40 +00:00
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_uint32(void)
|
|
|
|
{
|
|
|
|
return &ffi_type_uint32;
|
2015-08-28 15:33:40 +00:00
|
|
|
}
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_uint64(void)
|
|
|
|
{
|
|
|
|
return &ffi_type_uint64;
|
|
|
|
}
|
2015-08-28 15:33:40 +00:00
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_float(void)
|
2015-08-28 15:33:40 +00:00
|
|
|
{
|
|
|
|
return &ffi_type_float;
|
2017-10-07 00:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_double(void)
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
return &ffi_type_double;
|
2017-10-07 00:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_Bool
|
|
|
|
go_ffi_supports_complex(void)
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
|
2017-10-07 00:16:47 +00:00
|
|
|
return true;
|
2015-08-28 15:33:40 +00:00
|
|
|
#else
|
2017-10-07 00:16:47 +00:00
|
|
|
return false;
|
2015-08-28 15:33:40 +00:00
|
|
|
#endif
|
2017-10-07 00:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_complex_float(void)
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
|
2017-10-07 00:16:47 +00:00
|
|
|
return &ffi_type_complex_float;
|
2015-08-28 15:33:40 +00:00
|
|
|
#else
|
2017-10-07 00:16:47 +00:00
|
|
|
abort();
|
2015-08-28 15:33:40 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_complex_double(void)
|
2015-08-28 15:33:40 +00:00
|
|
|
{
|
2017-10-07 00:16:47 +00:00
|
|
|
#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
|
|
|
|
return &ffi_type_complex_double;
|
|
|
|
#else
|
|
|
|
abort();
|
|
|
|
#endif
|
2015-08-28 15:33:40 +00:00
|
|
|
}
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
ffi_type *
|
|
|
|
go_ffi_type_void(void)
|
2015-08-28 15:33:40 +00:00
|
|
|
{
|
2017-10-07 00:16:47 +00:00
|
|
|
return &ffi_type_void;
|
2015-08-28 15:33:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* defined(USE_LIBFFI) */
|