Back to index

glibc  2.9
68881-sw.h
Go to the documentation of this file.
00001 /* Copyright (C) 1991, 1992, 1997, 2000 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef       _68881_SWITCH_H
00020 
00021 #define       _68881_SWITCH_H      1
00022 #include <sys/cdefs.h>
00023 
00024 /* This is the format of the data at the code label for a function which
00025    wants to switch depending on whether or not a 68881 is present.
00026 
00027    Initially, `insn' is a `jsr' instruction, and `target' is __68881_switch.
00028    The first time such a function is called, __68881_switch determines whether
00029    or not a 68881 is present, and modifies the function accordingly.
00030    Then `insn' is a `jmp' instruction, and `target' is the value of `fpu'
00031    if there is 68881, or the value of `soft' if not.  */
00032 
00033 struct switch_caller
00034   {
00035     unsigned short int insn;       /* The `jsr' or `jmp' instruction.  */
00036     void *target;           /* The target of the instruction.  */
00037     void *soft;                    /* The address of the soft function.  */
00038     void *fpu;                     /* The address of the 68881 function.  */
00039   };
00040 
00041 /* These are opcodes (values for `insn', above) for `jmp' and `jsr'
00042    instructions, respectively, to 32-bit absolute addresses.  */
00043 #define       JMP    0x4ef9
00044 #define       JSR    0x4eb9
00045 
00046 
00047 /* Function to determine whether or not a 68881 is available,
00048    and modify its caller (which must be a `struct switch_caller', above,
00049    in data space) to use the appropriate version.  */
00050 extern void __68881_switch (int __dummy) __THROW;
00051 
00052 
00053 /* Define FUNCTION as a `struct switch_caller' which will call
00054    `__FUNCTION_68881' if a 68881 is present, and `__FUNCTION_soft' if not.
00055 #define       switching_function(FUNCTION)                                         \
00056   struct switch_caller FUNCTION =                                    \
00057     {                                                                \
00058       JSR, (__ptr_t) __68881_switch,                                        \
00059       __CONCAT(__CONCAT(__,FUNCTION),_soft),                                \
00060       __CONCAT(__CONCAT(__,FUNCTION),_68881)                                \
00061     }
00062 
00063 
00064 #endif /* 68881-switch.h  */