| 1 |
/* Some older compilers do not let you include, e.g., <immintrin.h> unless you also use e.g. -mavx. |
| 2 |
* This poses a problem for files like Hacl_Streaming_HMAC.c, which *do* need a vec128 type defined |
| 3 |
* in scope (so that their state type can be defined), but which *must not* be compiled with -mavx |
| 4 |
* (otherwise it would result in illegal instruction errors on machines without -mavx). |
| 5 |
* |
| 6 |
* Rather than add another layer of hacks with `[@ CAbstractStruct ]` and another internal |
| 7 |
* abstraction barrier between Hacl_Streaming_HMAC and optimized files, we simply define the two |
| 8 |
* relevant types to be an incomplete struct (we could also define them to be void). Two |
| 9 |
* consequences: |
| 10 |
* - these types cannot be constructed, which enforces the abstraction barrier -- you can define the |
| 11 |
* Hacl_Streaming_HMAC state type but only if it uses vec128 behind a pointer, which is exactly |
| 12 |
* the intent, and |
| 13 |
* - the absence of actual operations over these types once again enforces that a client module |
| 14 |
* which relies on this header only does type definitions, nothing more, and leaves the actual |
| 15 |
* operations to the relevant module (e.g. Hacl_Hash_Blake2b_256) -- that one will include |
| 16 |
* libintvector.h |
| 17 |
* |
| 18 |
* See https://github.com/python/cpython/issues/130213 for a detailed description of the issue |
| 19 |
* including actual problematic compilers. |
| 20 |
* |
| 21 |
* Currently, only Hacl_Streaming_HMAC is crafted carefully enough to do this. |
| 22 |
*/ |
| 23 |
|
| 24 |
typedef struct __vec128 Lib_IntVector_Intrinsics_vec128; |
| 25 |
typedef struct __vec256 Lib_IntVector_Intrinsics_vec256; |
| 26 |
|
| 27 |
/* If a module includes this header, it almost certainly has #ifdef HACL_CAN_COMPILE_XXX all over |
| 28 |
* the place, so bring that into scope too via config.h */ |
| 29 |
#if defined(__has_include) |
| 30 |
#if __has_include("config.h") |
| 31 |
#include "config.h" |
| 32 |
#endif |
| 33 |
#endif |
| 34 |
|
| 35 |
#define HACL_INTRINSICS_SHIMMED |