Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Sep 1998 03:05:29 +0900 (JST)
From:      kiroh@pp.iij4u.or.jp (HARADA Kiroh)
To:        ports@FreeBSD.ORG
Subject:   POVRAY port fix (FPE problem fix)
Message-ID:  <199809291805.DAA22520@pp.iij4u.or.jp>

next in thread | raw e-mail | index | archive | help
Dear porters,

I found that the port of POVRAY-3.0 eventually crashes with floating
exception.  The cause was that FreeBSD does not handle floating point
exception in IEEE 754 manner.

Attached is the patch to prevent povray crash with FPE.  It masks
several FPEs in the beginning of the problem and restores them at the
end.

Please update the port as appropriate.  Thank you.

Regards,
--
Kiroh HARADA
kiroh@pp.iij4u.or.jp, kiroh@jp.freebsd.org
PGP Fingerprint: 38 0D E0 BD BB C1 8F E0  93 3C 13 30 39 F7 C4 79
PGP Public Key : http://www.pp.iij4u.or.jp/~kiroh/harada.asc


*** povray.c.orig	Wed Sep 23 20:10:31 1998
--- povray.c	Wed Sep 30 02:57:14 1998
***************
*** 24,29 ****
--- 24,34 ----
  
  #include <ctype.h>
  #include <time.h>     /* BP */
+ 
+ #ifdef __FreeBSD__     /* to prevent FPE on FreeBSD */
+ #include <floatingpoint.h>
+ #endif
+ 
  #include "frame.h"    /* common to ALL modules in this program */
  #include "povproto.h"
  #include "bezier.h"
***************
*** 198,205 ****
  
  
  #ifdef NOCMDLINE    /* a main() by any other name... */
! #ifdef ALTMAIN
!   MAIN_RETURN_TYPE alt_main()
  #else
    MAIN_RETURN_TYPE main()
  #endif
--- 203,209 ----
  
  
  #ifdef NOCMDLINE    /* a main() by any other name... */
! #ifdef ALTMAIN  MAIN_RETURN_TYPE alt_main()
  #else
    MAIN_RETURN_TYPE main()
  #endif
***************
*** 218,223 ****
--- 222,232 ----
    DBL Diff_Clock;
    SHELLRET Pre_Scene_Result, Frame_Result;
  
+ #ifdef __FreeBSD__  /* to prevent FPE on FreeBSD */
+   /* allow divide by zero -- Inf */
+   fpsetmask(fpgetmask() & ~(FP_X_OFL|FP_X_DZ|FP_X_INV));
+ #endif
+ 
    /* Attention all ALTMAIN people! See comments attached to this function*/
    pre_init_povray();
  
***************
*** 371,376 ****
--- 380,390 ----
    /* And finish. */
  
    Terminate_POV(0);
+ 
+ #ifdef __FreeBSD__   /* restore original FPE handling in FreeBSD */
+   fpresetsticky(FP_X_DZ|FP_X_INV);
+   fpsetmask(FP_X_OFL|FP_X_DZ|FP_X_INV);
+ #endif
  
    MAIN_RETURN_STATEMENT
  } /* main */

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809291805.DAA22520>