libsysve  3.1.0
VH call

VH call is a feature for VE programs to invoke functions on VH. More...

Functions

vhcall_handle vhcall_install (const char *filename)
 Load a VH library. More...
 
int64_t vhcall_find (vhcall_handle hdl, const char *symname)
 Find a symbol in VH library. More...
 
vhcall_argsvhcall_args_alloc (void)
 Allocate VHCall arguments object (vhcall_args) More...
 
vhcall_argsvhcall_args_alloc_num (int num)
 Allocate VHCall arguments object extended for Fortran API. More...
 
int vhcall_args_set_i8 (vhcall_args *ca, int argnum, int8_t val)
 Set a 8-bit signed integer argument. More...
 
int vhcall_args_set_u8 (vhcall_args *ca, int argnum, uint8_t val)
 Set a 8-bit unsigned integer argument. More...
 
int vhcall_args_set_i16 (vhcall_args *ca, int argnum, int16_t val)
 Set a 16-bit signed integer argument. More...
 
int vhcall_args_set_u16 (vhcall_args *ca, int argnum, uint16_t val)
 Set a 16-bit unsigned integer argument. More...
 
int vhcall_args_set_i32 (vhcall_args *ca, int argnum, int32_t val)
 Set a 32-bit signed integer argument. More...
 
int vhcall_args_set_u32 (vhcall_args *ca, int argnum, uint32_t val)
 Set a 32-bit unsigned integer argument. More...
 
int vhcall_args_set_i64 (vhcall_args *ca, int argnum, int64_t val)
 Set a 64-bit signed integer argument. More...
 
int vhcall_args_set_u64 (vhcall_args *ca, int argnum, uint64_t val)
 Set a 64-bit unsigned integer argument. More...
 
int vhcall_args_set_float (vhcall_args *ca, int argnum, float val)
 Set a single precision floating point number argument. More...
 
int vhcall_args_set_double (vhcall_args *ca, int argnum, double val)
 Set a double precision floating point number argument. More...
 
int vhcall_args_set_complex_float (vhcall_args *ca, int argnum, _Complex float val)
 Set a single precision floating point complex object argument. More...
 
int vhcall_args_set_complex_double (vhcall_args *ca, int argnum, _Complex double val)
 Set a double precision floating point complex object argument. More...
 
int vhcall_args_set_pointer (vhcall_args *ca, enum vhcall_args_intent inout, int argnum, void *buff, size_t len)
 Set VH function argument of pointer type. More...
 
int vhcall_args_set_veoshandle (vhcall_args *ca, int argnum)
 Set VH function argument of pointer to VEOS handle. More...
 
void vhcall_args_clear (vhcall_args *ca)
 Clear arguments set in VHCall arguments object. More...
 
void vhcall_args_free (vhcall_args *ca)
 Free VHCall arguments object. More...
 
int vhcall_invoke_with_args (int64_t symid, vhcall_args *args, uint64_t *retval)
 Invoke a function in VH library with passing arguments. More...
 
long vhcall_invoke (int64_t symid, const void *inptr, size_t insize, void *outptr, size_t outsize)
 Invoke a function in VH library. More...
 
int vhcall_uninstall (vhcall_handle hdl)
 Unload a VH library. More...
 

Detailed Description

VH call is a feature for VE programs to invoke functions on VH.

Please include "libvhcall.h".

Note
vhcall_invoke_with_args() is expanded API of vhcall_invoke() for passing arguments. vhcall_args_alloc() and functions in vhcall_args_set_double() family (they are found in API list with prefix "vhcall_args_set_") are available for generating VH function arguments from VE side by following two steps:
  1. vhcall_args_alloc() allocates new list for arguments of VH function. The list is represented by "vhcall_args".
  2. For each argument, function of vhcall_args_set_double() family sets its value to vhcall_args. vhcall_args_set_double() family is corresponding to each fundamental type of argument (int_8t, float, pointer and etc...) but long double.

Function Documentation

vhcall_handle vhcall_install ( const char *  filename)

Load a VH library.

