Skip to content

Commit

Permalink
types: Introduce [us]128
Browse files Browse the repository at this point in the history
Introduce [us]128 (when available). Unlike [us]64, ensure they are
always naturally aligned.

This also enables 128bit wide atomics (which require natural
alignment) such as cmpxchg128().

Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Arnd Bergmann <[email protected]>
Reviewed-by: Mark Rutland <[email protected]>
Acked-by: Herbert Xu <[email protected]>
Tested-by: Mark Rutland <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
Peter Zijlstra committed Jun 5, 2023
1 parent f413e72 commit 224d80c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions include/linux/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#define DECLARE_BITMAP(name,bits) \
unsigned long name[BITS_TO_LONGS(bits)]

#ifdef __SIZEOF_INT128__
typedef __s128 s128;
typedef __u128 u128;
#endif

typedef u32 __kernel_dev_t;

typedef __kernel_fd_set fd_set;
Expand Down
4 changes: 4 additions & 0 deletions include/uapi/linux/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

#include <linux/posix_types.h>

#ifdef __SIZEOF_INT128__
typedef __signed__ __int128 __s128 __attribute__((aligned(16)));
typedef unsigned __int128 __u128 __attribute__((aligned(16)));
#endif

/*
* Below are truly Linux-specific types that should never collide with
Expand Down
2 changes: 0 additions & 2 deletions lib/crypto/curve25519-hacl64.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include <crypto/curve25519.h>
#include <linux/string.h>

typedef __uint128_t u128;

static __always_inline u64 u64_eq_mask(u64 a, u64 b)
{
u64 x = a ^ b;
Expand Down
2 changes: 0 additions & 2 deletions lib/crypto/poly1305-donna64.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include <asm/unaligned.h>
#include <crypto/internal/poly1305.h>

typedef __uint128_t u128;

void poly1305_core_setkey(struct poly1305_core_key *key,
const u8 raw_key[POLY1305_BLOCK_SIZE])
{
Expand Down

0 comments on commit 224d80c

Please sign in to comment.