s390: Kill trailing whitespace
This commit is contained in:
130
src/s390/ffi.c
130
src/s390/ffi.c
@@ -1,9 +1,9 @@
|
|||||||
/* -----------------------------------------------------------------------
|
/* -----------------------------------------------------------------------
|
||||||
ffi.c - Copyright (c) 2000, 2007 Software AG
|
ffi.c - Copyright (c) 2000, 2007 Software AG
|
||||||
Copyright (c) 2008 Red Hat, Inc
|
Copyright (c) 2008 Red Hat, Inc
|
||||||
|
|
||||||
S390 Foreign Function Interface
|
S390 Foreign Function Interface
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
``Software''), to deal in the Software without restriction, including
|
``Software''), to deal in the Software without restriction, including
|
||||||
@@ -11,10 +11,10 @@
|
|||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
the following conditions:
|
the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included
|
The above copyright notice and this permission notice shall be included
|
||||||
in all copies or substantial portions of the Software.
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
@@ -27,24 +27,24 @@
|
|||||||
/* Includes */
|
/* Includes */
|
||||||
/* -------- */
|
/* -------- */
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
|
|
||||||
#include <ffi.h>
|
#include <ffi.h>
|
||||||
#include <ffi_common.h>
|
#include <ffi_common.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/*====================== End of Includes =============================*/
|
/*====================== End of Includes =============================*/
|
||||||
|
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
/* Defines */
|
/* Defines */
|
||||||
/* ------- */
|
/* ------- */
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
|
|
||||||
/* Maximum number of GPRs available for argument passing. */
|
/* Maximum number of GPRs available for argument passing. */
|
||||||
#define MAX_GPRARGS 5
|
#define MAX_GPRARGS 5
|
||||||
|
|
||||||
/* Maximum number of FPRs available for argument passing. */
|
/* Maximum number of FPRs available for argument passing. */
|
||||||
#ifdef __s390x__
|
#ifdef __s390x__
|
||||||
#define MAX_FPRARGS 4
|
#define MAX_FPRARGS 4
|
||||||
#else
|
#else
|
||||||
@@ -63,12 +63,12 @@
|
|||||||
#define FFI390_RET_INT64 5
|
#define FFI390_RET_INT64 5
|
||||||
|
|
||||||
/*===================== End of Defines ===============================*/
|
/*===================== End of Defines ===============================*/
|
||||||
|
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
/* Externals */
|
/* Externals */
|
||||||
/* --------- */
|
/* --------- */
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
|
|
||||||
extern void ffi_call_SYSV(unsigned,
|
extern void ffi_call_SYSV(unsigned,
|
||||||
extended_cif *,
|
extended_cif *,
|
||||||
void (*)(unsigned char *, extended_cif *),
|
void (*)(unsigned char *, extended_cif *),
|
||||||
@@ -78,9 +78,9 @@ extern void ffi_call_SYSV(unsigned,
|
|||||||
|
|
||||||
extern void ffi_closure_SYSV(void);
|
extern void ffi_closure_SYSV(void);
|
||||||
extern void ffi_go_closure_SYSV(void);
|
extern void ffi_go_closure_SYSV(void);
|
||||||
|
|
||||||
/*====================== End of Externals ============================*/
|
/*====================== End of Externals ============================*/
|
||||||
|
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
/* */
|
/* */
|
||||||
/* Name - ffi_check_struct_type. */
|
/* Name - ffi_check_struct_type. */
|
||||||
@@ -89,7 +89,7 @@ extern void ffi_go_closure_SYSV(void);
|
|||||||
/* general purpose or floating point register. */
|
/* general purpose or floating point register. */
|
||||||
/* */
|
/* */
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ffi_check_struct_type (ffi_type *arg)
|
ffi_check_struct_type (ffi_type *arg)
|
||||||
{
|
{
|
||||||
@@ -97,7 +97,7 @@ ffi_check_struct_type (ffi_type *arg)
|
|||||||
|
|
||||||
/* If the struct has just one element, look at that element
|
/* If the struct has just one element, look at that element
|
||||||
to find out whether to consider the struct as floating point. */
|
to find out whether to consider the struct as floating point. */
|
||||||
while (arg->type == FFI_TYPE_STRUCT
|
while (arg->type == FFI_TYPE_STRUCT
|
||||||
&& arg->elements[0] && !arg->elements[1])
|
&& arg->elements[0] && !arg->elements[1])
|
||||||
arg = arg->elements[0];
|
arg = arg->elements[0];
|
||||||
|
|
||||||
@@ -130,9 +130,9 @@ ffi_check_struct_type (ffi_type *arg)
|
|||||||
/* Other structs are passed via a pointer to the data. */
|
/* Other structs are passed via a pointer to the data. */
|
||||||
return FFI_TYPE_POINTER;
|
return FFI_TYPE_POINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*======================== End of Routine ============================*/
|
/*======================== End of Routine ============================*/
|
||||||
|
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
/* */
|
/* */
|
||||||
/* Name - ffi_prep_args. */
|
/* Name - ffi_prep_args. */
|
||||||
@@ -143,7 +143,7 @@ ffi_check_struct_type (ffi_type *arg)
|
|||||||
/* has been allocated for the function's arguments. */
|
/* has been allocated for the function's arguments. */
|
||||||
/* */
|
/* */
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ffi_prep_args (unsigned char *stack, extended_cif *ecif)
|
ffi_prep_args (unsigned char *stack, extended_cif *ecif)
|
||||||
{
|
{
|
||||||
@@ -178,7 +178,7 @@ ffi_prep_args (unsigned char *stack, extended_cif *ecif)
|
|||||||
ffi_type **ptr;
|
ffi_type **ptr;
|
||||||
void **p_argv = ecif->avalue;
|
void **p_argv = ecif->avalue;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* If we returning a structure then we set the first parameter register
|
/* If we returning a structure then we set the first parameter register
|
||||||
to the address of where we are returning this structure. */
|
to the address of where we are returning this structure. */
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ ffi_prep_args (unsigned char *stack, extended_cif *ecif)
|
|||||||
p_gpr[n_gpr++] = (unsigned long) ecif->rvalue;
|
p_gpr[n_gpr++] = (unsigned long) ecif->rvalue;
|
||||||
|
|
||||||
/* Now for the arguments. */
|
/* Now for the arguments. */
|
||||||
|
|
||||||
for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
|
for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
|
||||||
i > 0;
|
i > 0;
|
||||||
i--, ptr++, p_argv++)
|
i--, ptr++, p_argv++)
|
||||||
@@ -218,7 +218,7 @@ ffi_prep_args (unsigned char *stack, extended_cif *ecif)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now handle all primitive int/pointer/float data types. */
|
/* Now handle all primitive int/pointer/float data types. */
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case FFI_TYPE_DOUBLE:
|
case FFI_TYPE_DOUBLE:
|
||||||
if (n_fpr < MAX_FPRARGS)
|
if (n_fpr < MAX_FPRARGS)
|
||||||
@@ -231,7 +231,7 @@ ffi_prep_args (unsigned char *stack, extended_cif *ecif)
|
|||||||
p_ov[n_ov++] = ((unsigned long *) arg)[1];
|
p_ov[n_ov++] = ((unsigned long *) arg)[1];
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FFI_TYPE_FLOAT:
|
case FFI_TYPE_FLOAT:
|
||||||
if (n_fpr < MAX_FPRARGS)
|
if (n_fpr < MAX_FPRARGS)
|
||||||
p_fpr[n_fpr++] = (long long) *(unsigned int *) arg << 32;
|
p_fpr[n_fpr++] = (long long) *(unsigned int *) arg << 32;
|
||||||
@@ -245,7 +245,7 @@ ffi_prep_args (unsigned char *stack, extended_cif *ecif)
|
|||||||
else
|
else
|
||||||
p_ov[n_ov++] = (unsigned long)*(unsigned char **) arg;
|
p_ov[n_ov++] = (unsigned long)*(unsigned char **) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FFI_TYPE_UINT64:
|
case FFI_TYPE_UINT64:
|
||||||
case FFI_TYPE_SINT64:
|
case FFI_TYPE_SINT64:
|
||||||
#ifdef __s390x__
|
#ifdef __s390x__
|
||||||
@@ -264,14 +264,14 @@ ffi_prep_args (unsigned char *stack, extended_cif *ecif)
|
|||||||
p_ov[n_ov++] = ((unsigned long *) arg)[1];
|
p_ov[n_ov++] = ((unsigned long *) arg)[1];
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FFI_TYPE_UINT32:
|
case FFI_TYPE_UINT32:
|
||||||
if (n_gpr < MAX_GPRARGS)
|
if (n_gpr < MAX_GPRARGS)
|
||||||
p_gpr[n_gpr++] = *(unsigned int *) arg;
|
p_gpr[n_gpr++] = *(unsigned int *) arg;
|
||||||
else
|
else
|
||||||
p_ov[n_ov++] = *(unsigned int *) arg;
|
p_ov[n_ov++] = *(unsigned int *) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FFI_TYPE_INT:
|
case FFI_TYPE_INT:
|
||||||
case FFI_TYPE_SINT32:
|
case FFI_TYPE_SINT32:
|
||||||
if (n_gpr < MAX_GPRARGS)
|
if (n_gpr < MAX_GPRARGS)
|
||||||
@@ -279,14 +279,14 @@ ffi_prep_args (unsigned char *stack, extended_cif *ecif)
|
|||||||
else
|
else
|
||||||
p_ov[n_ov++] = *(signed int *) arg;
|
p_ov[n_ov++] = *(signed int *) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FFI_TYPE_UINT16:
|
case FFI_TYPE_UINT16:
|
||||||
if (n_gpr < MAX_GPRARGS)
|
if (n_gpr < MAX_GPRARGS)
|
||||||
p_gpr[n_gpr++] = *(unsigned short *) arg;
|
p_gpr[n_gpr++] = *(unsigned short *) arg;
|
||||||
else
|
else
|
||||||
p_ov[n_ov++] = *(unsigned short *) arg;
|
p_ov[n_ov++] = *(unsigned short *) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FFI_TYPE_SINT16:
|
case FFI_TYPE_SINT16:
|
||||||
if (n_gpr < MAX_GPRARGS)
|
if (n_gpr < MAX_GPRARGS)
|
||||||
p_gpr[n_gpr++] = *(signed short *) arg;
|
p_gpr[n_gpr++] = *(signed short *) arg;
|
||||||
@@ -300,14 +300,14 @@ ffi_prep_args (unsigned char *stack, extended_cif *ecif)
|
|||||||
else
|
else
|
||||||
p_ov[n_ov++] = *(unsigned char *) arg;
|
p_ov[n_ov++] = *(unsigned char *) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FFI_TYPE_SINT8:
|
case FFI_TYPE_SINT8:
|
||||||
if (n_gpr < MAX_GPRARGS)
|
if (n_gpr < MAX_GPRARGS)
|
||||||
p_gpr[n_gpr++] = *(signed char *) arg;
|
p_gpr[n_gpr++] = *(signed char *) arg;
|
||||||
else
|
else
|
||||||
p_ov[n_ov++] = *(signed char *) arg;
|
p_ov[n_ov++] = *(signed char *) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FFI_ASSERT (0);
|
FFI_ASSERT (0);
|
||||||
break;
|
break;
|
||||||
@@ -316,7 +316,7 @@ ffi_prep_args (unsigned char *stack, extended_cif *ecif)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*======================== End of Routine ============================*/
|
/*======================== End of Routine ============================*/
|
||||||
|
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
/* */
|
/* */
|
||||||
/* Name - ffi_prep_cif_machdep. */
|
/* Name - ffi_prep_cif_machdep. */
|
||||||
@@ -324,7 +324,7 @@ ffi_prep_args (unsigned char *stack, extended_cif *ecif)
|
|||||||
/* Function - Perform machine dependent CIF processing. */
|
/* Function - Perform machine dependent CIF processing. */
|
||||||
/* */
|
/* */
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
|
|
||||||
ffi_status
|
ffi_status
|
||||||
ffi_prep_cif_machdep(ffi_cif *cif)
|
ffi_prep_cif_machdep(ffi_cif *cif)
|
||||||
{
|
{
|
||||||
@@ -336,7 +336,7 @@ ffi_prep_cif_machdep(ffi_cif *cif)
|
|||||||
ffi_type **ptr;
|
ffi_type **ptr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Determine return value handling. */
|
/* Determine return value handling. */
|
||||||
|
|
||||||
switch (cif->rtype->type)
|
switch (cif->rtype->type)
|
||||||
{
|
{
|
||||||
@@ -350,7 +350,7 @@ ffi_prep_cif_machdep(ffi_cif *cif)
|
|||||||
case FFI_TYPE_COMPLEX:
|
case FFI_TYPE_COMPLEX:
|
||||||
cif->flags = FFI390_RET_STRUCT;
|
cif->flags = FFI390_RET_STRUCT;
|
||||||
n_gpr++; /* We need one GPR to pass the pointer. */
|
n_gpr++; /* We need one GPR to pass the pointer. */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Floating point values are returned in fpr 0. */
|
/* Floating point values are returned in fpr 0. */
|
||||||
case FFI_TYPE_FLOAT:
|
case FFI_TYPE_FLOAT:
|
||||||
@@ -389,14 +389,14 @@ ffi_prep_cif_machdep(ffi_cif *cif)
|
|||||||
cif->flags = FFI390_RET_INT32;
|
cif->flags = FFI390_RET_INT32;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FFI_ASSERT (0);
|
FFI_ASSERT (0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now for the arguments. */
|
/* Now for the arguments. */
|
||||||
|
|
||||||
for (ptr = cif->arg_types, i = cif->nargs;
|
for (ptr = cif->arg_types, i = cif->nargs;
|
||||||
i > 0;
|
i > 0;
|
||||||
i--, ptr++)
|
i--, ptr++)
|
||||||
@@ -424,7 +424,7 @@ ffi_prep_cif_machdep(ffi_cif *cif)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now handle all primitive int/float data types. */
|
/* Now handle all primitive int/float data types. */
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
/* The first MAX_FPRARGS floating point arguments
|
/* The first MAX_FPRARGS floating point arguments
|
||||||
go in FPRs, the rest overflow to the stack. */
|
go in FPRs, the rest overflow to the stack. */
|
||||||
@@ -435,7 +435,7 @@ ffi_prep_cif_machdep(ffi_cif *cif)
|
|||||||
else
|
else
|
||||||
n_ov += sizeof (double) / sizeof (long);
|
n_ov += sizeof (double) / sizeof (long);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FFI_TYPE_FLOAT:
|
case FFI_TYPE_FLOAT:
|
||||||
if (n_fpr < MAX_FPRARGS)
|
if (n_fpr < MAX_FPRARGS)
|
||||||
n_fpr++;
|
n_fpr++;
|
||||||
@@ -445,9 +445,9 @@ ffi_prep_cif_machdep(ffi_cif *cif)
|
|||||||
|
|
||||||
/* On 31-bit machines, 64-bit integers are passed in GPR pairs,
|
/* On 31-bit machines, 64-bit integers are passed in GPR pairs,
|
||||||
if one is still available, or else on the stack. If only one
|
if one is still available, or else on the stack. If only one
|
||||||
register is free, skip the register (it won't be used for any
|
register is free, skip the register (it won't be used for any
|
||||||
subsequent argument either). */
|
subsequent argument either). */
|
||||||
|
|
||||||
#ifndef __s390x__
|
#ifndef __s390x__
|
||||||
case FFI_TYPE_UINT64:
|
case FFI_TYPE_UINT64:
|
||||||
case FFI_TYPE_SINT64:
|
case FFI_TYPE_SINT64:
|
||||||
@@ -463,7 +463,7 @@ ffi_prep_cif_machdep(ffi_cif *cif)
|
|||||||
/* Everything else is passed in GPRs (until MAX_GPRARGS
|
/* Everything else is passed in GPRs (until MAX_GPRARGS
|
||||||
have been used) or overflows to the stack. */
|
have been used) or overflows to the stack. */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (n_gpr < MAX_GPRARGS)
|
if (n_gpr < MAX_GPRARGS)
|
||||||
n_gpr++;
|
n_gpr++;
|
||||||
else
|
else
|
||||||
@@ -476,12 +476,12 @@ ffi_prep_cif_machdep(ffi_cif *cif)
|
|||||||
and temporary structure copies. */
|
and temporary structure copies. */
|
||||||
|
|
||||||
cif->bytes = ROUND_SIZE (n_ov * sizeof (long)) + struct_size;
|
cif->bytes = ROUND_SIZE (n_ov * sizeof (long)) + struct_size;
|
||||||
|
|
||||||
return FFI_OK;
|
return FFI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*======================== End of Routine ============================*/
|
/*======================== End of Routine ============================*/
|
||||||
|
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
/* */
|
/* */
|
||||||
/* Name - ffi_call. */
|
/* Name - ffi_call. */
|
||||||
@@ -489,7 +489,7 @@ ffi_prep_cif_machdep(ffi_cif *cif)
|
|||||||
/* Function - Call the FFI routine. */
|
/* Function - Call the FFI routine. */
|
||||||
/* */
|
/* */
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ffi_call_int(ffi_cif *cif,
|
ffi_call_int(ffi_cif *cif,
|
||||||
void (*fn)(void),
|
void (*fn)(void),
|
||||||
@@ -499,7 +499,7 @@ ffi_call_int(ffi_cif *cif,
|
|||||||
{
|
{
|
||||||
int ret_type = cif->flags;
|
int ret_type = cif->flags;
|
||||||
extended_cif ecif;
|
extended_cif ecif;
|
||||||
|
|
||||||
ecif.cif = cif;
|
ecif.cif = cif;
|
||||||
ecif.avalue = avalue;
|
ecif.avalue = avalue;
|
||||||
ecif.rvalue = rvalue;
|
ecif.rvalue = rvalue;
|
||||||
@@ -511,7 +511,7 @@ ffi_call_int(ffi_cif *cif,
|
|||||||
ecif.rvalue = alloca (cif->rtype->size);
|
ecif.rvalue = alloca (cif->rtype->size);
|
||||||
else
|
else
|
||||||
ret_type = FFI390_RET_VOID;
|
ret_type = FFI390_RET_VOID;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cif->abi)
|
switch (cif->abi)
|
||||||
{
|
{
|
||||||
@@ -519,7 +519,7 @@ ffi_call_int(ffi_cif *cif,
|
|||||||
ffi_call_SYSV (cif->bytes, &ecif, ffi_prep_args,
|
ffi_call_SYSV (cif->bytes, &ecif, ffi_prep_args,
|
||||||
ret_type, ecif.rvalue, fn, closure);
|
ret_type, ecif.rvalue, fn, closure);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FFI_ASSERT (0);
|
FFI_ASSERT (0);
|
||||||
break;
|
break;
|
||||||
@@ -538,7 +538,7 @@ ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
|
|||||||
{
|
{
|
||||||
ffi_call_int(cif, fn, rvalue, avalue, closure);
|
ffi_call_int(cif, fn, rvalue, avalue, closure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*======================== End of Routine ============================*/
|
/*======================== End of Routine ============================*/
|
||||||
|
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
@@ -575,8 +575,8 @@ ffi_closure_helper_SYSV (ffi_cif *cif,
|
|||||||
|
|
||||||
p_arg = avalue = alloca (cif->nargs * sizeof (void *));
|
p_arg = avalue = alloca (cif->nargs * sizeof (void *));
|
||||||
|
|
||||||
/* If we returning a structure, pass the structure address
|
/* If we returning a structure, pass the structure address
|
||||||
directly to the target function. Otherwise, have the target
|
directly to the target function. Otherwise, have the target
|
||||||
function store the return value to the GPR save area. */
|
function store the return value to the GPR save area. */
|
||||||
|
|
||||||
if (cif->flags == FFI390_RET_STRUCT)
|
if (cif->flags == FFI390_RET_STRUCT)
|
||||||
@@ -603,7 +603,7 @@ ffi_closure_helper_SYSV (ffi_cif *cif,
|
|||||||
else
|
else
|
||||||
type = ffi_check_struct_type (*ptr);
|
type = ffi_check_struct_type (*ptr);
|
||||||
|
|
||||||
/* If we pass the struct via pointer, remember to
|
/* If we pass the struct via pointer, remember to
|
||||||
retrieve the pointer later. */
|
retrieve the pointer later. */
|
||||||
if (type == FFI_TYPE_POINTER)
|
if (type == FFI_TYPE_POINTER)
|
||||||
deref_struct_pointer = 1;
|
deref_struct_pointer = 1;
|
||||||
@@ -618,23 +618,23 @@ ffi_closure_helper_SYSV (ffi_cif *cif,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Now handle all primitive int/float data types. */
|
/* Now handle all primitive int/float data types. */
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case FFI_TYPE_DOUBLE:
|
case FFI_TYPE_DOUBLE:
|
||||||
if (n_fpr < MAX_FPRARGS)
|
if (n_fpr < MAX_FPRARGS)
|
||||||
*p_arg = &p_fpr[n_fpr++];
|
*p_arg = &p_fpr[n_fpr++];
|
||||||
else
|
else
|
||||||
*p_arg = &p_ov[n_ov],
|
*p_arg = &p_ov[n_ov],
|
||||||
n_ov += sizeof (double) / sizeof (long);
|
n_ov += sizeof (double) / sizeof (long);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FFI_TYPE_FLOAT:
|
case FFI_TYPE_FLOAT:
|
||||||
if (n_fpr < MAX_FPRARGS)
|
if (n_fpr < MAX_FPRARGS)
|
||||||
*p_arg = &p_fpr[n_fpr++];
|
*p_arg = &p_fpr[n_fpr++];
|
||||||
else
|
else
|
||||||
*p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 4;
|
*p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FFI_TYPE_UINT64:
|
case FFI_TYPE_UINT64:
|
||||||
case FFI_TYPE_SINT64:
|
case FFI_TYPE_SINT64:
|
||||||
#ifdef __s390x__
|
#ifdef __s390x__
|
||||||
@@ -651,7 +651,7 @@ ffi_closure_helper_SYSV (ffi_cif *cif,
|
|||||||
*p_arg = &p_ov[n_ov], n_ov += 2;
|
*p_arg = &p_ov[n_ov], n_ov += 2;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FFI_TYPE_INT:
|
case FFI_TYPE_INT:
|
||||||
case FFI_TYPE_UINT32:
|
case FFI_TYPE_UINT32:
|
||||||
case FFI_TYPE_SINT32:
|
case FFI_TYPE_SINT32:
|
||||||
@@ -660,7 +660,7 @@ ffi_closure_helper_SYSV (ffi_cif *cif,
|
|||||||
else
|
else
|
||||||
*p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 4;
|
*p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FFI_TYPE_UINT16:
|
case FFI_TYPE_UINT16:
|
||||||
case FFI_TYPE_SINT16:
|
case FFI_TYPE_SINT16:
|
||||||
if (n_gpr < MAX_GPRARGS)
|
if (n_gpr < MAX_GPRARGS)
|
||||||
@@ -676,7 +676,7 @@ ffi_closure_helper_SYSV (ffi_cif *cif,
|
|||||||
else
|
else
|
||||||
*p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 1;
|
*p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FFI_ASSERT (0);
|
FFI_ASSERT (0);
|
||||||
break;
|
break;
|
||||||
@@ -744,7 +744,7 @@ ffi_closure_helper_SYSV (ffi_cif *cif,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*======================== End of Routine ============================*/
|
/*======================== End of Routine ============================*/
|
||||||
|
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
@@ -754,7 +754,7 @@ ffi_closure_helper_SYSV (ffi_cif *cif,
|
|||||||
/* Function - Prepare a FFI closure. */
|
/* Function - Prepare a FFI closure. */
|
||||||
/* */
|
/* */
|
||||||
/*====================================================================*/
|
/*====================================================================*/
|
||||||
|
|
||||||
ffi_status
|
ffi_status
|
||||||
ffi_prep_closure_loc (ffi_closure *closure,
|
ffi_prep_closure_loc (ffi_closure *closure,
|
||||||
ffi_cif *cif,
|
ffi_cif *cif,
|
||||||
@@ -780,17 +780,17 @@ ffi_prep_closure_loc (ffi_closure *closure,
|
|||||||
*(short *)&closure->tramp [8] = 0x07f1; /* br %r1 */
|
*(short *)&closure->tramp [8] = 0x07f1; /* br %r1 */
|
||||||
*(long *)&closure->tramp[16] = (long)codeloc;
|
*(long *)&closure->tramp[16] = (long)codeloc;
|
||||||
*(long *)&closure->tramp[24] = (long)&ffi_closure_SYSV;
|
*(long *)&closure->tramp[24] = (long)&ffi_closure_SYSV;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
closure->cif = cif;
|
closure->cif = cif;
|
||||||
closure->user_data = user_data;
|
closure->user_data = user_data;
|
||||||
closure->fun = fun;
|
closure->fun = fun;
|
||||||
|
|
||||||
return FFI_OK;
|
return FFI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*======================== End of Routine ============================*/
|
/*======================== End of Routine ============================*/
|
||||||
|
|
||||||
/* Build a Go language closure. */
|
/* Build a Go language closure. */
|
||||||
|
|
||||||
ffi_status
|
ffi_status
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/* -----------------------------------------------------------------------
|
/* -----------------------------------------------------------------------
|
||||||
sysv.S - Copyright (c) 2000 Software AG
|
sysv.S - Copyright (c) 2000 Software AG
|
||||||
Copyright (c) 2008 Red Hat, Inc.
|
Copyright (c) 2008 Red Hat, Inc.
|
||||||
|
|
||||||
S390 Foreign Function Interface
|
S390 Foreign Function Interface
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
``Software''), to deal in the Software without restriction, including
|
``Software''), to deal in the Software without restriction, including
|
||||||
@@ -11,10 +11,10 @@
|
|||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
the following conditions:
|
the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included
|
The above copyright notice and this permission notice shall be included
|
||||||
in all copies or substantial portions of the Software.
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
#include <ffi.h>
|
#include <ffi.h>
|
||||||
|
|
||||||
#ifndef __s390x__
|
#ifndef __s390x__
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
|
||||||
# r2: cif->bytes
|
# r2: cif->bytes
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
# r4: ffi_prep_args
|
# r4: ffi_prep_args
|
||||||
# r5: ret_type
|
# r5: ret_type
|
||||||
# r6: ecif.rvalue
|
# r6: ecif.rvalue
|
||||||
# ov: fn
|
# ov: fn
|
||||||
# ov+8: closure
|
# ov+8: closure
|
||||||
|
|
||||||
# This assumes we are using gas.
|
# This assumes we are using gas.
|
||||||
@@ -125,7 +125,7 @@ ffi_call_SYSV:
|
|||||||
.cfi_restore_state
|
.cfi_restore_state
|
||||||
# See comment on the nopr above.
|
# See comment on the nopr above.
|
||||||
nopr
|
nopr
|
||||||
|
|
||||||
.LretDouble:
|
.LretDouble:
|
||||||
l %r4,48+56(%r11)
|
l %r4,48+56(%r11)
|
||||||
std %f0,0(%r8) # Return double
|
std %f0,0(%r8) # Return double
|
||||||
@@ -167,7 +167,7 @@ ffi_call_SYSV:
|
|||||||
.cfi_restore_state
|
.cfi_restore_state
|
||||||
# See comment on the nopr above.
|
# See comment on the nopr above.
|
||||||
nopr
|
nopr
|
||||||
|
|
||||||
.LretInt64:
|
.LretInt64:
|
||||||
l %r4,48+56(%r11)
|
l %r4,48+56(%r11)
|
||||||
stm %r2,%r3,0(%r8) # Return long long
|
stm %r2,%r3,0(%r8) # Return long long
|
||||||
@@ -186,7 +186,7 @@ ffi_call_SYSV:
|
|||||||
.cfi_def_cfa r15, 96
|
.cfi_def_cfa r15, 96
|
||||||
br %r4
|
br %r4
|
||||||
.cfi_endproc
|
.cfi_endproc
|
||||||
|
|
||||||
.Ltable:
|
.Ltable:
|
||||||
.byte .LretNone-.Lbase # FFI390_RET_VOID
|
.byte .LretNone-.Lbase # FFI390_RET_VOID
|
||||||
.byte .LretNone-.Lbase # FFI390_RET_STRUCT
|
.byte .LretNone-.Lbase # FFI390_RET_STRUCT
|
||||||
@@ -269,15 +269,15 @@ ffi_go_closure_SYSV:
|
|||||||
.cfi_endproc
|
.cfi_endproc
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
|
||||||
# r2: cif->bytes
|
# r2: cif->bytes
|
||||||
# r3: &ecif
|
# r3: &ecif
|
||||||
# r4: ffi_prep_args
|
# r4: ffi_prep_args
|
||||||
# r5: ret_type
|
# r5: ret_type
|
||||||
# r6: ecif.rvalue
|
# r6: ecif.rvalue
|
||||||
# ov: fn
|
# ov: fn
|
||||||
# ov+8: closure
|
# ov+8: closure
|
||||||
|
|
||||||
# This assumes we are using gas.
|
# This assumes we are using gas.
|
||||||
@@ -365,7 +365,7 @@ ffi_call_SYSV:
|
|||||||
.cfi_restore_state
|
.cfi_restore_state
|
||||||
# See comment on the nopr above.
|
# See comment on the nopr above.
|
||||||
nopr
|
nopr
|
||||||
|
|
||||||
.LretDouble:
|
.LretDouble:
|
||||||
lg %r4,80+112(%r11)
|
lg %r4,80+112(%r11)
|
||||||
std %f0,0(%r8) # Return double
|
std %f0,0(%r8) # Return double
|
||||||
@@ -404,7 +404,7 @@ ffi_call_SYSV:
|
|||||||
.cfi_def_cfa r15, 160
|
.cfi_def_cfa r15, 160
|
||||||
br %r4
|
br %r4
|
||||||
.cfi_endproc
|
.cfi_endproc
|
||||||
|
|
||||||
.Ltable:
|
.Ltable:
|
||||||
.byte .LretNone-.Lbase # FFI390_RET_VOID
|
.byte .LretNone-.Lbase # FFI390_RET_VOID
|
||||||
.byte .LretNone-.Lbase # FFI390_RET_STRUCT
|
.byte .LretNone-.Lbase # FFI390_RET_STRUCT
|
||||||
@@ -461,7 +461,7 @@ ffi_closure_SYSV:
|
|||||||
.ffi_closure_SYSV_end:
|
.ffi_closure_SYSV_end:
|
||||||
.size ffi_closure_SYSV,.ffi_closure_SYSV_end-ffi_closure_SYSV
|
.size ffi_closure_SYSV,.ffi_closure_SYSV_end-ffi_closure_SYSV
|
||||||
|
|
||||||
|
|
||||||
.globl ffi_go_closure_SYSV
|
.globl ffi_go_closure_SYSV
|
||||||
FFI_HIDDEN(ffi_go_closure_SYSV)
|
FFI_HIDDEN(ffi_go_closure_SYSV)
|
||||||
.type ffi_go_closure_SYSV,%function
|
.type ffi_go_closure_SYSV,%function
|
||||||
|
|||||||
Reference in New Issue
Block a user