Parameters
[in]filenamethe file name to load on VH
Returns
VH call handle of the VH library
Return values
-1upon failure and the following errno is set:
  • ENOENT filename cannot be loaded;
  • EFAULT filename is not accessible;
  • ENOMEM not enough VH memory.
int64_t vhcall_find ( vhcall_handle  hdl,
const char *  symname 
)

Find a symbol in VH library.

Parameters
hdlVH call handle of VH library
[in]symnamethe name of a function
Returns
symbol ID of the function upon success; negative upon failure.
Return values
-1upon failure and the following errno is set:
  • EINVAL symname is not found in hdl.
  • EFAULT symname is not accessible.
  • ENOMEM not enough VH memory.
vhcall_args* vhcall_args_alloc ( void  )

Allocate VHCall arguments object (vhcall_args)

Returns
pointer to vehcall_args
Return values
NULLthe allocation of vhcall_args failed and following errno is set:
  • ENOMEM not enough VE memory.
vhcall_args* vhcall_args_alloc_num ( int  num)

Allocate VHCall arguments object extended for Fortran API.

Parameters
[in]numthe number of arguments.
Returns
pointer to vehcall_args
Return values
NULLthe allocation of vhcall_args failed and following errno is set:
  • ENOMEM not enough VE memory.
int vhcall_args_set_i8 ( vhcall_args ca,
int  argnum,
int8_t  val 
)

Set a 8-bit signed integer argument.

Parameters
cavhcall_args
argnumthe argnum-th argument (counting from 0)
valvalue to be set
Returns
zero upon success; negative upon failure and following errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.
int vhcall_args_set_u8 ( vhcall_args ca,
int  argnum,
uint8_t  val 
)

Set a 8-bit unsigned integer argument.

Parameters
cavhcall_args
argnumthe argnum-th argument (counting from 0)
valvalue to be set
Returns
zero upon success; negative upon failure and following errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.
int vhcall_args_set_i16 ( vhcall_args ca,
int  argnum,
int16_t  val 
)

Set a 16-bit signed integer argument.

Parameters
cavhcall_args
argnumthe argnum-th argument (counting from 0)
valvalue to be set
Returns
zero upon success; negative upon failure and following errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.
int vhcall_args_set_u16 ( vhcall_args ca,
int  argnum,
uint16_t  val 
)

Set a 16-bit unsigned integer argument.

Parameters
cavhcall_arg
argnumthe argnum-th argument (counting from 0)
valvalue to be set
Returns
zero upon success; negative upon failure and following errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.
int vhcall_args_set_i32 ( vhcall_args ca,
int  argnum,
int32_t  val 
)

Set a 32-bit signed integer argument.

Parameters
cavhcall_arg
argnumthe argnum-th argument (counting from 0)
valvalue to be set
Returns
zero upon success; negative upon failure and following errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.
int vhcall_args_set_u32 ( vhcall_args ca,
int  argnum,
uint32_t  val 
)

Set a 32-bit unsigned integer argument.

Parameters
cavhcall_arg
argnumthe argnum-th argument (counting from 0)
valvalue to be set
Returns
zero upon success; negative upon failure and following errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.
int vhcall_args_set_i64 ( vhcall_args ca,
int  argnum,
int64_t  val 
)

Set a 64-bit signed integer argument.

Parameters
cavhcall_arg
argnumthe argnum-th argument (counting from 0)
valvalue to be set
Returns
zero upon success; negative upon failure and following errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.
int vhcall_args_set_u64 ( vhcall_args ca,
int  argnum,
uint64_t  val 
)

Set a 64-bit unsigned integer argument.

Parameters
cavhcall_args
argnumthe argnum-th argument (counting from 0)
valvalue to be set
Returns
zero upon success; negative upon failure and following errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.
int vhcall_args_set_float ( vhcall_args ca,
int  argnum,
float  val 
)

Set a single precision floating point number argument.

Parameters
cavhcall_args
argnumthe argnum-th argument (counting from 0)
valvalue to be set
Returns
zero upon success; negative upon failure and following errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.
int vhcall_args_set_double ( vhcall_args ca,
int  argnum,
double  val 
)

