1 |
/* |
2 |
* Gestion du coprocesseur arithmétique (FPU : Flotting Point Unit). Deux |
3 |
* librairies sont supportées : <fenv.h> (fait parti de la glib), et |
4 |
* <float.h> (version Windows). |
5 |
* |
6 |
* Les fonctions ne sont disponnibles que si UTILISE_FENV est défini |
7 |
* (#ifdef UTILISE_FPU). |
8 |
* |
9 |
*/ |
10 |
|
11 |
#ifndef HFPU_H |
12 |
#define HFPU_H |
13 |
//----------------------------------------------------------------------------- |
14 |
#include "base.h" |
15 |
//----------------------------------------------------------------------------- |
16 |
|
17 |
// Utilise la vérification en hardware |
18 |
// via les fonctions _control87 et _status87 ? |
19 |
#if defined(__BORLANDC__) |
20 |
# define UTILISE_FPU |
21 |
# define UTILISE_STATUS87 |
22 |
# define UTILISE_DENORMAL |
23 |
|
24 |
// Utilise le bel entête "fenv.h" ? |
25 |
#elif defined(__MINGW32__) || defined(OS_UNIX) |
26 |
# define UTILISE_FPU |
27 |
# define UTILISE_FENV |
28 |
# if defined(FE_DENORMAL) |
29 |
# define UTILISE_DENORMAL |
30 |
# endif |
31 |
#endif |
32 |
|
33 |
//----------------------------------------------------------------------------- |
34 |
|
35 |
// Include |
36 |
#if defined(UTILISE_STATUS87) |
37 |
# include <float.h> |
38 |
#elif defined(UTILISE_FENV) |
39 |
# include <fenv.h> |
40 |
#endif |
41 |
|
42 |
//----------------------------------------------------------------------------- |
43 |
|
44 |
#if defined(UTILISE_STATUS87) |
45 |
// Définit le type pour lire l'état du FPU |
46 |
typedef unsigned int fexcept_t; |
47 |
|
48 |
// Redéfinit les fonctions de <fenv.h> |
49 |
void fegetexceptflag (fexcept_t *flagp, fexcept_t excepts); |
50 |
void fesetexceptflag (const fexcept_t *flagp, fexcept_t excepts); |
51 |
void feclearexcept (fexcept_t excepts); |
52 |
int fetestexcept (fexcept_t excepts); |
53 |
|
54 |
# if defined(__BORLANDC__) |
55 |
// Masque pour les exceptions |
56 |
# define FE_OVERFLOW EM_OVERFLOW |
57 |
# define FE_UNDERFLOW EM_UNDERFLOW |
58 |
# define FE_DIVBYZERO EM_ZERODIVIDE |
59 |
# define FE_DENORMAL EM_DENORMAL |
60 |
# define MASQUE_ERREUR_87 MCW_EM |
61 |
# elif defined(__CYGWIN__) |
62 |
# define FE_OVERFLOW 0x00000004 |
63 |
# define FE_UNDERFLOW 0x00000002 |
64 |
# define FE_DIVBYZERO 0x00000008 |
65 |
# define FE_DENORMAL 0x00080000 |
66 |
# define MASQUE_ERREUR_87 0x0008001F |
67 |
# endif |
68 |
#endif |
69 |
|
70 |
//----------------------------------------------------------------------------- |
71 |
#endif |