summaryrefslogtreecommitdiff
path: root/libffi/src/alpha
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-03-03 21:39:37 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-03-03 21:39:37 +0100
commitcd11ae061b002913740483529e31b3f6d3da753d (patch)
treea6d84df9a4a8ed53476aa079a7202fdec69f4d98 /libffi/src/alpha
parentb2342735e543f8fec2f6914d5e628391dd0ffc46 (diff)
Update libffi to 3.0.4.
darcs-hash:d0cdf89441c98da668f268b1af91e536dc3ed76e
Diffstat (limited to 'libffi/src/alpha')
-rw-r--r--libffi/src/alpha/ffi.c252
-rw-r--r--libffi/src/alpha/ffitarget.h48
-rw-r--r--libffi/src/alpha/osf.S355
3 files changed, 0 insertions, 655 deletions
diff --git a/libffi/src/alpha/ffi.c b/libffi/src/alpha/ffi.c
deleted file mode 100644
index 00d3379..0000000
--- a/libffi/src/alpha/ffi.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/* -----------------------------------------------------------------------
- ffi.c - Copyright (c) 1998, 2001 Red Hat, Inc.
-
- Alpha Foreign Function Interface
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- ``Software''), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
- ----------------------------------------------------------------------- */
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-#include <stdlib.h>
-
-extern void ffi_call_osf(void *, unsigned long, unsigned, void *, void (*)());
-extern void ffi_closure_osf(void);
-
-
-ffi_status
-ffi_prep_cif_machdep(ffi_cif *cif)
-{
- /* Adjust cif->bytes to represent a minimum 6 words for the temporary
- register argument loading area. */
- if (cif->bytes < 6*FFI_SIZEOF_ARG)
- cif->bytes = 6*FFI_SIZEOF_ARG;
-
- /* Set the return type flag */
- switch (cif->rtype->type)
- {
- case FFI_TYPE_STRUCT:
- case FFI_TYPE_FLOAT:
- case FFI_TYPE_DOUBLE:
- cif->flags = cif->rtype->type;
- break;
-
- default:
- cif->flags = FFI_TYPE_INT;
- break;
- }
-
- return FFI_OK;
-}
-
-void
-ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
-{
- unsigned long *stack, *argp;
- long i, avn;
- ffi_type **arg_types;
-
- FFI_ASSERT (cif->abi == FFI_OSF);
-
- /* If the return value is a struct and we don't have a return
- value address then we need to make one. */
- if (rvalue == NULL && cif->flags == FFI_TYPE_STRUCT)
- rvalue = alloca(cif->rtype->size);
-
- /* Allocate the space for the arguments, plus 4 words of temp
- space for ffi_call_osf. */
- argp = stack = alloca(cif->bytes + 4*FFI_SIZEOF_ARG);
-
- if (cif->flags == FFI_TYPE_STRUCT)
- *(void **) argp++ = rvalue;
-
- i = 0;
- avn = cif->nargs;
- arg_types = cif->arg_types;
-
- while (i < avn)
- {
- switch ((*arg_types)->type)
- {
- case FFI_TYPE_SINT8:
- *(SINT64 *) argp = *(SINT8 *)(* avalue);
- break;
-
- case FFI_TYPE_UINT8:
- *(SINT64 *) argp = *(UINT8 *)(* avalue);
- break;
-
- case FFI_TYPE_SINT16:
- *(SINT64 *) argp = *(SINT16 *)(* avalue);
- break;
-
- case FFI_TYPE_UINT16:
- *(SINT64 *) argp = *(UINT16 *)(* avalue);
- break;
-
- case FFI_TYPE_SINT32:
- case FFI_TYPE_UINT32:
- /* Note that unsigned 32-bit quantities are sign extended. */
- *(SINT64 *) argp = *(SINT32 *)(* avalue);
- break;
-
- case FFI_TYPE_SINT64:
- case FFI_TYPE_UINT64:
- case FFI_TYPE_POINTER:
- *(UINT64 *) argp = *(UINT64 *)(* avalue);
- break;
-
- case FFI_TYPE_FLOAT:
- if (argp - stack < 6)
- {
- /* Note the conversion -- all the fp regs are loaded as
- doubles. The in-register format is the same. */
- *(double *) argp = *(float *)(* avalue);
- }
- else
- *(float *) argp = *(float *)(* avalue);
- break;
-
- case FFI_TYPE_DOUBLE:
- *(double *) argp = *(double *)(* avalue);
- break;
-
- case FFI_TYPE_STRUCT:
- memcpy(argp, *avalue, (*arg_types)->size);
- break;
-
- default:
- FFI_ASSERT(0);
- }
-
- argp += ALIGN((*arg_types)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
- i++, arg_types++, avalue++;
- }
-
- ffi_call_osf(stack, cif->bytes, cif->flags, rvalue, fn);
-}
-
-
-ffi_status
-ffi_prep_closure (ffi_closure* closure,
- ffi_cif* cif,
- void (*fun)(ffi_cif*, void*, void**, void*),
- void *user_data)
-{
- unsigned int *tramp;
-
- FFI_ASSERT (cif->abi == FFI_OSF);
-
- tramp = (unsigned int *) &closure->tramp[0];
- tramp[0] = 0x47fb0401; /* mov $27,$1 */
- tramp[1] = 0xa77b0010; /* ldq $27,16($27) */
- tramp[2] = 0x6bfb0000; /* jmp $31,($27),0 */
- tramp[3] = 0x47ff041f; /* nop */
- *(void **) &tramp[4] = ffi_closure_osf;
-
- closure->cif = cif;
- closure->fun = fun;
- closure->user_data = user_data;
-
- /* Flush the Icache.
-
- Tru64 UNIX as doesn't understand the imb mnemonic, so use call_pal
- instead, since both Compaq as and gas can handle it.
-
- 0x86 is PAL_imb in Tru64 UNIX <alpha/pal.h>. */
- asm volatile ("call_pal 0x86" : : : "memory");
-
- return FFI_OK;
-}
-
-int
-ffi_closure_osf_inner(ffi_closure *closure, void *rvalue, unsigned long *argp)
-{
- ffi_cif *cif;
- void **avalue;
- ffi_type **arg_types;
- long i, avn, argn;
-
- cif = closure->cif;
- avalue = alloca(cif->nargs * sizeof(void *));
-
- argn = 0;
-
- /* Copy the caller's structure return address to that the closure
- returns the data directly to the caller. */
- if (cif->flags == FFI_TYPE_STRUCT)
- {
- rvalue = (void *) argp[0];
- argn = 1;
- }
-
- i = 0;
- avn = cif->nargs;
- arg_types = cif->arg_types;
-
- /* Grab the addresses of the arguments from the stack frame. */
- while (i < avn)
- {
- switch (arg_types[i]->type)
- {
- case FFI_TYPE_SINT8:
- case FFI_TYPE_UINT8:
- case FFI_TYPE_SINT16:
- case FFI_TYPE_UINT16:
- case FFI_TYPE_SINT32:
- case FFI_TYPE_UINT32:
- case FFI_TYPE_SINT64:
- case FFI_TYPE_UINT64:
- case FFI_TYPE_POINTER:
- case FFI_TYPE_STRUCT:
- avalue[i] = &argp[argn];
- break;
-
- case FFI_TYPE_FLOAT:
- if (argn < 6)
- {
- /* Floats coming from registers need conversion from double
- back to float format. */
- *(float *)&argp[argn - 6] = *(double *)&argp[argn - 6];
- avalue[i] = &argp[argn - 6];
- }
- else
- avalue[i] = &argp[argn];
- break;
-
- case FFI_TYPE_DOUBLE:
- avalue[i] = &argp[argn - (argn < 6 ? 6 : 0)];
- break;
-
- default:
- FFI_ASSERT(0);
- }
-
- argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
- i++;
- }
-
- /* Invoke the closure. */
- (closure->fun) (cif, rvalue, avalue, closure->user_data);
-
- /* Tell ffi_closure_osf how to perform return type promotions. */
- return cif->rtype->type;
-}
diff --git a/libffi/src/alpha/ffitarget.h b/libffi/src/alpha/ffitarget.h
deleted file mode 100644
index 00a1217..0000000
--- a/libffi/src/alpha/ffitarget.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -----------------------------------------------------------------*-C-*-
- ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc.
- Target configuration macros for Alpha.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- ``Software''), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
-
- ----------------------------------------------------------------------- */
-
-#ifndef LIBFFI_TARGET_H
-#define LIBFFI_TARGET_H
-
-#ifndef LIBFFI_ASM
-typedef unsigned long ffi_arg;
-typedef signed long ffi_sarg;
-
-typedef enum ffi_abi {
- FFI_FIRST_ABI = 0,
- FFI_OSF,
- FFI_DEFAULT_ABI = FFI_OSF,
- FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
-} ffi_abi;
-#endif
-
-/* ---- Definitions for closures ----------------------------------------- */
-
-#define FFI_CLOSURES 1
-#define FFI_TRAMPOLINE_SIZE 24
-#define FFI_NATIVE_RAW_API 0
-
-#endif
-
diff --git a/libffi/src/alpha/osf.S b/libffi/src/alpha/osf.S
deleted file mode 100644
index cfa7a96..0000000
--- a/libffi/src/alpha/osf.S
+++ /dev/null
@@ -1,355 +0,0 @@
-/* -----------------------------------------------------------------------
- osf.S - Copyright (c) 1998, 2001 Red Hat
-
- Alpha/OSF Foreign Function Interface
-
- $Id: osf.S,v 1.1.1.1 1998/11/29 16:48:16 green Exp $
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- ``Software''), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
- ----------------------------------------------------------------------- */
-
-#define LIBFFI_ASM
-#include <fficonfig.h>
-#include <ffi.h>
-
- .arch ev6
- .text
-
-/* ffi_call_osf (void *args, unsigned long bytes, unsigned flags,
- void *raddr, void (*fnaddr)());
-
- Bit o trickiness here -- ARGS+BYTES is the base of the stack frame
- for this function. This has been allocated by ffi_call. We also
- deallocate some of the stack that has been alloca'd. */
-
- .align 3
- .globl ffi_call_osf
- .ent ffi_call_osf
-ffi_call_osf:
- .frame $15, 32, $26, 0
- .mask 0x4008000, -32
-$LFB1:
- addq $16,$17,$1
- mov $16, $30
- stq $26, 0($1)
-$LCFI0:
- stq $15, 8($1)
-$LCFI1:
- stq $18, 16($1)
- mov $1, $15
-$LCFI2:
- .prologue 0
-
- stq $19, 24($1)
- mov $20, $27
-
- # Load up all of the (potential) argument registers.
- ldq $16, 0($30)
- ldt $f16, 0($30)
- ldt $f17, 8($30)
- ldq $17, 8($30)
- ldt $f18, 16($30)
- ldq $18, 16($30)
- ldt $f19, 24($30)
- ldq $19, 24($30)
- ldt $f20, 32($30)
- ldq $20, 32($30)
- ldt $f21, 40($30)
- ldq $21, 40($30)
-
- # Deallocate the register argument area.
- lda $30, 48($30)
-
- jsr $26, ($27), 0
- ldgp $29, 0($26)
-
- # If the return value pointer is NULL, assume no return value.
- ldq $19, 24($15)
- ldq $18, 16($15)
- ldq $26, 0($15)
- beq $19, $noretval
-
- # Store the return value out in the proper type.
- cmpeq $18, FFI_TYPE_INT, $1
- bne $1, $retint
- cmpeq $18, FFI_TYPE_FLOAT, $2
- bne $2, $retfloat
- cmpeq $18, FFI_TYPE_DOUBLE, $3
- bne $3, $retdouble
-
-$noretval:
- ldq $15, 8($15)
- ret
-
-$retint:
- stq $0, 0($19)
- nop
- ldq $15, 8($15)
- ret
-
-$retfloat:
- sts $f0, 0($19)
- nop
- ldq $15, 8($15)
- ret
-
-$retdouble:
- stt $f0, 0($19)
- nop
- ldq $15, 8($15)
- ret
-$LFE1:
-
- .end ffi_call_osf
-
-/* ffi_closure_osf(...)
-
- Receives the closure argument in $1. */
-
- .align 3
- .globl ffi_closure_osf
- .ent ffi_closure_osf
-ffi_closure_osf:
- .frame $30, 16*8, $26, 0
- .mask 0x4000000, -16*8
-$LFB2:
- ldgp $29, 0($27)
- subq $30, 16*8, $30
-$LCFI5:
- stq $26, 0($30)
-$LCFI6:
- .prologue 1
-
- # Store all of the potential argument registers in va_list format.
- stt $f16, 4*8($30)
- stt $f17, 5*8($30)
- stt $f18, 6*8($30)
- stt $f19, 7*8($30)
- stt $f20, 8*8($30)
- stt $f21, 9*8($30)
- stq $16, 10*8($30)
- stq $17, 11*8($30)
- stq $18, 12*8($30)
- stq $19, 13*8($30)
- stq $20, 14*8($30)
- stq $21, 15*8($30)
-
- # Call ffi_closure_osf_inner to do the bulk of the work.
- mov $1, $16
- lda $17, 2*8($30)
- lda $18, 10*8($30)
- jsr $26, ffi_closure_osf_inner
- ldgp $29, 0($26)
- ldq $26, 0($30)
-
- # Load up the return value in the proper type.
- lda $1, $load_table
- s4addq $0, $1, $1
- ldl $1, 0($1)
- addq $1, $29, $1
- jmp $31, ($1), $load_32
-
- .align 4
-$load_none:
- addq $30, 16*8, $30
- ret
-
- .align 4
-$load_float:
- lds $f0, 16($30)
- nop
- addq $30, 16*8, $30
- ret
-
- .align 4
-$load_double:
- ldt $f0, 16($30)
- nop
- addq $30, 16*8, $30
- ret
-
- .align 4
-$load_u8:
-#ifdef __alpha_bwx__
- ldbu $0, 16($30)
- nop
-#else
- ldq $0, 16($30)
- and $0, 255, $0
-#endif
- addq $30, 16*8, $30
- ret
-
- .align 4
-$load_s8:
-#ifdef __alpha_bwx__
- ldbu $0, 16($30)
- sextb $0, $0
-#else
- ldq $0, 16($30)
- sll $0, 56, $0
- sra $0, 56, $0
-#endif
- addq $30, 16*8, $30
- ret
-
- .align 4
-$load_u16:
-#ifdef __alpha_bwx__
- ldwu $0, 16($30)
- nop
-#else
- ldq $0, 16($30)
- zapnot $0, 3, $0
-#endif
- addq $30, 16*8, $30
- ret
-
- .align 4
-$load_s16:
-#ifdef __alpha_bwx__
- ldwu $0, 16($30)
- sextw $0, $0
-#else
- ldq $0, 16($30)
- sll $0, 48, $0
- sra $0, 48, $0
-#endif
- addq $30, 16*8, $30
- ret
-
- .align 4
-$load_32:
- ldl $0, 16($30)
- nop
- addq $30, 16*8, $30
- ret
-
- .align 4
-$load_64:
- ldq $0, 16($30)
- nop
- addq $30, 16*8, $30
- ret
-$LFE2:
-
- .end ffi_closure_osf
-
-#ifdef __ELF__
-.section .rodata
-#else
-.rdata
-#endif
-$load_table:
- .gprel32 $load_none # FFI_TYPE_VOID
- .gprel32 $load_32 # FFI_TYPE_INT
- .gprel32 $load_float # FFI_TYPE_FLOAT
- .gprel32 $load_double # FFI_TYPE_DOUBLE
- .gprel32 $load_double # FFI_TYPE_LONGDOUBLE
- .gprel32 $load_u8 # FFI_TYPE_UINT8
- .gprel32 $load_s8 # FFI_TYPE_SINT8
- .gprel32 $load_u16 # FFI_TYPE_UINT16
- .gprel32 $load_s16 # FFI_TYPE_SINT16
- .gprel32 $load_32 # FFI_TYPE_UINT32
- .gprel32 $load_32 # FFI_TYPE_SINT32
- .gprel32 $load_64 # FFI_TYPE_UINT64
- .gprel32 $load_64 # FFI_TYPE_SINT64
- .gprel32 $load_none # FFI_TYPE_STRUCT
- .gprel32 $load_64 # FFI_TYPE_POINTER
-
-/* Assert that the table above is in sync with ffi.h. */
-
-#if FFI_TYPE_FLOAT != 2 \
- || FFI_TYPE_DOUBLE != 3 \
- || FFI_TYPE_UINT8 != 5 \
- || FFI_TYPE_SINT8 != 6 \
- || FFI_TYPE_UINT16 != 7 \
- || FFI_TYPE_SINT16 != 8 \
- || FFI_TYPE_UINT32 != 9 \
- || FFI_TYPE_SINT32 != 10 \
- || FFI_TYPE_UINT64 != 11 \
- || FFI_TYPE_SINT64 != 12 \
- || FFI_TYPE_STRUCT != 13 \
- || FFI_TYPE_POINTER != 14 \
- || FFI_TYPE_LAST != 14
-#error "osf.S out of sync with ffi.h"
-#endif
-
-#ifdef __ELF__
- .section .eh_frame,EH_FRAME_FLAGS,@progbits
-__FRAME_BEGIN__:
- .4byte $LECIE1-$LSCIE1 # Length of Common Information Entry
-$LSCIE1:
- .4byte 0x0 # CIE Identifier Tag
- .byte 0x1 # CIE Version
- .ascii "zR\0" # CIE Augmentation
- .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
- .byte 0x78 # sleb128 -8; CIE Data Alignment Factor
- .byte 0x1a # CIE RA Column
- .byte 0x1 # uleb128 0x1; Augmentation size
- .byte 0x1b # FDE Encoding (pcrel sdata4)
- .byte 0xc # DW_CFA_def_cfa
- .byte 0x1e # uleb128 0x1e
- .byte 0x0 # uleb128 0x0
- .align 3
-$LECIE1:
-$LSFDE1:
- .4byte $LEFDE1-$LASFDE1 # FDE Length
-$LASFDE1:
- .4byte $LASFDE1-__FRAME_BEGIN__ # FDE CIE offset
- .4byte $LFB1-. # FDE initial location
- .4byte $LFE1-$LFB1 # FDE address range
- .byte 0x0 # uleb128 0x0; Augmentation size
- .byte 0x4 # DW_CFA_advance_loc4
- .4byte $LCFI0-$LFB1
- .byte 0xe # DW_CFA_def_cfa_offset
- .byte 0x30 # uleb128 0x30
- .byte 0x4 # DW_CFA_advance_loc4
- .4byte $LCFI1-$LCFI0
- .byte 0x9a # DW_CFA_offset, column 0x1a
- .byte 0x6 # uleb128 0x6
- .byte 0x8f # DW_CFA_offset, column 0xf
- .byte 0x5 # uleb128 0x5
- .byte 0x4 # DW_CFA_advance_loc4
- .4byte $LCFI2-$LCFI1
- .byte 0xc # DW_CFA_def_cfa
- .byte 0xf # uleb128 0xf
- .byte 0x30 # uleb128 0x30
- .align 3
-$LEFDE1:
-
-$LSFDE3:
- .4byte $LEFDE3-$LASFDE3 # FDE Length
-$LASFDE3:
- .4byte $LASFDE3-__FRAME_BEGIN__ # FDE CIE offset
- .4byte $LFB2-. # FDE initial location
- .4byte $LFE2-$LFB2 # FDE address range
- .byte 0x0 # uleb128 0x0; Augmentation size
- .byte 0x4 # DW_CFA_advance_loc4
- .4byte $LCFI5-$LFB2
- .byte 0xe # DW_CFA_def_cfa_offset
- .byte 0x90,0x1 # uleb128 0x90
- .byte 0x4 # DW_CFA_advance_loc4
- .4byte $LCFI6-$LCFI5
- .byte 0x9a # DW_CFA_offset, column 0x1a
- .byte 0x12 # uleb128 0x12
- .align 3
-$LEFDE3:
-#endif