1 #ifndef MPFQ_GF2N_COMMON_H_
2 #define MPFQ_GF2N_COMMON_H_
3 
4 #include "mpfq.h"
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 // type for small field char 2
11 typedef struct {
12     int io_type;
13 } mpfq_2_field_struct;
14 
15 typedef mpfq_2_field_struct mpfq_2_field[1];
16 typedef const mpfq_2_field_struct * mpfq_2_src_field;
17 typedef mpfq_2_field_struct * mpfq_2_dst_field;
18 
19 #if GNUC_VERSION(4,3,0) || GNUC_VERSION(4,3,1)
20 #warning "Your GCC version is buggy. Binary fields may fail randomly"
21 #endif
22 
23 /* include some helpers for SSE intrinsics */
24 #ifdef  __SSE2__        /* maybe a configure-time check would be better */
25 #include <emmintrin.h>
26 #include <stdint.h>
27 #if defined(__GNUC__) && __GNUC__ == 4 &&__GNUC_MINOR__ == 1
28 #define _mpfq_mm_cvtsi64_m64(u) _mm_cvtsi64x_m64((u))
29 #else
30 #define _mpfq_mm_cvtsi64_m64(u) _mm_cvtsi64_m64((u))
31 #endif
32 /* _m128i from 2 int64_t's */
33 #define _mpfq_mm_setr_epi64(lo, hi)                                     \
34     _mm_setr_epi64(                                                     \
35             _mpfq_mm_cvtsi64_m64((int64_t) (lo)),                       \
36             _mpfq_mm_cvtsi64_m64((int64_t) (hi))                        \
37         )
38 /* _m128i from 1 int64_t's */
39 #define _mpfq_mm_set1_epi64(u) _mm_set1_epi64( _mpfq_mm_cvtsi64_m64((int64_t) (u)))
40 /* _m128i from 2 int64_t CONSTANTS (and try to get suffix right) */
41 #define _mpfq_mm_setr_epi64_c(lo, hi)                                   \
42     _mm_setr_epi64(                                                     \
43             _mpfq_mm_cvtsi64_m64(INT64_C(lo)),                          \
44             _mpfq_mm_cvtsi64_m64(INT64_C(hi))                           \
45         )
46 /* _m128i from 1 int64_t CONSTANT (and try to get suffix right) */
47 #define _mpfq_mm_set1_epi64_c(u) _mm_set1_epi64( _mpfq_mm_cvtsi64_m64(INT64_C(u)))
48 /* and same for 32-bits (which, for some, have SSE-2) */
49 #define _mpfq_mm_setr_epi32(a0, a1, a2, a3)                             \
50     _mm_setr_epi32(                                                     \
51             (int32_t) (a0),                                             \
52             (int32_t) (a1),                                             \
53             (int32_t) (a2),                                             \
54             (int32_t) (a3)                                              \
55             )
56 #define _mpfq_mm_set1_epi32(u) _mm_set1_epi32( (int32_t) (u))
57 #define _mpfq_mm_setr_epi32_c(a0, a1, a2, a3)                           \
58     _mm_setr_epi32(                                                     \
59             (INT32_C(a0)),                                              \
60             (INT32_C(a1)),                                              \
61             (INT32_C(a2)),                                              \
62             (INT32_C(a3))                                               \
63         )
64 #define _mpfq_mm_set1_epi32_c(u) _mm_set1_epi32(INT32_C(u))
65 #endif  /* __SSE2__ */
66 
67 #ifdef __cplusplus
68 }
69 #endif
70 
71 #endif	/* MPFQ_GF2N_COMMON_H_ */
72