Changeset 4985


Ignore:
Timestamp:
Aug 20, 2006, 10:58:49 PM (18 years ago)
Author:
Gary Byers
Message:

Still needs lots of work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lisp-kernel/x86-exceptions.c

    r4954 r4985  
    17721772
    17731773
    1774 int
    1775 thread_set_fp_exceptions_enabled(mach_port_t thread, Boolean enabled)
    1776 {
    1777 #ifdef X8664
    1778   x86_thread_state64_t ts;
    1779 #else
    1780   x86_thread_state_t ts;
    1781 #endif
    1782   mach_msg_type_number_t thread_state_count;
    1783 
    1784 #ifdef X8664
    1785   thread_state_count = X86_THREAD_STATE64_COUNT;
    1786 #else
    1787   thread_state_count = X86_THREAD_STATE_COUNT;
    1788 #endif
    1789   thread_get_state(thread,
    1790 #ifdef X8664
    1791                    X86_THREAD_STATE64,  /* GPRs, some SPRs  */
    1792 #else
    1793                    X86_THREAD_STATE,    /* GPRs, some SPRs  */
    1794 #endif
    1795                    (thread_state_t)&ts,
    1796                    &thread_state_count);
    1797   if (enabled) {
    1798     ts.srr1 |= MSR_FE0_FE1_MASK;
    1799   } else {
    1800     ts.srr1 &= ~MSR_FE0_FE1_MASK;
    1801   }
    1802   /*
    1803      Hack-o-rama warning (isn't it about time for such a warning?):
    1804      pthread_kill() seems to want to lose the MSR's FE0/FE1 bits.
    1805      Our handler for lisp's use of pthread_kill() pushes a phony
    1806      lisp frame on the stack and force the context to resume at
    1807      the UUO in enable_fp_exceptions(); the "saveLR" field of that
    1808      lisp frame contains the -real- address that process_interrupt
    1809      should have returned to, and the fact that it's in a lisp
    1810      frame should convince the GC to notice that address if it
    1811      runs in the tiny time window between returning from our
    1812      interrupt handler and ... here.
    1813      If the top frame on the stack is a lisp frame, discard it
    1814      and set ts.srr0 to the saveLR field in that frame.  Otherwise,
    1815      just adjust ts.srr0 to skip over the UUO.
    1816   */
    1817   {
    1818     lisp_frame *tos = (lisp_frame *)ts.r1,
    1819       *next_frame = tos->backlink;
    1820    
    1821     if (tos == (next_frame -1)) {
    1822       ts.srr0 = tos->savelr;
    1823       ts.r1 = (LispObj) next_frame;
    1824     } else {
    1825       ts.srr0 += 4;
    1826     }
    1827   }
    1828   thread_set_state(thread,
    1829 #ifdef X8664
    1830                    X86_THREAD_STATE64,  /* GPRs, some SPRs  */
    1831 #else
    1832                    X86_THREAD_STATE,    /* GPRs, some SPRs  */
    1833 #endif
    1834                    (thread_state_t)&ts,
    1835 #ifdef X8664
    1836                    X86_THREAD_STATE64_COUNT
    1837 #else
    1838                    X86_THREAD_STATE_COUNT
    1839 #endif
    1840                    );
    1841 
    1842   return 0;
    1843 }
     1774
     1775
    18441776
    18451777/*
Note: See TracChangeset for help on using the changeset viewer.