~ubuntu-branches/ubuntu/lucid/fpc/lucid-proposed

« back to all changes in this revision

Viewing changes to fpcsrc/rtl/go32v2/dpmiexcp.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-10-09 23:29:00 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081009232900-553f61m37jkp6upv
Tags: 2.2.2-4
[ Torsten Werner ]
* Update ABI version in fpc-depends automatically.
* Remove empty directories from binary package fpc-source.

[ Mazen Neifer ]
* Removed leading path when calling update-alternatives to remove a Linitian
  error.
* Fixed clean target.
* Improved description of packages. (Closes: #498882)

Show diffs side-by-side

added added

removed removed

Lines of Context:
500
500
 
501
501
{$ifdef CREATE_C_FUNCTIONS}
502
502
function c_setjmp(var rec : dpmi_jmp_buf) : longint;cdecl;[public, alias : '_setjmp'];
503
 
  begin
 
503
begin
 
504
  asm
 
505
        { unset the frame pointer just set }
 
506
        movl    %ebp,%esp
 
507
        popl    %ebp
504
508
{$ifndef REGCALL}
505
509
  { here we need to be subtle :
506
510
    - we need to return with the arg still on the stack
509
513
 
510
514
    For this we shift the return address down and
511
515
    duplicate the rec on stack }
512
 
     asm
513
 
        movl    %ebp,%esp
514
 
        popl    %ebp
515
516
        subl    $8,%esp
516
517
        movl    %eax,(%esp)
517
518
        movl    8(%esp),%eax
518
519
        movl    %eax,4(%esp)
519
520
        movl    12(%esp),%eax
520
521
        movl    %eax,8(%esp)
 
522
    { stack is now:
 
523
          (%esp)   eax           <= we're popping it in the next instruction
 
524
         4(%esp)   return addr
 
525
         8(%esp)   rec           <= automatically removed by dpmi_setjmp
 
526
        12(%esp)   rec           <= the caller will remove this
 
527
    }
521
528
        popl    %eax
522
529
        jmp     dpmi_setjmp
523
 
     end;
524
530
{$ELSE REGCALL}
525
531
    { this is easier with regcall convention
526
 
      because dpmi_setjmp expects rec arg in $eax }
527
 
     asm
528
 
        movl     rec,%eax
529
 
        movl    %ebp,%esp
530
 
        popl    %ebp
531
 
        pushl   %eax
532
 
        { stack is now:
533
 
           (%esp): saved eax
534
 
          4(%esp): return addr
535
 
          8(%esp): rec addr
536
 
          we need just
537
 
          (%esp): return addr }
538
 
        movl    4(%esp),%eax
539
 
        movl    %eax,8(%esp)
540
 
        popl    %eax
541
 
        addl    $4,%esp
 
532
      because dpmi_setjmp expects rec arg in $eax
 
533
 
 
534
      We don't need to touch the stack. We must leave the parameter
 
535
      there since this is a cdecl function (the caller will remove it)
 
536
    }
 
537
        movl    4(%esp), %eax
542
538
        jmp     dpmi_setjmp
543
 
     end;
544
539
{$ENDIF REGCALL}
545
540
  end;
 
541
end;
546
542
{$endif CREATE_C_FUNCTIONS}
547
543
 
548
544
{$ifdef CREATE_C_FUNCTIONS}
597
593
        movl    djgpp_exception_state_ptr, %eax
598
594
        movl    %eax, 60(%edi)
599
595
        { restore EDI }
600
 
        pop     %edi
 
596
        popl    %edi
601
597
        { we come from the initial call }
602
598
        xorl    %eax,%eax
603
599
        movl    %eax,__RESULT
1548
1544
{$endif CREATE_C_FUNCTIONS}
1549
1545
end.
1550
1546
{$else IN_SYSTEM}
 
1547
 
 
1548
{ Default handler for SIGINT. Default action is to quit silently.
 
1549
  However, if a CtrlBreakHandler has been installed, call it and continue if
 
1550
  it returned true.
 
1551
  If you want RTE 217 to be generated, use HandleException instead as the
 
1552
  SIGINT handler }
 
1553
function SIGINT_Handler(x:longint):longint;cdecl;
 
1554
var
 
1555
  iscbreak : boolean;
 
1556
begin
 
1557
  iscbreak:=assigned(djgpp_exception_state_ptr) and
 
1558
    (djgpp_exception_state_ptr^.__signum=$1b);
 
1559
  if assigned(CtrlBreakHandler) and CtrlBreakHandler(iscbreak) then
 
1560
    exit(0); //no need to do cleanups, dpmi_longjmp will do it for us
 
1561
  halt;
 
1562
end;
 
1563
 
1551
1564
const
1552
1565
  FPU_ControlWord : word = $1332;
1553
1566
function HandleException(sig : longint) : longint;cdecl;
1594
1607
           ErrorOfSig:=206
1595
1608
         else
1596
1609
           ErrorOfSig:=207;  {'Coprocessor Error'}
1597
 
         { if exceptions then Reset FPU and reload control word }
 
1610
         { if exceptions then Reset FPU and reload control word }        
1598
1611
         if (FPUStatus and FPU_ExceptionMask)<>0 then
1599
 
           asm
1600
 
             fninit
1601
 
             fldcw FPU_ControlWord
1602
 
           end;
 
1612
           SysResetFPU;
1603
1613
        end;
1604
1614
   4 : ErrorOfSig:=215;    {'Overflow'}
1605
1615
   1,                      {'Debug'}
1615
1625
   17,                     {'Alignment Check',}
1616
1626
   18,                     {'Machine Check',}
1617
1627
   19,                     {'SSE FP error'}
1618
 
   SIGSEGV,SIGTRAP,SIGTIMR,SIGINT,SIGQUIT
1619
 
    : ErrorOfSig:=216;
 
1628
   SIGSEGV,SIGTRAP,SIGTIMR,SIGQUIT,SIGILL:
 
1629
     ErrorOfSig:=216;
 
1630
   $1b, $79, SIGINT : ErrorOfSig:=217;
1620
1631
  end;
1621
1632
  if assigned(djgpp_exception_state_ptr) then
1622
1633
    Begin
1640
1651
  Signal(SIGNOFP,@HandleException);
1641
1652
  Signal(SIGTRAP,@HandleException);
1642
1653
  Signal(SIGTIMR,@HandleException);
1643
 
  Signal(SIGINT,@HandleException);
 
1654
  Signal(SIGINT,@SIGINT_Handler);
1644
1655
  Signal(SIGQUIT,@HandleException);
1645
1656
  Signal(SIGILL,@HandleException);
1646
1657
end;