Blame view

build1/epsilon-master/liba/src/aeabi-rt/float.h 1.37 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  #ifndef LIBA_AEABI_FLOAT_H
  #define LIBA_AEABI_FLOAT_H
  
  #include <assert.h>
  #include "../external/softfloat/port/softfloat.h"
  
  /* To avoid any issue due to procedure call conventions, we convert softfloat
   * double 'aeabi_double_t' (respectively 'aeabi_float_t') to float64_t (to
   * respectively float32_t) before or/and after calling softfloat functions. */
  
  typedef unsigned aeabi_float_t;
  typedef unsigned long long aeabi_double_t;
  
  static inline float32_t f32(aeabi_float_t f) {
    union {
      aeabi_float_t in;
      float32_t out;
    } res = {.in = f};
    assert(sizeof(aeabi_float_t) == sizeof(float32_t));
    assert(sizeof(res) == sizeof(float32_t));
    return res.out;
  }
  
  static inline aeabi_float_t f(float32_t f) {
    union {
      float32_t in;
      aeabi_float_t out;
    } res = {.in = f};
    assert(sizeof(aeabi_float_t) == sizeof(float32_t));
    assert(sizeof(res) == sizeof(aeabi_float_t));
    return res.out;
  }
  
  static inline float64_t f64(aeabi_double_t d) {
    union {
      aeabi_double_t in;
      float64_t out;
    } res = {.in = d};
    assert(sizeof(aeabi_double_t) == sizeof(float64_t));
    assert(sizeof(res) == sizeof(float64_t));
    return res.out;
  }
  
  
  static inline aeabi_double_t d(float64_t d) {
    union {
      float64_t in;
      aeabi_double_t out;
    } res = {.in = d};
    assert(sizeof(aeabi_double_t) == sizeof(float64_t));
    assert(sizeof(res) == sizeof(aeabi_double_t));
    return res.out;
  }
  
  #endif