User:157yagz5r48a5f1a1f/patch cgal for netbsd

This is how to patch CGAL to compile on NetBSD x86 / amd64.

The Problem

CGAL's "FPU.h" by default looks for fenv.h. As of late 2011, the released versions of NetBSD don't contain fenv.h. The updated development versions of NetBSD do include it, but the release version does not.

A Solution

We can kludge FPU.h so that it uses NetBSD's "ieeefp.h" instead of fenv.h. I have no idea if this actually works mathematically, but at least CGAL compiles. You only need to edit one file.

Edit CGAL-3.7/include/CGAL/FPU.h

part 1
Replace these lines:

// Nothing to include.
 * 1) else
 * 2)  include 
 * 3) endif

with

// Nothing to include.
 * 1) elif defined __NetBSD__
 * 2) include 
 * 3) else
 * 4)  include 
 * 5) endif

part 2
find this:

// This is a version following the ISO C99 standard, which aims at portability. // The drawbacks are speed on one hand, and also, on x86, it doesn't fix the
 * 1) else

replace with this:


 * 1) elif defined __NetBSD__

typedef int FPU_CW_t;
 * 1) define CGAL_IA_SETFPCW(CW) fpsetround(fp_rnd(CW))
 * 2) define CGAL_IA_GETFPCW(CW) CW = fpgetround
 * 1) define CGAL_FE_TONEAREST   FE_TONEAREST
 * 2) define CGAL_FE_TOWARDZERO  FE_TOWARDZERO
 * 3) define CGAL_FE_UPWARD      FE_UPWARD
 * 4) define CGAL_FE_DOWNWARD    FE_DOWNWARD

// This is a version following the ISO C99 standard, which aims at portability. // The drawbacks are speed on one hand, and also, on x86, it doesn't fix the
 * 1) else

the future
development versions of NetBSD apparently do include fenv.h, so in a few years this page will be obsolete, hopefully!