Skip to content

Commit

Permalink
Ensure parser buffer is aligned to 64 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Nov 15, 2023
1 parent ab3c247 commit b7566ec
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kitty/vt-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "state.h"
#include "modes.h"
#include "simd-string.h"
#include <stdalign.h>

#define BUF_SZ (1024u*1024u)
// The extra bytes are so loads of large integers such as for AVX 512 dont read past the end of the buffer
Expand Down Expand Up @@ -207,7 +208,7 @@ typedef struct PS {
// The buffer
struct { size_t consumed, pos, sz; } read;
struct { size_t offset, sz, pending; } write;
uint8_t buf[BUF_SZ + BUF_EXTRA];
alignas(BUF_EXTRA) uint8_t buf[BUF_SZ + BUF_EXTRA];
} PS;
static_assert(offsetof(PS, buf) > sizeof(BYTE_LOADER_T), "There must be enough space before the buf[] array for aligned loads");

Expand Down

0 comments on commit b7566ec

Please sign in to comment.