Professional Web Applications Themes

OS 10.3 and floating point exception handling. - Mac Programming

Does anyone know if the mechanism for handling floating point exceptions has changed from 10.2 to 10.3? The following is what I have been doing in 10.2, but in 10.3 I get exceptions every time I take a sqrt. Any ideas? Jamie -- void * fpe_enabler(void * parent) { mach_port_t victim = (mach_port_t)parent; mach_msg_type_number_t count; ppc_thread_state_t ts; ppc_float_state_t fs; /* First enable the right FP exception conditions */ count = PPC_FLOAT_STATE_COUNT; thread_get_state(victim, PPC_FLOAT_STATE, (thread_state_t)&fs, &count); /* Enable VE OE ZE, Disable UE XE */ fs.fpscr = (fs.fpscr & ~0x1FFFFF28) | 0x0D0; thread_set_state(victim, PPC_FLOAT_STATE, (thread_state_t)&fs, count); /* Now, enable FP exceptions ...

  1. #1

    Default OS 10.3 and floating point exception handling.


    Does anyone know if the mechanism for handling floating point exceptions
    has changed from 10.2 to 10.3?

    The following is what I have been doing in 10.2, but in 10.3 I get
    exceptions every time I take a sqrt.

    Any ideas?
    Jamie

    --
    void * fpe_enabler(void * parent)
    {
    mach_port_t victim = (mach_port_t)parent;
    mach_msg_type_number_t count;

    ppc_thread_state_t ts;
    ppc_float_state_t fs;

    /* First enable the right FP exception conditions */
    count = PPC_FLOAT_STATE_COUNT;
    thread_get_state(victim, PPC_FLOAT_STATE, (thread_state_t)&fs, &count);

    /* Enable VE OE ZE, Disable UE XE */
    fs.fpscr = (fs.fpscr & ~0x1FFFFF28) | 0x0D0;
    thread_set_state(victim, PPC_FLOAT_STATE, (thread_state_t)&fs, count);

    /* Now, enable FP exceptions as such */
    count = PPC_THREAD_STATE_COUNT;
    thread_get_state(victim, PPC_THREAD_STATE, (thread_state_t)&ts, &count);

    /* Set FE0 = FE1 = 1 */
    ts.srr1 |= 0x0900;
    thread_set_state(victim, PPC_THREAD_STATE, (thread_state_t)&ts, count);

    return 0;
    }

    static void
    catch_sigfpe (sig)
    int sig;
    {
    fail ("Floating point exception.");
    raise_exception ();
    }

    void
    enable_fpe_traps ()
    {
    pthread_t enabler;
    pthread_create (&enabler, NULL, fpe_enabler, mach_thread_self());
    pthread_join (enabler, NULL);

    signal (SIGFPE, catch_sigfpe);
    }

    Jamie Guest

  2. #2

    Default Re: OS 10.3 and floating point exception handling.

    In article
    <atm.ox.ac.uk>,
    Jamie Smyth <com> wrote:
     

    I'd suggest asking this on Apple's darwin-development list. There are
    more people who know the low levels of the system in depth there than
    here.

    -Eric

    --
    Eric Albert edu
    http://rescomp.stanford.edu/~ejalbert/
    Eric Guest

Similar Threads

  1. comparing floating point numbers
    By Thens in forum PERL Miscellaneous
    Replies: 4
    Last Post: March 3rd, 04:57 PM
  2. #14366 [Csd]: exit signal Floating point exception (8)
    By bugs at kreho dot com in forum PHP Development
    Replies: 0
    Last Post: October 7th, 02:03 PM
  3. Replies: 0
    Last Post: July 29th, 05:39 PM
  4. From floating point to fraction
    By jon rogers in forum PERL Miscellaneous
    Replies: 6
    Last Post: July 5th, 08:19 PM
  5. VAX floating point format conversion
    By Dale Pennington in forum AIX
    Replies: 0
    Last Post: July 3rd, 06:07 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139