Ignore:
Timestamp:
Apr 8, 2008, 4:55:44 AM (11 years ago)
Author:
gb
Message:

Check to see if bogus FP exceptions are raised for one case that has
been known to do so (asinf 1.0) generated spurious divide-by-zero.
Set global flag 'bogus_fp_exceptions' if we get something other than
"inexact result'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/pmcl-kernel.c

    r8616 r9056  
    114114#endif
    115115#include "Threads.h"
     116
     117#include <fenv.h>
    116118
    117119#ifndef MAP_NORESERVE
     
    14391441#endif
    14401442
     1443Boolean
     1444bogus_fp_exceptions = false;
     1445
     1446typedef
     1447float (*float_arg_returns_float)(float);
     1448
     1449float
     1450fcallf(float_arg_returns_float fun, float arg)
     1451{
     1452  return fun(arg);
     1453}
     1454
     1455void
     1456check_bogus_fp_exceptions()
     1457{
     1458#ifdef X8664
     1459  float asinf(float),result;
     1460   
     1461
     1462  natural save_mxcsr = get_mxcsr(), post_mxcsr;
     1463  set_mxcsr(0x1f80);
     1464
     1465  result = fcallf(asinf, 1.0);
     1466  post_mxcsr = get_mxcsr();
     1467  set_mxcsr(save_mxcsr);
     1468  if (post_mxcsr & (FE_ALL_EXCEPT & (~FE_INEXACT))) {
     1469    bogus_fp_exceptions = true;
     1470  }
     1471#endif
     1472}
     1473
    14411474main(int argc, char *argv[], char *envp[], void *aux)
    14421475{
     
    14581491  page_size = getpagesize();
    14591492
     1493  check_bogus_fp_exceptions();
    14601494#ifdef LINUX
    14611495#ifdef X8664
Note: See TracChangeset for help on using the changeset viewer.