Set a double precision floating point number argument.

Parameters
cavhcall_args
argnumthe argnum-th argument (counting from 0)
valvalue to be set
Returns
zero upon success; negative upon failure and following errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.
int vhcall_args_set_complex_float ( vhcall_args ca,
int  argnum,
_Complex float  val 
)

Set a single precision floating point complex object argument.

Parameters
cavhcall_args
argnumthe argnum-th argument (counting from 0)
valvalue to be set
Returns
zero upon success; negative upon failure and following errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.
int vhcall_args_set_complex_double ( vhcall_args ca,
int  argnum,
_Complex double  val 
)

Set a double precision floating point complex object argument.

Parameters
cavhcall_args
argnumthe argnum-th argument (counting from 0)
valvalue to be set
Returns
zero upon success; negative upon failure and errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.
int vhcall_args_set_pointer ( vhcall_args ca,
enum vhcall_args_intent  inout,
int  argnum,
void *  buff,
size_t  len 
)

Set VH function argument of pointer type.

Parameters
capointer to vhcall_args object
inoutintent of argument. VHCALL_INTENT_IN, VHCALL_INTENT_OUT, VHCALL_INTENT_INOUT are supported
argnumthe argnum-th argument (counting from 0)
[in,out]buffchar pointer to be set as argument
lenlength of buffer that is specified as argument
Return values
0argnum is successfully set
-1an error occurred and following errno is set
  • EINVAL ca is NULL, intent is not vhcall_args_intent type or argnum is negative.
  • ENOMEM not enough VE memory.

Buffer is allocated on VH side and its pointer is given as actual argument of VH function. The VH buffer is copy-in/copy-out from/to buff depending on intent. Use this in following cases:

  • pass by pointer (eg. C language functions)
  • pass by reference (eg. GNU Fortran functions)
int vhcall_args_set_veoshandle ( vhcall_args ca,
int  argnum 
)

Set VH function argument of pointer to VEOS handle.

Note
Please include libvepseudo.h to use VEOS handle in VH function.
Parameters
capointer to vhcall_args object
argnumthe argnum-th argument (counting from 0)
Return values
0argumen is successfully set.
-1an error occurred and following errno is set.
  • EINVAL ca is NULL or argnum is negative.
  • ENOMEM not enough VE memory.

VEOS handle is used to send/receive data to/from VE in VHCall function.

void vhcall_args_clear ( vhcall_args ca)

Clear arguments set in VHCall arguments object.

Parameters
cavhcall_args object
void vhcall_args_free ( vhcall_args ca)

Free VHCall arguments object.

Parameters
cavhcall_args object
int vhcall_invoke_with_args ( int64_t  symid,
vhcall_args args,
uint64_t *  retval 
)

Invoke a function in VH library with passing arguments.

Note
"vhcall_args" passed to vhcall_invoke_with_args() must have all of arguments of VH function to be invoked. If not, result is unexpected.
Return value of VH function to be invoked must be uint64_t. It can be got through pointer passed to vhcall_invoke_with_args().
Parameters
symidsymbol id of VH function to call
argsarguments to be passed to the VH function
[out]retvalpointer to buffer storing return value of VH library function
Returns
0 upon success, -1 upon failure and following errno is set.
  • EINVAL args is not complete i.e. some list elements of args are missing.
  • ENOMEM not enough VE memory or not enough VH memory.
  • EFAULT failure to send/receive data to/from VE on VH side.
long vhcall_invoke ( int64_t  symid,
const void *  inptr,
size_t  insize,
void *  outptr,
size_t  outsize 
)

Invoke a function in VH library.

Parameters
symidsymbol ID to invoke
[in]inptrinput buffer
insizesize of input buffer
[out]outptroutput buffer
outsizesize of output buffer
Returns
return value from the function specified by symid.
Return values
-1and errno is set when the return value is between -4095 and -1.
int vhcall_uninstall ( vhcall_handle  hdl)

Unload a VH library.

Parameters
hdlVH call handle to close
Return values
0on success.
non-zerovalue on error: the value returned from dlclose() on VH.