Back to index

glibc  2.9
Defines | Functions | Variables
switch.c File Reference
#include <signal.h>
#include <68881-sw.h>

Go to the source code of this file.




static void trap (int sig)
void __68881_switch (int dummy)


static int have_fpu = -1

Define Documentation


Definition at line 26 of file switch.c.

Function Documentation

void __68881_switch ( int  dummy)

Definition at line 47 of file switch.c.

  void **return_address_location = &((void **) &dummy)[-1];
  struct switch_caller *const caller
    = (struct switch_caller *) (((short int *) *return_address_location) - 1);

  if (have_fpu < 0)
      /* Figure out whether or not we have a 68881.  */
      __sighandler_t handler = signal (TRAPSIG, trap);
      if (handler == SIG_ERR)
       /* We can't figure it out, so assume we don't have a 68881.
          This assumption will never cause us any problems other than
          lost performance, while the reverse assumption could cause
          the program to crash.  */
       have_fpu = 0;
         /* We set `have_fpu' to nonzero, and then execute a 68881
            no-op instruction.  If we have a 68881, this will do nothing.
            If we don't have one, this will trap and the signal handler
            will clear `have_fpu'.  */
         have_fpu = 1;
         asm ("fnop");

         /* Restore the old signal handler.  */
         (void) signal (TRAPSIG, handler);

  /* Modify the caller to be a jump to the appropriate address.  */
  caller->insn = JMP;
  caller->target = have_fpu ? caller->fpu : caller->soft;

  /* Make the address we will return to be the target we have chosen.
     Our return will match the `jsr' done by the caller we have
     just modified, and it will be just as if that had instead
     been a `jmp' to the new target.  */
  *return_address_location = caller->target;

Here is the call graph for this function:

static void trap ( int  sig) [static]

Definition at line 35 of file switch.c.

  have_fpu = 0;

Here is the caller graph for this function:

Variable Documentation

int have_fpu = -1 [static]

Definition at line 30 of file switch.c.