File: libintvector-shim.h

package info (click to toggle)
python3.14 3.14.0~rc1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 126,824 kB
  • sloc: python: 745,274; ansic: 713,752; xml: 31,250; sh: 5,822; cpp: 4,063; makefile: 1,988; objc: 787; lisp: 502; javascript: 136; asm: 75; csh: 12
file content (35 lines) | stat: -rw-r--r-- 1,834 bytes parent folder | download
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
/* Some older compilers do not let you include, e.g., <immintrin.h> unless you also use e.g. -mavx.
 * This poses a problem for files like Hacl_Streaming_HMAC.c, which *do* need a vec128 type defined
 * in scope (so that their state type can be defined), but which *must not* be compiled with -mavx
 * (otherwise it would result in illegal instruction errors on machines without -mavx).
 *
 * Rather than add another layer of hacks with `[@ CAbstractStruct ]` and another internal
 * abstraction barrier between Hacl_Streaming_HMAC and optimized files, we simply define the two
 * relevant types to be an incomplete struct (we could also define them to be void). Two
 * consequences:
 * - these types cannot be constructed, which enforces the abstraction barrier -- you can define the
 *   Hacl_Streaming_HMAC state type but only if it uses vec128 behind a pointer, which is exactly
 *   the intent, and
 * - the absence of actual operations over these types once again enforces that a client module
 *   which relies on this header only does type definitions, nothing more, and leaves the actual
 *   operations to the relevant module (e.g. Hacl_Hash_Blake2b_256) -- that one will include
 *   libintvector.h
 *
 * See https://github.com/python/cpython/issues/130213 for a detailed description of the issue
 * including actual problematic compilers.
 *
 * Currently, only Hacl_Streaming_HMAC is crafted carefully enough to do this.
 */

typedef struct __vec128 Lib_IntVector_Intrinsics_vec128;
typedef struct __vec256 Lib_IntVector_Intrinsics_vec256;

/* If a module includes this header, it almost certainly has #ifdef HACL_CAN_COMPILE_XXX all over
 * the place, so bring that into scope too via config.h */
#if defined(__has_include)
#if __has_include("config.h")
#include "config.h"
#endif
#endif

#define HACL_INTRINSICS_SHIMMED