2006-02-28 Roland McGrath <roland@redhat.com>
[glibc-ports.git] / sysdeps / m68k / fpu / switch / 68881-sw.h
blobc5a0f71fa6eb130f6fcd3314e56e365fde671c53
1 /* Copyright (C) 1991, 1992, 1997, 2000 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #ifndef _68881_SWITCH_H
21 #define _68881_SWITCH_H 1
22 #include <sys/cdefs.h>
24 /* This is the format of the data at the code label for a function which
25 wants to switch depending on whether or not a 68881 is present.
27 Initially, `insn' is a `jsr' instruction, and `target' is __68881_switch.
28 The first time such a function is called, __68881_switch determines whether
29 or not a 68881 is present, and modifies the function accordingly.
30 Then `insn' is a `jmp' instruction, and `target' is the value of `fpu'
31 if there is 68881, or the value of `soft' if not. */
33 struct switch_caller
35 unsigned short int insn; /* The `jsr' or `jmp' instruction. */
36 void *target; /* The target of the instruction. */
37 void *soft; /* The address of the soft function. */
38 void *fpu; /* The address of the 68881 function. */
41 /* These are opcodes (values for `insn', above) for `jmp' and `jsr'
42 instructions, respectively, to 32-bit absolute addresses. */
43 #define JMP 0x4ef9
44 #define JSR 0x4eb9
47 /* Function to determine whether or not a 68881 is available,
48 and modify its caller (which must be a `struct switch_caller', above,
49 in data space) to use the appropriate version. */
50 extern void __68881_switch (int __dummy) __THROW;
53 /* Define FUNCTION as a `struct switch_caller' which will call
54 `__FUNCTION_68881' if a 68881 is present, and `__FUNCTION_soft' if not.
55 #define switching_function(FUNCTION) \
56 struct switch_caller FUNCTION = \
57 { \
58 JSR, (__ptr_t) __68881_switch, \
59 __CONCAT(__CONCAT(__,FUNCTION),_soft), \
60 __CONCAT(__CONCAT(__,FUNCTION),_68881) \
64 #endif /* 68881-switch.h */