1 /* -----------------------------------------------------------------------
2 osf.S - Copyright (c) 1998 Cygnus Solutions
4 Alpha/OSF Foreign Function Interface
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 ``Software''), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice shall be included
15 in all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 OTHER DEALINGS IN THE SOFTWARE.
24 ----------------------------------------------------------------------- */
32 /* ffi_call_osf (void *args, unsigned long bytes, unsigned flags,
33 void *raddr, void (*fnaddr)());
35 Bit o trickiness here -- ARGS+BYTES is the base of the stack frame
36 for this function. This has been allocated by ffi_call. We also
37 deallocate some of the stack that has been alloca'd. */
43 .frame $15, 32, $26, 0
56 # Load up all of the (potential) argument registers.
70 # Deallocate the register argument area.
76 # If the return value pointer is NULL, assume no return value.
82 # Store the return value out in the proper type.
83 cmpeq $18, FFI_TYPE_INT, $1
85 cmpeq $18, FFI_TYPE_FLOAT, $2
87 cmpeq $18, FFI_TYPE_DOUBLE, $3
114 /* ffi_closure_osf(...)
116 Receives the closure argument in $1. */
119 .globl ffi_closure_osf
122 .frame $30, 16*8, $26, 0
123 .mask 0x4000000, -16*8
129 # Store all of the potential argument registers in va_list format.
143 # Call ffi_closure_osf_inner to do the bulk of the work.
147 jsr $26, ffi_closure_osf_inner
151 # Load up the return value in the proper type.
156 jmp $31, ($1), $load_32
245 .gprel32 $load_none # FFI_TYPE_VOID
246 .gprel32 $load_32 # FFI_TYPE_INT
247 .gprel32 $load_float # FFI_TYPE_FLOAT
248 .gprel32 $load_double # FFI_TYPE_DOUBLE
249 .gprel32 $load_double # FFI_TYPE_LONGDOUBLE
250 .gprel32 $load_u8 # FFI_TYPE_UINT8
251 .gprel32 $load_s8 # FFI_TYPE_SINT8
252 .gprel32 $load_u16 # FFI_TYPE_UINT16
253 .gprel32 $load_s16 # FFI_TYPE_SINT16
254 .gprel32 $load_32 # FFI_TYPE_UINT32
255 .gprel32 $load_32 # FFI_TYPE_SINT32
256 .gprel32 $load_64 # FFI_TYPE_UINT64
257 .gprel32 $load_64 # FFI_TYPE_SINT64
258 .gprel32 $load_none # FFI_TYPE_STRUCT
259 .gprel32 $load_64 # FFI_TYPE_POINTER
261 /* Assert that the table above is in sync with ffi.h. */
263 #if FFI_TYPE_FLOAT != 2 \
264 || FFI_TYPE_DOUBLE != 3 \
265 || FFI_TYPE_UINT8 != 5 \
266 || FFI_TYPE_SINT8 != 6 \
267 || FFI_TYPE_UINT16 != 7 \
268 || FFI_TYPE_SINT16 != 8 \
269 || FFI_TYPE_UINT32 != 9 \
270 || FFI_TYPE_SINT32 != 10 \
271 || FFI_TYPE_UINT64 != 11 \
272 || FFI_TYPE_SINT64 != 12 \
273 || FFI_TYPE_STRUCT != 13 \
274 || FFI_TYPE_POINTER != 14 \
275 || FFI_TYPE_LAST != 14
276 #error "osf.S out of sync with ffi.h"