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

edit

Replace these lines:

  // Nothing to include.
#else
#  include <fenv.h>
#endif

with

  // Nothing to include.
#elif defined __NetBSD__
#include <ieeefp.h>
#else
#  include <fenv.h>
#endif


part 2

edit

find this:

#else
// 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


replace with this:

#elif defined __NetBSD__

#define CGAL_IA_SETFPCW(CW) fpsetround(fp_rnd(CW))
#define CGAL_IA_GETFPCW(CW) CW = fpgetround()
typedef int  FPU_CW_t;
#define CGAL_FE_TONEAREST    FE_TONEAREST
#define CGAL_FE_TOWARDZERO   FE_TOWARDZERO
#define CGAL_FE_UPWARD       FE_UPWARD
#define CGAL_FE_DOWNWARD     FE_DOWNWARD

#else
// 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

the future

edit

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