; last update 16/04/2004


SwitchCheck: movem.l d0/d1/a0/a1,-(a7)
    jsr _LVOForbid(a6)
   btst #AFB_68060,AttnFlags+1(a6)   ; patched switch() routines are not good for 68060.library
    bne.b ExitSwitchCheck           ; It seems that 68060.library patches Switch() and others without using SetFunction()
                                    ; It seems Switch() patch is yet good for 68040.library
   btst #AFB_68881,AttnFlags+1(a6)  ; check for 68881/882, if present
    bne.b FPU
NOFPU: movea.l a6,a1
   move.l MemForPatch,d0
   add.l #SwitchNOFPU-StartPatch,d0
   movea.w #_LVOSwitch,a0
    jsr _LVOSetFunction(a6)
   bra.b ExitSwitchCheck
 cnop 0,4


FPU: movea.l a6,a1
   move.l MemForPatch,d0
   add.l #SwitchFPU-StartPatch,d0
   movea.w #_LVOSwitch,a0
    jsr _LVOSetFunction(a6)
   move.l MemForPatch,d0
   add.l #ContextRestore-StartPatch,d0
   move.l d0,$230(a6)                  ; install the new FPU optimized context restore routine
ExitSwitchCheck: jsr _LVOCacheClearU(a6)
    jsr _LVOPermit(a6)
   movem.l (a7)+,d0/d1/a0/a1
  rts
 cnop 0,4




